{"id":678,"date":"2007-12-06T23:43:22","date_gmt":"2007-12-07T04:43:22","guid":{"rendered":"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/06\/secure-travelling-tips-with-iptables-and-ssh-port-forwarding"},"modified":"2007-12-06T23:48:27","modified_gmt":"2007-12-07T04:48:27","slug":"secure-travelling-tips-with-iptables-and-ssh-port-forwarding","status":"publish","type":"post","link":"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/06\/secure-travelling-tips-with-iptables-and-ssh-port-forwarding","title":{"rendered":"Secure travelling tips with iptables and SSH port forwarding"},"content":{"rendered":"<p>The general paranoia at conferences is such that there almost always is WiFi, and there almost always is someone wanting to snoop your traffic. I guess, in a similar vein, this could also happen at Starbucks. So, on day 1, at foss.in I tried to recollect what I used to do, ages ago (when I used to run Fedora on my R51, before the disk died, and I realised I lacked a backup of \/root).<\/p>\n<p><strong>iptables<\/strong><br \/>\nFirewalls break networks? They also secure networks. I have access to some legacy POP servers, that don&#8217;t support SSL\/TLS like the IMAP servers I have access to. Firing up Thunderbird, to change the settings, to point to localhost, just seems like a waste of time. So the magic of iptables comes into play.<br \/>\n<tt><br \/>\niptables -t nat -A PREROUTING -p tcp -d my.pop.server --dport 110 -j DNAT --to-destination 127.0.0.1:1235<br \/>\niptables -t nat -A OUTPUT -p tcp -d my.pop.server --dport 110 -j DNAT --to-destination 127.0.0.1:1235<br \/>\n<\/tt><br \/>\nThe above, ensures that to access my.pop.server:110, the traffic is automatically routed now to localhost:1235. Clearly, I don&#8217;t run a POP server on my laptop, so this is where SSH port forwarding comes into play.<\/p>\n<p><strong>SSH port forwarding<\/strong><br \/>\nProvided you have access to a server via SSH, and you trust it, you can tunnel your traffic through it. Its made very easy by the:<br \/>\n-L localport:my.pop.server:foreignport<\/p>\n<p>So using the above example, that would be -L 1235:my.pop.server:110.<\/p>\n<p>Then, let&#8217;s not forget the useful -C option, to compress traffic.<\/p>\n<p>And hey, web surfing isn&#8217;t secure either, so lets create a SOCKS5 proxy while we&#8217;re at it. ssh supports the -D option, which works a charm. Use it such that you have something like:<br \/>\n-D 8188<\/p>\n<p>And now, configure your web browser, to use a SOCKS proxy, localhost:8188. You can also configure it in GNOME, under the Network Proxy, but it seems like not all applications respect it (for instance, I can get pidgin to segfault, and Liferea will not get RSS updates for some reason, etc.).<\/p>\n<p>So to sum it up, your SSH command should look something like:<br \/>\nssh -D 8188 -L 1235:my.pop.server:110 -C my.ssh.server<\/p>\n<p><strong>Discuss<\/strong><br \/>\nAm I missing something? Do you have an easier iptables rule? Yes, I realise I can also use a VPN. If you have other tips, please don&#8217;t hesitate to comment. Thanks.<\/p>\n<p>Technorati Tags: <a href=\"http:\/\/technorati.com\/tag\/ssh\" class=\"performancingtags\" rel=\"tag\">ssh<\/a>, <a href=\"http:\/\/technorati.com\/tag\/iptables\" class=\"performancingtags\" rel=\"tag\">iptables<\/a>, <a href=\"http:\/\/technorati.com\/tag\/travel\" class=\"performancingtags\" rel=\"tag\">travel<\/a>, <a href=\"http:\/\/technorati.com\/tag\/tips\" class=\"performancingtags\" rel=\"tag\">tips<\/a>, <a href=\"http:\/\/technorati.com\/tag\/wifi\" class=\"performancingtags\" rel=\"tag\">wifi<\/a>, <a href=\"http:\/\/technorati.com\/tag\/open%20access%20points\" class=\"performancingtags\" rel=\"tag\">open access points<\/a>, <a href=\"http:\/\/technorati.com\/tag\/socks5\" class=\"performancingtags\" rel=\"tag\">socks5<\/a><\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"mailto:?subject=%5BShared%20Post%5D%20Secure%20travelling%20tips%20with%20iptables%20and%20SSH%20port%20forwarding&body=http%3A%2F%2Fwww.bytebot.net%2Fblog%2Farchives%2F2007%2F12%2F06%2Fsecure-travelling-tips-with-iptables-and-ssh-port-forwarding&share=email\" target=\"_blank\" title=\"Click to email a link to a friend\" data-email-share-error-title=\"Do you have email set up?\" data-email-share-error-text=\"If you&#039;re having problems sharing via email, you might not have email set up for your browser. You may need to create a new email yourself.\" data-email-share-nonce=\"da9f00aecc\" data-email-share-track-url=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/06\/secure-travelling-tips-with-iptables-and-ssh-port-forwarding?share=email\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-678\" class=\"share-facebook sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/06\/secure-travelling-tips-with-iptables-and-ssh-port-forwarding?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span>Facebook<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-678\" class=\"share-linkedin sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/06\/secure-travelling-tips-with-iptables-and-ssh-port-forwarding?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\" ><span>LinkedIn<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-678\" class=\"share-twitter sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/06\/secure-travelling-tips-with-iptables-and-ssh-port-forwarding?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p>The general paranoia at conferences is such that there almost always is WiFi, and there almost always is someone wanting to snoop your traffic. I guess, in a similar vein, this could also happen at Starbucks. So, on day 1, at foss.in I tried to recollect what I used to do, ages ago (when I [&hellip;]<\/p>\n<div class=\"sharedaddy sd-sharing-enabled\"><div class=\"robots-nocontent sd-block sd-social sd-social-icon-text sd-sharing\"><h3 class=\"sd-title\">Share this:<\/h3><div class=\"sd-content\"><ul><li class=\"share-email\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"\" class=\"share-email sd-button share-icon\" href=\"mailto:?subject=%5BShared%20Post%5D%20Secure%20travelling%20tips%20with%20iptables%20and%20SSH%20port%20forwarding&body=http%3A%2F%2Fwww.bytebot.net%2Fblog%2Farchives%2F2007%2F12%2F06%2Fsecure-travelling-tips-with-iptables-and-ssh-port-forwarding&share=email\" target=\"_blank\" title=\"Click to email a link to a friend\" data-email-share-error-title=\"Do you have email set up?\" data-email-share-error-text=\"If you&#039;re having problems sharing via email, you might not have email set up for your browser. You may need to create a new email yourself.\" data-email-share-nonce=\"da9f00aecc\" data-email-share-track-url=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/06\/secure-travelling-tips-with-iptables-and-ssh-port-forwarding?share=email\"><span>Email<\/span><\/a><\/li><li class=\"share-facebook\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-facebook-678\" class=\"share-facebook sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/06\/secure-travelling-tips-with-iptables-and-ssh-port-forwarding?share=facebook\" target=\"_blank\" title=\"Click to share on Facebook\" ><span>Facebook<\/span><\/a><\/li><li class=\"share-linkedin\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-linkedin-678\" class=\"share-linkedin sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/06\/secure-travelling-tips-with-iptables-and-ssh-port-forwarding?share=linkedin\" target=\"_blank\" title=\"Click to share on LinkedIn\" ><span>LinkedIn<\/span><\/a><\/li><li class=\"share-twitter\"><a rel=\"nofollow noopener noreferrer\" data-shared=\"sharing-twitter-678\" class=\"share-twitter sd-button share-icon\" href=\"http:\/\/www.bytebot.net\/blog\/archives\/2007\/12\/06\/secure-travelling-tips-with-iptables-and-ssh-port-forwarding?share=twitter\" target=\"_blank\" title=\"Click to share on Twitter\" ><span>Twitter<\/span><\/a><\/li><li class=\"share-end\"><\/li><\/ul><\/div><\/div><\/div>","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"jetpack_publicize_message":"","jetpack_is_tweetstorm":false,"jetpack_publicize_feature_enabled":true,"jetpack_social_options":[]},"categories":[1],"tags":[],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/p4vJD-aW","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":822,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2008\/05\/27\/secure-travelling-with-ipfw-on-os-x","url_meta":{"origin":678,"position":0},"title":"Secure travelling with ipfw on OS X?","date":"27\/5\/2008","format":false,"excerpt":"Dear (mac\/bsd) Lazyweb, Any idea how I can do the following, on Mac OS X? iptables -t nat -A PREROUTING -p tcp -d my.pop.server \u2014dport 110 -j DNAT \u2014to-destination 127.0.0.1:1235 iptables -t nat -A OUTPUT -p tcp -d my.pop.server \u2014dport 110 -j DNAT \u2014to-destination 127.0.0.1:1235 Does ipfw(8) work in OS\u2026","rel":"","context":"In &quot;General&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":441,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2006\/11\/14\/linux-performance-server-security-related-book-reviews","url_meta":{"origin":678,"position":1},"title":"Linux (performance, server, security) related book reviews","date":"14\/11\/2006","format":false,"excerpt":"I took a vacation recently, which involved heading down to Hobart, for some rest & relaxation. And lots of food (read: oysters, seafood, yum!). I packed my suitcase with some books for some late night reading, and am pleased to provide some form of review. Linux Server Hacks by Rob\u2026","rel":"","context":"In &quot;General&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":766,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2008\/04\/09\/lugradio-live-registration-fail","url_meta":{"origin":678,"position":2},"title":"LugRadio Live registration FAIL","date":"9\/4\/2008","format":false,"excerpt":"Today I tried to register for LugRadio Live USA 2008, seeing that I will be in San Franciso this Friday. Apparently, their payment provider doesn't like my IP address (or ISP).Declined: We do not currently process transcations from the country your Internet Service Provider is located in.Yes, I could login\u2026","rel":"","context":"In &quot;General&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2856,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2014\/01\/21\/openbsd-foundation-raising-funds","url_meta":{"origin":678,"position":3},"title":"OpenBSD Foundation raising funds","date":"21\/1\/2014","format":false,"excerpt":"The OpenBSD Foundation is raising funds\u00a0- they've got a goal of USD$150,000 (so far they've achieved $100,000). A few days ago they had potential trouble keeping the lights on for this secure BSD distribution, and today they're all set in terms of electricity to power servers and looking for more\u2026","rel":"","context":"In &quot;MariaDB&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":784,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2008\/04\/14\/memcached-and-mysql-tutorial","url_meta":{"origin":678,"position":4},"title":"Memcached and MySQL tutorial","date":"14\/4\/2008","format":false,"excerpt":"Memcached by Brian Aker, Alan Kasindorf (dormando). Here are some quick, somewhat sparse notes. Follow the slides, it will help. Slides: http:\/\/download.tangent.org\/talks\/Memcached%20Study.pdf Memcached was actually created for LiveJournal. It has evolved a bit over time. Chaos to user based clustering, and then Brad implemented memcached. LiveJournal has about 30GB of\u2026","rel":"","context":"In &quot;MySQL&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":740,"url":"http:\/\/www.bytebot.net\/blog\/archives\/2008\/03\/08\/malaysiakini-not-accessible-try-their-ip-address-instead","url_meta":{"origin":678,"position":5},"title":"Malaysiakini not accessible? Try their IP address instead","date":"8\/3\/2008","format":false,"excerpt":"Public Service Announcement: Malaysiakini's DNS servers have been knocked off the Internet. Basically, they're pointing to 127.0.0.1, which is localhost (your machine). Live reports of election results are still available, just access Malaysiakini via their IP address: http:\/\/122.0.17.30\/.Reason behind the DNS being unavailable is unknown, but do keep up with\u2026","rel":"","context":"In &quot;General&quot;","img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"amp_enabled":true,"_links":{"self":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/678"}],"collection":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/comments?post=678"}],"version-history":[{"count":0,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/posts\/678\/revisions"}],"wp:attachment":[{"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/media?parent=678"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/categories?post=678"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.bytebot.net\/blog\/wp-json\/wp\/v2\/tags?post=678"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}