{"id":112,"date":"2014-05-27T21:56:44","date_gmt":"2014-05-27T19:56:44","guid":{"rendered":"https:\/\/blog.gentz.com.de\/bloggentz\/?p=112"},"modified":"2014-07-10T11:56:02","modified_gmt":"2014-07-10T09:56:02","slug":"raspberry-pi-als-vpn-gateway","status":"publish","type":"post","link":"https:\/\/gentz.cloud\/?p=112","title":{"rendered":"Raspberry PI als VPN Gateway"},"content":{"rendered":"<p style=\"text-align: justify;\">Ich habe in Januar ein Raspberry Pi Version B gekauft (f\u00fcr ca. 50\u20ac)<\/p>\n<p style=\"text-align: justify;\">Den RPI wollte ich eigentlich f\u00fcr meinen alten Fernseher einsetzten damit ich Filme\/Fotos\/Musik von meinen\u00a0NAS sehen kann. Leider ist das RPI sehr cool f\u00fcr solche Sachen aber leider nicht damit man sich irgendeinen stream anschaut (leider zu wenig RAM) aber weil ich gerne anonym im Internet surft habe ich mir gedacht bau den RPI doch um in einen VPN Gateway.<\/p>\n<p style=\"text-align: justify;\">Dieses haben ich auch umgesetzt, leider habe ich nicht gro\u00dfe Linux Kenntnisse aber es reicht um solche Sachen zu bauen ;-P. Meistens hat man ja auch einen super Support von Forum Member hier nochmal ein danke an Thomas Butz! Der Thomas hat ein cooles Skript f\u00fcr hide.me geschrieben das dein Rasperry komplett einrichtet damit es als eine VPN Gateway fungiert.<\/p>\n<p style=\"text-align: justify;\">Folgendes Skript k\u00f6nnt ihr auf euren RPI ausf\u00fchren.<\/p>\n<hr \/>\n<p>#! \/bin\/bash<\/p>\n<pre>###########################################\r\n#          Created by Thomas Butz         #\r\n#   E-Mail: btom1990(at)googlemail.com    #\r\n#  Feel free to copy &amp; share this script  #\r\n###########################################\r\n\r\nraspi_client_ip=\"192.168.2.2\" # the IP the Raspberry should use to connect to the router\r\nraspi_client_nm=\"255.255.255.0\" # the netmask of the routers subnet\r\nraspi_client_nw=\"192.168.2.0\" # the network address of the subnet\r\nraspi_client_gw=\"192.168.2.1\" # the IP of your router\r\nraspi_gateway_ip=\"192.168.2.3\" # the IP the clients will use as their gateway\r\n\r\n# Your hide.me credentials\r\nusername=\"sample_user\"\r\npassword=\"sample_password\"\r\n\r\nserver=\"https:\/\/hide.me\/setup\/ovpn\/type\/ovpn\/server\/17\" # Default: Netherlands\r\n\r\n# Don't change anything beyond this point\r\n###########################################\r\n\r\n# Check for root priviliges\r\nif [[ $EUID -ne 0 ]]; then\r\n   printf \"Please run as root:\\nsudo %s\\n\" \"${0}\"\r\n   exit 1\r\nfi\r\n\r\n# Install required packages\r\napt-get update &amp;&amp; apt-get -y install openvpn iptables-persistent\r\n\r\n# Create config\r\ncd \/etc\/openvpn\r\nwget $server -O config.zip\r\nunzip config.zip\r\nrm config.zip\r\nshopt -s nullglob\r\nfor f in *.ovpn\r\ndo\r\n    sed -i 's\/^auth-user-pass$\/auth-user-pass user_pass.txt\/' $f\r\n    echo 'script-security 2' &gt;&gt; $f\r\n    echo 'up update-resolv-conf' &gt;&gt; $f\r\n    echo 'down update-resolv-conf' &gt;&gt; $f\r\n    rename 's\/.ovpn\/.conf\/' $f\r\ndone\r\ncat &gt; user_pass.txt &lt;&lt;EOF\r\n$username\r\n$password\r\nEOF\r\n\r\n# Reconfigure interfaces\r\ncat &gt; \/etc\/network\/interfaces &lt;&lt;EOF\r\nauto lo\r\niface lo inet loopback\r\n\r\nauto eth0\r\niface eth0 inet static\r\naddress $raspi_client_ip\r\ngateway $raspi_client_gw\r\nnetmask $raspi_client_nm\r\n\r\nauto eth0:0\r\niface eth0:0 inet static\r\naddress $raspi_gateway_ip\r\nEOF\r\n\r\n# Setup IPTables\r\niptables -A FORWARD -s $raspi_client_nw\/$raspi_client_nm -i eth0:0 -o eth0 -m conntrack --ctstate NEW -j REJECT\r\niptables -A FORWARD -s $raspi_client_nw\/$raspi_client_nm -i eth0:0 -o tun0 -m conntrack --ctstate NEW -j ACCEPT\r\niptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE\r\niptables-save &gt; \/etc\/iptables\/rules.v4\r\n\r\n# Enable IP forwarding\r\ncp \/etc\/sysctl.conf \/etc\/sysctl.conf.old\r\nsed -i 's\/.*net\\.ipv4\\.ip_forward=.*\/net\\.ipv4\\.ip_forward=1\/' \/etc\/sysctl.conf<\/pre>\n<hr \/>\n<p style=\"text-align: justify;\">Ich habe dieses nun seit Januar im Einsatz und es funktioniert einwandfrei!<\/p>\n<p style=\"text-align: justify;\">Hoffe das es bei euch auch so gut funktioniert, bei mir funz das alles!<\/p>\n<p style=\"text-align: center;\"><strong style=\"color: #666666;\"><span style=\"color: #ff0000;\">Hier nochmal der Warnhinweis ich nehme keinerlei Verantwortung f\u00fcr meine Tipps &amp; Tricks!!! alles was hier pr\u00e4sentiert\u00a0wird habe ich aktuell Produktiv und keinerlei Probleme feststellen k\u00f6nnen. Jeder ist trotzdem dazu verpflichtet alles sorgf\u00e4ltig\u00a0zu testen.<\/span><\/strong><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Ich habe in Januar ein Raspberry Pi Version B gekauft (f\u00fcr ca. 50\u20ac) Den RPI wollte ich eigentlich f\u00fcr meinen alten Fernseher einsetzten damit ich Filme\/Fotos\/Musik von meinen\u00a0NAS sehen kann. Leider ist das RPI sehr cool f\u00fcr solche Sachen aber leider nicht damit man sich irgendeinen stream anschaut (leider zu wenig RAM) aber weil ich<\/p><\/div>\n<div class=\"blog-btn\"><a href=\"https:\/\/gentz.cloud\/?p=112\" class=\"home-blog-btn\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-112","post","type-post","status-publish","format-standard","hentry","category-tips-ricks"],"_links":{"self":[{"href":"https:\/\/gentz.cloud\/index.php?rest_route=\/wp\/v2\/posts\/112","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gentz.cloud\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gentz.cloud\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gentz.cloud\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gentz.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=112"}],"version-history":[{"count":0,"href":"https:\/\/gentz.cloud\/index.php?rest_route=\/wp\/v2\/posts\/112\/revisions"}],"wp:attachment":[{"href":"https:\/\/gentz.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=112"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gentz.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=112"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gentz.cloud\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=112"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}