<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:content="http://purl.org/rss/1.0/modules/content/">
  <channel>
    <title>Vpn – Yeri Tiete</title>
    <link>https://yeri.be/tag/vpn/</link>
    <description>Yeri Tiete&#39;s blog</description>
    <language>en</language>
    <copyright>© Yeri Tiete</copyright>
    <lastBuildDate>Mon, 03 Jul 2023 15:48:30 +0200</lastBuildDate>
    <atom:link href="https://yeri.be/tag/vpn/index.xml" rel="self" type="application/rss+xml" />
    
    <item>
      <title>killwarp</title>
      <link>https://yeri.be/killwarp/</link>
      <pubDate>Mon, 03 Jul 2023 15:48:30 +0200</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/killwarp/</guid>
      <description>&lt;p&gt;Is your company forcing &lt;a href=&#34;https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/download-warp/&#34; target=&#34;_blank&#34; rel=&#34;noreferrer noopener&#34;&gt;Cloudflare Warp&lt;/a&gt; on you, and are you running on a Mac (with &lt;code&gt;sudo&lt;/code&gt; access)?&lt;/p&gt;&#xA;&lt;p&gt;It probably sucks, spies on you, does MitM attacks, breaks most video conferencing tools, and is generally not very stable... Also... Zero trust!&lt;/p&gt;&#xA;&lt;p&gt;Add this function to your &lt;code&gt;.bashrc&lt;/code&gt; or &lt;code&gt;.zshrc&lt;/code&gt; (whichever shell you&#39;re using*):&lt;/p&gt;&#xA;&lt;pre class=&#34;wp-block-code&#34;&gt;&lt;code&gt;func killwarp() {&#xA;&#x9;sudo launchctl remove com.cloudflare.1dot1dot1dot1.macos.warp.daemon&#xA;&#x9;sudo killall Cloudflare\ WARP&#xA;}&lt;/code&gt;&lt;/pre&gt;&#xA;&lt;p&gt;Open a new shell window (to reload your dot files), and type &lt;code&gt;killwarp&lt;/code&gt;.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>Is your company forcing <a href="https://developers.cloudflare.com/cloudflare-one/connections/connect-devices/warp/download-warp/" target="_blank" rel="noreferrer noopener">Cloudflare Warp</a> on you, and are you running on a Mac (with <code>sudo</code> access)?</p>
<p>It probably sucks, spies on you, does MitM attacks, breaks most video conferencing tools, and is generally not very stable... Also... Zero trust!</p>
<p>Add this function to your <code>.bashrc</code> or <code>.zshrc</code> (whichever shell you're using*):</p>
<pre class="wp-block-code"><code>func killwarp() {
	sudo launchctl remove com.cloudflare.1dot1dot1dot1.macos.warp.daemon
	sudo killall Cloudflare\ WARP
}</code></pre>
<p>Open a new shell window (to reload your dot files), and type <code>killwarp</code>.</p>
<p>This will permanently disable Warp (until your Mac is rebooted; as it's most likely force installed/started by your admin). So just run this after every reboot. </p>
<p>(*) Find out with <code>echo $SHELL</code>. </p>
]]></content:encoded>
      <category>apple</category><category>networking</category><category>software</category>
      <category>cloudflare</category><category>vpn</category>
    </item>
    
    <item>
      <title>Remote desktop and Wake-on-LAN</title>
      <link>https://yeri.be/remote-desktop-and-wake-on-lan/</link>
      <pubDate>Sat, 09 Jul 2022 23:14:54 +0200</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/remote-desktop-and-wake-on-lan/</guid>
      <description>&lt;p&gt;&lt;a href=&#34;http://shanwong.com&#34; target=&#34;_blank&#34; rel=&#34;noreferrer noopener&#34;&gt;Shan&lt;/a&gt; uses her iPad a lot, but a lot of the more serious (interior design) work needs to happen on &lt;a href=&#34;https://yeri.be/screen-going-black-with-autocad-lt&#34;&gt;AutoCAD&lt;/a&gt; or Photoshop. That is just not going to work on an iPad. &lt;/p&gt;&#xA;&lt;p&gt;When we&#39;re travelling (read: holiday) she&#39;s carrying an old Lenovo &lt;a href=&#34;https://www.lenovo.com/gb/en/laptops/thinkpad/13-series/ThinkPad-13-Windows-2nd-Gen/p/22TP2TX133E&#34; target=&#34;_blank&#34; rel=&#34;noreferrer noopener&#34;&gt;ThinkPad 13&lt;/a&gt; (great device!) just &#34;in case&#34; she needs to open AutoCAD and edit something minor or read the drawings/dimensions. But honestly, most of the time that device is turned off and dead weight.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p><a href="http://shanwong.com" target="_blank" rel="noreferrer noopener">Shan</a> uses her iPad a lot, but a lot of the more serious (interior design) work needs to happen on <a href="https://yeri.be/screen-going-black-with-autocad-lt">AutoCAD</a> or Photoshop. That is just not going to work on an iPad. </p>
<p>When we're travelling (read: holiday) she's carrying an old Lenovo <a href="https://www.lenovo.com/gb/en/laptops/thinkpad/13-series/ThinkPad-13-Windows-2nd-Gen/p/22TP2TX133E" target="_blank" rel="noreferrer noopener">ThinkPad 13</a> (great device!) just "in case" she needs to open AutoCAD and edit something minor or read the drawings/dimensions. But honestly, most of the time that device is turned off and dead weight.</p>
<p>But all the above is just an excuse to "I was bored, and I wanted to test something": can I use an old Raspberry Pi (<a href="https://www.raspberrypi.com/products/raspberry-pi-zero-w/" target="_blank" rel="noreferrer noopener">zero W</a>) to remotely wake her Intel NUC, and then use <a href="http://tailscale.com/" target="_blank" rel="noreferrer noopener">Tailscale</a> to use RD on her iPad? Well, yes I can. </p>
<p>I completed this using:</p>
<ul><li>Tailscale to remote desktop from anywhere to home</li><li>Cloudflare Tunnels, Access and DNS to have a web interface to wake the desktop</li><li>A Linux device that's always on and in the same LAN, and that'll run a PHP script. </li></ul>
<h2>Prep work: enable WOL</h2>
<p>First off: enable Wake-on-LAN (WOL) in the BIOS <em>and </em>in your Windows settings. <a href="https://www.intel.com/content/www/us/en/support/articles/000027615/intel-nuc.html" target="_blank" rel="noreferrer noopener">This article explains</a> it for Intel NUCs, but would be similar enough for most devices. The Device Manager pane looked different on our i5 NUC, but was close enough. </p>
<p>On Mac, you just need to enable it in the Energy preference pane, for Linux I have no clue. 🤷‍♂️</p>
<p>Second step: have a working Raspberry Pi (or any Linux device) in <em>the same LAN</em>. This device needs to be turned on 24/7, so use something that uses very little power. </p>
<pre class="wp-block-verse">I do have a more powerful <a href="https://yeri.be/making-bluetooth-work-on-rpi4">RPi4</a> I wish I could've reused (running <a href="https://yeri.be/running-wireguard-in-a-docker-container-rpi">Docker</a> and some other "serious" stuff; however it's currently in a different VLAN, and it's quite crucial the Linux device is in the same LAN as the device(s) you want to wake up), so I went with an old Raspberry Pi Zero W that was collecting dust (it used to run <a href="https://pwnagotchi.ai/" target="_blank" rel="noreferrer noopener">pwnagotchi</a>).</pre>
<p>On the Linux device, install <a href="https://www.mkssoftware.com/docs/man1/etherwake.1.asp" target="_blank" rel="noreferrer noopener">etherwake</a>. The command to run is quite simply <code>etherwake aa:bb:cc:11:22:33</code> (= the ethernet MAC address of your device).</p>
<p>If this doesn't wake your desktop, something is wrong and there's no point continuing. Go and troubleshoot. </p>
<h2>Install Tailscale and RD</h2>
<p>On the (<a href="https://www.youtube.com/watch?v=lKQroybFqg4" target="_blank" rel="noreferrer noopener">Windows</a>) desktop and your iPad, install <a href="https://tailscale.com/download" target="_blank" rel="noreferrer noopener">Tailscale</a>. Login, and make sure it works by pinging from one to the other. </p>
<p>Then set up Remote Desktop on both (<a href="https://support.microsoft.com/en-us/windows/how-to-use-remote-desktop-5fe128d5-8fb1-7a23-3b8a-41e636865e8c#ID0EDD=Windows_10" target="_blank" rel="noreferrer noopener">Windows</a>, <a href="https://apps.apple.com/us/app/remote-desktop-mobile/id714464092" target="_blank" rel="noreferrer noopener">iPad</a>). You should test and make sure you can properly connect using the LAN IP address and then the Tailscale IP address.</p>
<pre class="wp-block-verse">Fun fact: I create a DNS record for all my devices using <a href="https://developers.cloudflare.com/dns/manage-dns-records/how-to/create-dns-records/" target="_blank" rel="noreferrer noopener">Cloudflare DNS</a> with the syntax of <a href="https://smokeping-sg.superuser.one/smokeping/?target=yeri.TSwol" target="_blank" rel="noreferrer noopener">device-name.ts.yeri.be</a>, so I don't need to ever remember IPs, and can easily <code>ssh</code> or <code>ping</code> devices without having to look up IPs. </pre>
<figure class="wp-block-image size-large is-resized"><img src="https://static.yeri.be/2022/07/cf-dns-ts-1024x461.png" alt="" class="wp-image-70039" width="610" height="274"/><figcaption>Cloudflare DNS screenshot, filtered on "ts". I add both <code>A</code> and <code>AAAA</code> records (not shown in the screenshot) </figcaption></figure>
<pre class="wp-block-verse">Fun fact side track: I actually have a dynamic script that runs (on Linux) and creates <code>hostname.ts.yeri.be</code> for the Tailscale IP, <code>hostname.wg.yeri.be</code> based on the <a href="https://yeri.be/wireguard" target="_blank" rel="noreferrer noopener">Wireguard</a> IP, <code>hostname.lan.yeri.be</code> based on the LAN IP. This dyndns script runs every so often and updates IPs if needed. All this is running using <a href="https://github.com/tech-otaku/cloudflare-dns" target="_blank" rel="noreferrer noopener">Cloudflare DNS and their API</a>. Super convenient.</pre>
<h2>Nginx, php and etherwake</h2>
<pre class="wp-block-verse">I'm a 80s kid, so I'll use dirty PHP to run this script. I'm sure I'll go straight to hell for this, but yolo.</pre>
<p>Install <a href="https://www.digitalocean.com/community/tutorials/how-to-install-linux-nginx-mysql-php-lemp-stack-ubuntu-18-04" target="_blank" rel="noreferrer noopener">nginx and PHP</a> (no need for MySQL and other stuff).</p>
<p><code>etherwake</code> requires root to run (because it needs root access to create a weird <a href="https://en.wikipedia.org/wiki/Wake-on-LAN#Magic_packet" target="_blank" rel="noreferrer noopener">magic</a> ethernet packet). Create a file in <code>/etc/sudoers.d/etherwake</code> and add this line:</p>
<pre class="wp-block-code"><code>www-data ALL=(ALL) NOPASSWD: /usr/sbin/etherwake</code></pre>
<p>This will allow <code>www-data</code> (nginx/php) to run <code>/usr/sbin/etherwake</code> using <code>sudo</code>, without password.</p>
<p>In <code>/var/www/html/</code> create an <code>index.php</code> file with:</p>
<pre class="wp-block-code"><code>&lt;html&gt;
&lt;head&gt;&lt;title&gt;Wake on Lan&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;
&lt;p&gt;Wake up &lt;a href="mycooldesktop.php"&gt;My Cool Desktop&lt;/a&gt;
&lt;/body&gt;
&lt;/html&gt;</code></pre>
<p>And a <code>mycooldesktop.php</code> (or whatever) file with:</p>
<pre class="wp-block-code"><code>&lt;?php
$output = shell_exec('sudo /usr/sbin/etherwake aa:bb:cc:11:22:33 2&gt;&amp;1');
echo "&lt;pre&gt;$output&lt;/pre&gt;";
?&gt;
&lt;p&gt;&lt;a href=".."&gt;Back&lt;/a&gt;&lt;/p&gt;</code></pre>
<pre class="wp-block-verse">It ain't pretty -- but it gets the job done. </pre>
<p>And be sure to edit the MAC address to match your desktop's ethernet MAC address. </p>
<h2>Cloudflare tunnels</h2>
<p>Install Cloudflare Tunnel (via <a href="https://dash.teams.cloudflare.com" target="_blank" rel="noreferrer noopener">Zero Trust</a> dashboard). </p>
<p>When creating a new tunnel, the dashboard will give you all needed commands to install the tunnel on your RPi -- but be sure to select the right OS/architecture (arm64? arm? armhf?). </p>
<figure class="wp-block-image size-large"><img src="https://static.yeri.be/2022/07/cf-tunnel-1024x448.png" alt="" class="wp-image-70047"/><figcaption>Easy.</figcaption></figure>
<p>And then point the tunnel to <code>http://localhost</code>. No need to mess around with <a href="https://yeri.be/tag/ssl">SSL</a> certs.</p>
<p>Lastly, set up Cloudflare Access (via the same Zero Trust dashboard): create a new application, and make sure only approved users can sign in (i.e.: using a pin code emailed to only approved emails). </p>
<figure class="wp-block-image size-large"><img src="https://static.yeri.be/2022/07/cf-access-1024x796.png" alt="" class="wp-image-70048"/><figcaption>I only allow access to my own emails, and my family, by using groups.</figcaption></figure>
<p>You can try it yourself via <a href="https://wol.superuser.one/" target="_blank" rel="noreferrer noopener">wol.superuser.one</a>. You won't get in. :)</p>
<pre class="wp-block-verse">Optionally, but recommended: lock down Nginx to only allow connections from localhost (<code>127.0.0.0/8</code> and <code>::1</code>) if using Cloudflare Tunnels, or <a href="https://www.frankindev.com/2020/11/18/allow-cloudflare-only-in-nginx/" target="_blank" rel="noreferrer noopener">Cloudflare IPs</a> if using port forwarding with <a href="https://www.cloudflare.com/en-gb/products/zero-trust/access/" target="_blank" rel="noreferrer noopener">Cloudflare Access</a> in front. </pre>
<figure class="wp-block-image size-large is-resized"><img src="https://static.yeri.be/2022/07/wol-interface-1024x540.png" alt="" class="wp-image-70042" width="610" height="321"/><figcaption>Love my design skills... But it gets the job done: click that link, and it'll execute <code>etherwake</code>.</figcaption></figure>
<h2>To recap</h2>
<ul><li>We used Tailscale to create a VPN network between the desktop and the iPad. The big benefit is that Tailscale works effortlessly across NAT networks without having to open ports,</li><li>We used Cloudflare DNS so we don't need to remember hostnames :),</li><li>We used Cloudflare Tunnels to make sure the RPi web interface is accessible across NAT (without port forwarding) and from anywhere, </li><li>We used Cloudflare Acces and locked down access to the right people using ACLs,</li><li>We used <code>etherwake</code> running on a RPi to wake up devices that are hibernating or turned off.</li></ul>
<p>And that's it really.</p>
<pre class="wp-block-verse">PS: technically WoL works with WiFi, but when I enabled WoL on the WiFi adapter, the NUC refused to hibernate/sleep for more than a minute, and kept waking itself up. So, there seems to be some kind of trigger in my network that keeps waking it up. Also, not sure if WoL via WiFi would work if the device is turned off (as opposed to sleep or hibernate). I just ended up using ethernet. 

PPS: both Cloudflare Tunnels and Tailscale use <a href="https://www.wireguard.com/" target="_blank" rel="noreferrer noopener">Wireguard</a> tech in the background, so that's really cool. </pre>
]]></content:encoded>
      <category>apple</category><category>hardware</category><category>linux</category><category>misc</category><category>networking</category><category>software</category><category>windows</category><category>www</category>
      <category>windows</category><category>cloudflare</category><category>tailscale</category><category>vpn</category>
    </item>
    
    <item>
      <title>WireGuard</title>
      <link>https://yeri.be/wireguard/</link>
      <pubDate>Mon, 27 Apr 2020 20:34:00 +0200</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/wireguard/</guid>
      <description>&lt;p&gt;This is the first post of &lt;a href=&#34;https://yeri.be/tag/wireguard&#34; target=&#34;_blank&#34; aria-label=&#34; (opens in a new tab)&#34; rel=&#34;noreferrer noopener&#34; class=&#34;aioseop-link&#34;&gt;several&lt;/a&gt;. Next posts will focus on running WireGuard inside a Docker container on &lt;a href=&#34;https://yeri.be/running-wireguard-in-a-docker-container-(amd64)&#34; target=&#34;_blank&#34; aria-label=&#34;amd64 Linux (opens in a new tab)&#34; rel=&#34;noreferrer noopener&#34; class=&#34;aioseop-link&#34;&gt;amd64 Linux&lt;/a&gt; and a &lt;a href=&#34;https://yeri.be/running-wireguard-in-a-docker-container-rpi&#34; target=&#34;_blank&#34; aria-label=&#34;Raspberry Pi (opens in a new tab)&#34; rel=&#34;noreferrer noopener&#34; class=&#34;aioseop-link&#34;&gt;Raspberry Pi&lt;/a&gt;. &lt;/p&gt;&#xA;&lt;p&gt;I&#39;ve been running &lt;a aria-label=&#34;Wireguard (opens in a new tab)&#34; href=&#34;https://www.wireguard.com/&#34; target=&#34;_blank&#34; rel=&#34;noreferrer noopener&#34; class=&#34;aioseop-link&#34;&gt;WireGuard&lt;/a&gt; for a few months now and I&#39;ve been loving it. &lt;/p&gt;&#xA;&lt;p&gt;I first started using it about a year ago when in &lt;a aria-label=&#34;China (opens in a new tab)&#34; rel=&#34;noreferrer noopener&#34; class=&#34;aioseop-link&#34; href=&#34;https://yeri.be/tag/china&#34; target=&#34;_blank&#34;&gt;China&lt;/a&gt; — OpenVPN was once again being actively blocked and it was driving me nuts. Overnight I set up a &lt;a aria-label=&#34;DigitalOcean (opens in a new tab)&#34; rel=&#34;noreferrer noopener&#34; class=&#34;aioseop-link&#34; href=&#34;https://m.do.co/c/3276c58fdbfd&#34; target=&#34;_blank&#34;&gt;DigitalOcean&lt;/a&gt; server in Singapore and ran WireGuard from it — both my phone and laptop were able to actively bypass the &lt;a aria-label=&#34;GFW (opens in a new tab)&#34; rel=&#34;noreferrer noopener&#34; class=&#34;aioseop-link&#34; href=&#34;https://yeri.be/tag/gfw&#34; target=&#34;_blank&#34;&gt;GFW&lt;/a&gt; and (at that time) surf the internet freely once more. As WireGuard gains popularity, I am sure the GFW will start detecting it — it&#39;s a quiet but not a stealthy &lt;a aria-label=&#34;protocol (opens in a new tab)&#34; rel=&#34;noreferrer noopener&#34; class=&#34;aioseop-link&#34; href=&#34;https://www.wireguard.com/protocol/&#34; target=&#34;_blank&#34;&gt;protocol&lt;/a&gt;. &lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>This is the first post of <a href="https://yeri.be/tag/wireguard" target="_blank" aria-label=" (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link">several</a>. Next posts will focus on running WireGuard inside a Docker container on <a href="https://yeri.be/running-wireguard-in-a-docker-container-(amd64)" target="_blank" aria-label="amd64 Linux (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link">amd64 Linux</a> and a <a href="https://yeri.be/running-wireguard-in-a-docker-container-rpi" target="_blank" aria-label="Raspberry Pi (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link">Raspberry Pi</a>. </p>
<p>I've been running <a aria-label="Wireguard (opens in a new tab)" href="https://www.wireguard.com/" target="_blank" rel="noreferrer noopener" class="aioseop-link">WireGuard</a> for a few months now and I've been loving it. </p>
<p>I first started using it about a year ago when in <a aria-label="China (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link" href="https://yeri.be/tag/china" target="_blank">China</a> — OpenVPN was once again being actively blocked and it was driving me nuts. Overnight I set up a <a aria-label="DigitalOcean (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link" href="https://m.do.co/c/3276c58fdbfd" target="_blank">DigitalOcean</a> server in Singapore and ran WireGuard from it — both my phone and laptop were able to actively bypass the <a aria-label="GFW (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link" href="https://yeri.be/tag/gfw" target="_blank">GFW</a> and (at that time) surf the internet freely once more. As WireGuard gains popularity, I am sure the GFW will start detecting it — it's a quiet but not a stealthy <a aria-label="protocol (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link" href="https://www.wireguard.com/protocol/" target="_blank">protocol</a>. </p>
<p>Since then I've dug quite a bit deeper in WireGuard and am really looking forward to what it's going to bring. </p>
<p>WireGuard differentiates itself to be an extremely simple VPN server (which can make getting started and debugging a bit more challenging) — but it wants to seamlessly work together with existing tools. One of the main features still missing is for example running a DHCP server on the server and dynamically assigning IPs (like oVPN does). </p>
<figure class="wp-block-image size-large"><a href="https://static.yeri.be/2020/04/WireGuard-network.png" target="_blank" rel="noopener noreferrer"><img src="https://static.yeri.be/2020/04/WireGuard-network.png" alt="WireGuard network" class="wp-image-8750"/></a><figcaption>Simplified diagram of my network. Using static routing my clients can access the WireGuard network even without running WireGuard directly. (Some of) my containers are also able to access the network, this allows me to run Resilio Sync over WireGuard. It's using one big subnet to create one big LAN. </figcaption></figure>
<p>It's also pretty cool because any node can both be a server and a client at the same time. In my setup I am running two servers: one running at home in Singapore on a RPi4 (1Gbit fiber connection) and one on a virtual machine in <a aria-label="Amsterdam (opens in a new tab)" href="https://yeri.be/tag/rootspirit/" target="_blank" rel="noreferrer noopener" class="aioseop-link">Amsterdam</a> (1Gbit as well). The RPis at my parents are connected to the server in Amsterdam, my iPad and phones are connected to the server in Singapore. If I am in Europe I might switch over and let my iDevices connect to the AMS server instead. </p>
<figure class="wp-block-image size-large"><a href="https://static.yeri.be/2020/04/WireGuard-and-traffic-shaping.png" target="_blank" rel="noopener noreferrer"><img src="https://static.yeri.be/2020/04/WireGuard-and-traffic-shaping-1024x150.png" alt="WireGuard and traffic shaping" class="wp-image-8751"/></a><figcaption>Click to enlarge. <br />Bandwidth stats from Resilio Sync, transferring several big files. We can clearly see a speed increase (from 2-5mb/s to 11mb/s) when routing the exact same traffic over WireGuard. <a aria-label="Traffic shaping (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link" href="https://en.wikipedia.org/wiki/Traffic_shaping" target="_blank">Traffic shaping</a> at its best.</figcaption></figure>
<p>The example above clearly shows speed gains by cloaking the traffic in UDP packets. The shared folder has only two nodes (sender and receiver) and shows several big files being transferred from Amsterdam to Singapore. <a aria-label="Resilio Sync (opens in a new tab)" href="https://www.resilio.com/individuals/" target="_blank" rel="noreferrer noopener" class="aioseop-link">Resilio Sync</a> uses the <a aria-label="Bittorrent protocol (opens in a new tab)" href="https://en.wikipedia.org/wiki/Resilio_Sync#Technology" target="_blank" rel="noreferrer noopener" class="aioseop-link">Bittorrent protocol</a>, something ISPs generally hate and tend to slow down as much as they can — thanks Starhub. </p>
<p>Wireguard also allows the client to decide what to route through the server: only the VPN LAN traffic, or a whole subnet, or 0.0.0.0/0? So for my iPhone I for example route all traffic through VPN to avoid hotel/airport/... WiFi's to mine/log/scan my data. For my laptop I have two configs, one to only connect to the LAN, but another that routes all my traffic through the VPN if I want to avoid exposure or circumvent censoring. </p>
<p>Note that I am not running WireGuard to remain anonymous and I'll definitely leak some information — just trying to minimise and remain in control of what I leak. This is not a <a aria-label="Tor (opens in a new tab)" rel="noreferrer noopener" href="https://www.torproject.org/" target="_blank" class="aioseop-link">Tor</a> replacement. </p>
]]></content:encoded>
      <category>linux</category><category>networking</category><category>software</category>
      <category>debian</category><category>docker</category><category>raspberrypi</category><category>vpn</category><category>wireguard</category>
    </item>
    
    <item>
      <title>Box — Docker shell server</title>
      <link>https://yeri.be/box-docker-shell-server/</link>
      <pubDate>Fri, 24 Apr 2020 10:27:00 +0200</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/box-docker-shell-server/</guid>
      <description>&lt;p&gt;A couple of months ago I had the great idea to set up a shell server in Docker. Simply because my docker skillz were quite rusty and a shell server was something I actually genuinely needed. &lt;/p&gt;&#xA;&lt;p&gt;Shell servers... so 2005. I remember in the good old IRC days people asking for (free) shell servers to run their &lt;a aria-label=&#34;eggdrop (opens in a new tab)&#34; href=&#34;https://eggheads.org/&#34; target=&#34;_blank&#34; rel=&#34;noreferrer noopener&#34; class=&#34;aioseop-link&#34;&gt;eggdrop&lt;/a&gt; and stuff. OMG am I getting old? Anyhow... &lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>A couple of months ago I had the great idea to set up a shell server in Docker. Simply because my docker skillz were quite rusty and a shell server was something I actually genuinely needed. </p>
<p>Shell servers... so 2005. I remember in the good old IRC days people asking for (free) shell servers to run their <a aria-label="eggdrop (opens in a new tab)" href="https://eggheads.org/" target="_blank" rel="noreferrer noopener" class="aioseop-link">eggdrop</a> and stuff. OMG am I getting old? Anyhow... </p>
<p>I ssh quite often. I manage quite a few <a href="https://yeri.be/tag/rootspirit" target="_blank" aria-label="servers (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link">servers</a> (~15?) and <a href="https://yeri.be/?s=edgerouter" target="_blank" aria-label="routers (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link">routers</a> that require me to login and do some random stuff. I also work on a laptop quite often and that means closing the lid and moving around. </p>
<p>First of all, <a aria-label=" (opens in a new tab)" href="https://mosh.org/" target="_blank" rel="noreferrer noopener" class="aioseop-link">mosh</a> is amazing and allows you to stay connected via ssh, even with crappy (airport/hotel) internet as well as moving around networks -- that solves half the problem. If you are not using it, start using it now!</p>
<p>Second, during my <a aria-label="datacenter technician (opens in a new tab)" href="https://www.google.com/about/datacenters/" target="_blank" rel="noreferrer noopener" class="aioseop-link">datacenter technician</a> days at Google we used to have a "jump server" -- a shell server that allowed us to bridge the corporate network and ssh into prod machines. Doubt that's still used nowadays, but the idea stuck. I wanted something similar to ssh from, wherever I was, and easily connect to my servers. And as the network the shell server is running on is stable, I only need to use mosh to the shell server. Thereafter, the connection very rarely dies. </p>
<p>And I guess, third, I recently purchased an iPad Pro and I really need to have my local "dev" environment with my git repo that I edit quite frequently but iPadOS isn't really your average computer, and doesn't even have a proper terminal. This is my experiment to make iPadOS work as a main computer when on the move. </p>
<p>Enter box -- <a href="https://gitlab.com/yeri/box-public" target="_blank" aria-label="Docker shell server (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link">Docker shell server</a>... <a href="https://gitlab.com/yeri/box-public" class="aioseop-link"></a></p>
<p>I've copied over the files I use to this <a aria-label="example repo (opens in a new tab)" href="https://gitlab.com/yeri/box-public" target="_blank" rel="noreferrer noopener" class="aioseop-link">example repo</a>, and added some comments. Mind you that this repo acts as a proof of concept and isn't kept up to date, as I have my own private repo -- but this should give you a good idea on how to set up your own shell server with Docker. </p>
<p><a aria-label=" (opens in a new tab)" href="https://gitlab.com/yeri/box-public/-/blob/master/start.sh" target="_blank" rel="noreferrer noopener" class="aioseop-link">start.sh</a> -- this is a simple script that I execute when I first run or need to update the container. I execute the same file on two different servers: <a label="Liana (opens in a new tab)" href="http://smokeping-sg.superuser.one/" target="_blank" rel="noreferrer noopener" class="aioseop-link">Liana</a>, my Raspberry Pi at home and <a aria-label="Ocean (opens in a new tab)" href="http://smokeping.rootspirit.com/" target="_blank" rel="noreferrer noopener" class="aioseop-link">Ocean</a>, my server in <a aria-label="Amsterdam (opens in a new tab)" href="https://yeri.be/tag/rootspirit" target="_blank" rel="noreferrer noopener" class="aioseop-link">Amsterdam</a>. </p>
<p><a href="https://gitlab.com/yeri/box-public/-/blob/master/zsh.sh" target="_blank" aria-label=" (opens in a new tab)" rel="noreferrer noopener" class="aioseop-link">zsh.sh</a> -- this installs what I care about for zsh. This could be part of the Dockerfile but for some reason I separated it. ¯\_(ツ)_/¯ </p>
<p><a aria-label=" (opens in a new tab)" href="https://gitlab.com/yeri/box-public/-/blob/master/git.sh" target="_blank" rel="noreferrer noopener" class="aioseop-link">git.sh</a> -- this clones my Git repos so I can edit and commit stuff from the shell server. </p>
<p><a aria-label="run.sh (opens in a new tab)" href="https://gitlab.com/yeri/box-public/-/blob/master/run.sh" target="_blank" rel="noreferrer noopener" class="aioseop-link">run.sh</a> -- this file is launched by Dockerfile at the end and executes what matters: the ssh daemon. It also adds a <a aria-label="Wireguard (opens in a new tab)" href="https://yeri.be/tag/wireguard" target="_blank" rel="noreferrer noopener" class="aioseop-link">Wireguard</a> route and executes the scripts above. </p>
<p><a aria-label=" (opens in a new tab)" href="https://gitlab.com/yeri/box-public/-/blob/master/Dockerfile" target="_blank" rel="noreferrer noopener" class="aioseop-link">Dockerfile</a> -- this installs everything I need and configures the whole thing. I've added tons of comments that should get you going. </p>
<p>I am also cloning <a aria-label="misc (opens in a new tab)" href="https://gitlab.com/yeri/homefiles/" target="_blank" rel="noreferrer noopener" class="aioseop-link">misc</a> and <a aria-label="homefiles (opens in a new tab)" href="https://gitlab.com/yeri/homefiles/" target="_blank" rel="noreferrer noopener" class="aioseop-link">homefiles</a> as submodules in <a aria-label="files/ (opens in a new tab)" href="https://gitlab.com/yeri/box-public/-/tree/master/files" target="_blank" rel="noreferrer noopener" class="aioseop-link">files/</a> -- but you should change this to something that works for you. See the Dockerfile for more info. </p>
]]></content:encoded>
      <category>apple</category><category>linux</category><category>networking</category><category>software</category><category>virtualisation</category>
      <category>debian</category><category>docker</category><category>raspberrypi</category><category>rootspirit</category><category>vpn</category><category>wireguard</category>
    </item>
    
    <item>
      <title>Edgerouter IPsec tunnel to Fritzbox</title>
      <link>https://yeri.be/edgerouter-fritzbox-ipsec/</link>
      <pubDate>Wed, 08 Feb 2017 21:18:10 +0100</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/edgerouter-fritzbox-ipsec/</guid>
      <description>&lt;p&gt;So, I have an EdgeRouter Lite in Singapore (Starhub) and a FritzBox in Belgium (EDPnet).&lt;/p&gt;&#xA;&lt;p&gt;This is mostly stuff that I have found from several articles, mostly from &lt;a href=&#34;https://community.ubnt.com/t5/EdgeMAX/HOW-TO-IPSec-Site-to-Site-VPN-with-both-dynamic-IPs-between/m-p/1548055#U1548055&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;ERL: eth0 is WAN, eth1 (10.60.111.0/24) and eth2 (unused, not VPN&amp;rsquo;ed) are LAN&#xA;FritzBoz: 192.168.1.0/24&lt;/p&gt;&#xA;&lt;p&gt;This is the FritzBox config (go to VPN and them Import a config) &lt;code&gt;fritzvpn.cfg&lt;/code&gt;:&lt;/p&gt;&#xA;&lt;pre&gt;vpncfg {&#xA;        connections {&#xA;                enabled = yes;&#xA;                conn_type = conntype_lan;&#xA;                name = &#34;VPN Yeri&#34;;&#xA;                always_renew = yes;&#xA;                reject_not_encrypted = no;&#xA;                dont_filter_netbios = yes;&#xA;                localip = 0.0.0.0;&#xA;                local_virtualip = 0.0.0.0;&#xA;                remoteip = 0.0.0.0;&#xA;                remote_virtualip = 0.0.0.0;&#xA;                remotehostname = &#34;erl.yeri.be&#34;;&#xA;                localid {&#xA;                        fqdn = &#34;fritz.yeri.be&#34;;&#xA;                }&#xA;                remoteid {&#xA;                        fqdn = &#34;erl.yeri.be&#34;;&#xA;                }&#xA;                mode = phase1_mode_idp;&#xA;                phase1ss = &#34;all/all/all&#34;;&#xA;                keytype = connkeytype_pre_shared;&#xA;                key = &#34;SOMEPASSWORD&#34;;&#xA;                cert_do_server_auth = no;&#xA;                use_nat_t = yes;&#xA;                use_xauth = no;&#xA;                use_cfgmode = no;&#xA;                phase2localid {&#xA;                        ipnet {&#xA;                                ipaddr = 192.168.1.0;&#xA;                                mask = 255.255.255.0;&#xA;                        }&#xA;                }&#xA;                phase2remoteid {&#xA;                        ipnet {&#xA;                                ipaddr = 10.60.111.0;&#xA;                                mask = 255.255.255.0;&#xA;                        }&#xA;                }&#xA;                phase2ss = &#34;esp-all-all/ah-none/comp-all/pfs&#34;;&#xA;                accesslist = &#34;permit ip any 10.60.111.0 255.255.255.0&#34;;&#xA;        }&#xA;        ike_forward_rules = &#34;udp 0.0.0.0:500 0.0.0.0:500&#34;, &#xA;                            &#34;udp 0.0.0.0:4500 0.0.0.0:4500&#34;;&#xA;}&lt;/pre&gt;&#xA;&lt;p&gt;Be sure to modify the password, local (Fritz) and remote (ERL) LAN and edit the local and remote fqdn.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>So, I have an EdgeRouter Lite in Singapore (Starhub) and a FritzBox in Belgium (EDPnet).</p>
<p>This is mostly stuff that I have found from several articles, mostly from <a href="https://community.ubnt.com/t5/EdgeMAX/HOW-TO-IPSec-Site-to-Site-VPN-with-both-dynamic-IPs-between/m-p/1548055#U1548055" target="_blank" rel="noopener">here</a>.</p>
<p>ERL: eth0 is WAN, eth1 (10.60.111.0/24) and eth2 (unused, not VPN&rsquo;ed) are LAN
FritzBoz: 192.168.1.0/24</p>
<p>This is the FritzBox config (go to VPN and them Import a config) <code>fritzvpn.cfg</code>:</p>
<pre>vpncfg {
        connections {
                enabled = yes;
                conn_type = conntype_lan;
                name = "VPN Yeri";
                always_renew = yes;
                reject_not_encrypted = no;
                dont_filter_netbios = yes;
                localip = 0.0.0.0;
                local_virtualip = 0.0.0.0;
                remoteip = 0.0.0.0;
                remote_virtualip = 0.0.0.0;
                remotehostname = "erl.yeri.be";
                localid {
                        fqdn = "fritz.yeri.be";
                }
                remoteid {
                        fqdn = "erl.yeri.be";
                }
                mode = phase1_mode_idp;
                phase1ss = "all/all/all";
                keytype = connkeytype_pre_shared;
                key = "SOMEPASSWORD";
                cert_do_server_auth = no;
                use_nat_t = yes;
                use_xauth = no;
                use_cfgmode = no;
                phase2localid {
                        ipnet {
                                ipaddr = 192.168.1.0;
                                mask = 255.255.255.0;
                        }
                }
                phase2remoteid {
                        ipnet {
                                ipaddr = 10.60.111.0;
                                mask = 255.255.255.0;
                        }
                }
                phase2ss = "esp-all-all/ah-none/comp-all/pfs";
                accesslist = "permit ip any 10.60.111.0 255.255.255.0";
        }
        ike_forward_rules = "udp 0.0.0.0:500 0.0.0.0:500", 
                            "udp 0.0.0.0:4500 0.0.0.0:4500";
}</pre>
<p>Be sure to modify the password, local (Fritz) and remote (ERL) LAN and edit the local and remote fqdn.</p>
<p>This is the ERL config (via ssh, you&rsquo;ll need to <code>set</code> this:</p>
<pre>yeri@sg-erl# show vpn ipsec 
 auto-update 60
 auto-firewall-nat-exclude enable
 esp-group FOO0 {
     proposal 1 {
         encryption aes256
         hash sha1
     }
 }
 ike-group FOO0 {
     dead-peer-detection {
         action restart
         interval 60
         timeout 60
     }
     lifetime 3600
     proposal 1 {
         dh-group 2
         encryption aes256
         hash sha1
     }
 }
 ipsec-interfaces {
     interface eth0
 }
 nat-networks {
     allowed-network 0.0.0.0/0 {
     }
 }
 nat-traversal enable
 site-to-site {
     peer fritz.yeri.be {
         authentication {
             mode pre-shared-secret
             pre-shared-secret SOMEPASSWORD
         }
         connection-type initiate
         description "VPN to fritz.yeri.be"
         ike-group FOO0
         local-address erl.yeri.be
         tunnel 1 {
             esp-group FOO0
             local {
                 prefix 10.60.111.0/24
             }
             remote {
                 prefix 192.168.1.0/24
             }
         }
     }
 }</pre>
<p>Status:</p>
<pre>yeri@sg:~$ show vpn ipsec status
IPSec Process Running PID: 20140

1 Active IPsec Tunnels

IPsec Interfaces :
        eth0    (no IP on interface statically configured as local-address for any VPN peer)
yeri@sg:~$ show vpn ipsec sa
peer-be.yeri.be-tunnel-1: #9, ESTABLISHED, IKEv1, 85a2d010ada73113:ca439c40ac3bca06
  local  'erl.yeri.be' @ 116.87.x.y
  remote 'fritz.yeri.be' @ 109.236.x.y
  AES_CBC-256/HMAC_SHA1_96/PRF_HMAC_SHA1/MODP_1024
  established 1592s ago, reauth in 1333s
  peer-fritz.yeri.be-tunnel-1: #1, INSTALLED, TUNNEL, ESP:AES_CBC-256/HMAC_SHA1_96/MODP_1024
    installed 1592 ago, rekeying in 1200s, expires in 2009s
    in  c0bb652e, 1038032 bytes, 10726 packets,     0s ago
    out 8d5df3f5, 532685 bytes,  6062 packets,     0s ago
    local  10.60.111.0/24
    remote 192.168.1.0/24</pre>
<p>I haven&rsquo;t really figured out what <code>no IP on interface statically configured as local-address for any VPN peer</code> means yet though.</p>
<p>Next up: VLANs</p>
]]></content:encoded>
      <category>hardware</category><category>linux</category><category>networking</category>
      <category>1</category><category>9</category><category>ubiquiti</category><category>vpn</category>
    </item>
    
    <item>
      <title>OpenVPN packet drops</title>
      <link>https://yeri.be/openvpn-packet-drops/</link>
      <pubDate>Mon, 08 Mar 2010 17:22:35 +0100</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/openvpn-packet-drops/</guid>
      <description>&lt;p&gt;I recently started to notice following error messages on my openVPN server.&lt;/p&gt;&#xA;&lt;address&gt;ovpn-server[6306]: vpn.rootspirit.com/85.234.x.y:62068 MULTI: packet dropped due to output saturation (multi_process_incoming_tun)&lt;/address&gt;This basically means that the TUN or TAP interface is making more packets than the real (TCP) interface can handle.&#xA;&lt;p&gt;As I need to run OpenVPN using the TCP protocol (instead of the faster UDP protocol; as UDP is often blocked in networks I use my VPN in) I experimented by increasing the tcp-queue-limit. The default is 64, and I&amp;rsquo;ve set it to 256. So far, everything still seems to be working fine (but more packets will be queued before being dropped by OpenVPN, requiring less retransmissions).&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>I recently started to notice following error messages on my openVPN server.</p>
<address>ovpn-server[6306]: vpn.rootspirit.com/85.234.x.y:62068 MULTI: packet dropped due to output saturation (multi_process_incoming_tun)</address>This basically means that the TUN or TAP interface is making more packets than the real (TCP) interface can handle.
<p>As I need to run OpenVPN using the TCP protocol (instead of the faster UDP protocol; as UDP is often blocked in networks I use my VPN in) I experimented by increasing the tcp-queue-limit. The default is 64, and I&rsquo;ve set it to 256. So far, everything still seems to be working fine (but more packets will be queued before being dropped by OpenVPN, requiring less retransmissions).</p>
<p>Add this to the OpenVPN server config:</p>
<address>tcp-queue-limit 256</address>And restart the daemon.
]]></content:encoded>
      <category>errors</category><category>linux</category><category>networking</category><category>software</category>
      <category>openvpn</category><category>vpn</category>
    </item>
    
    <item>
      <title>OpenVPN &amp; Windows 7</title>
      <link>https://yeri.be/openvpn-windows-7/</link>
      <pubDate>Sun, 14 Feb 2010 17:10:11 +0100</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/openvpn-windows-7/</guid>
      <description>&lt;p&gt;There&amp;rsquo;s a great GUI out for OpenVPN &amp;amp; Windows, located &lt;a href=&#34;http://openvpn.se/download.html&#34; target=&#34;_blank&#34; rel=&#34;noopener noreferrer&#34;&gt;here&lt;/a&gt;.&lt;/p&gt;&#xA;&lt;p&gt;However, this GUI includes an old OpenVPN, that is no longer compatible with Windows 7 and Windows Vista.&lt;/p&gt;&#xA;&lt;p&gt;The TUN/TAP driver will be blocked due to compatibility issues, and when trying to connect to a VPN, you&amp;rsquo;ll get an error along the lines of:&lt;/p&gt;&#xA;&lt;p&gt;&lt;code&gt;All TAP-Win32 adapters on this system are currently in use&lt;/code&gt;&lt;/p&gt;&#xA;&lt;p&gt;The simplest fix, is to install the GUI package (including the old OpenVPN binaries), and reinstall OpenVPN afterwards.&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>There&rsquo;s a great GUI out for OpenVPN &amp; Windows, located <a href="http://openvpn.se/download.html" target="_blank" rel="noopener noreferrer">here</a>.</p>
<p>However, this GUI includes an old OpenVPN, that is no longer compatible with Windows 7 and Windows Vista.</p>
<p>The TUN/TAP driver will be blocked due to compatibility issues, and when trying to connect to a VPN, you&rsquo;ll get an error along the lines of:</p>
<p><code>All TAP-Win32 adapters on this system are currently in use</code></p>
<p>The simplest fix, is to install the GUI package (including the old OpenVPN binaries), and reinstall OpenVPN afterwards.</p>
<p>You can find the latest OpenVPN binaries <a href="https://web.archive.org/web/20170607163358/https://openvpn.net/release/" target="_blank" rel="noopener noreferrer">here</a> and the latest version, when writing this post <a href="https://web.archive.org/web/20170607163358/https://openvpn.net/release/" target="_blank" rel="noopener noreferrer">here</a>.</p>
<p>This will overwrite the old files and update the driver with a Windows 7 compatible driver.</p>
<p>Try to connect now, everything should work like a charm. :)</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow: hidden;">http://openvpn.se/download.html</div>
]]></content:encoded>
      <category>errors</category><category>networking</category><category>software</category><category>windows</category>
      <category>openvpn</category><category>vpn</category><category>windows 7</category>
    </item>
    
    <item>
      <title>OpenVPN Linux &#43; Mac howto</title>
      <link>https://yeri.be/openvpn-linux-mac-howto/</link>
      <pubDate>Sun, 05 Jul 2009 05:14:01 +0200</pubDate>
      <author>Yeri Tiete</author>
      <guid isPermaLink="true">https://yeri.be/openvpn-linux-mac-howto/</guid>
      <description>&lt;p&gt;A short howto, as I was unable to find any clear ones on the net.&lt;/p&gt;&#xA;&lt;p style=&#34;text-align: left;&#34;&gt;I&#39;m using Mac OS X (Leopard) as client, and a &lt;a href=&#34;http://home.tiete.be&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Gentoo server&lt;/a&gt; as server/host.&lt;/p&gt;&#xA;&lt;p style=&#34;text-align: left;&#34;&gt;I both tried &lt;a href=&#34;http://www.viscosityvpn.com/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Viscosity&lt;/a&gt; and &lt;a href=&#34;https://tunnelblick.net/&#34; target=&#34;_blank&#34; rel=&#34;noopener&#34;&gt;Tunnelblick&lt;/a&gt; on my Mac as OpenVPN software, and Viscosity is probably somewhat easier to configure (using the GUI), it was shareware. So I ended up using Tunnelblick and it seems to be doing its job quite well.&lt;/p&gt;&#xA;&lt;p style=&#34;text-align: left;&#34;&gt;First of all, make sure Gentoo is set up and working as intended. I used my home router as VPN server (having both eth0 and eth1 (= ppp0).&lt;/p&gt;</description>
      <content:encoded><![CDATA[<p>A short howto, as I was unable to find any clear ones on the net.</p>
<p style="text-align: left;">I'm using Mac OS X (Leopard) as client, and a <a href="http://home.tiete.be" target="_blank" rel="noopener">Gentoo server</a> as server/host.</p>
<p style="text-align: left;">I both tried <a href="http://www.viscosityvpn.com/" target="_blank" rel="noopener">Viscosity</a> and <a href="https://tunnelblick.net/" target="_blank" rel="noopener">Tunnelblick</a> on my Mac as OpenVPN software, and Viscosity is probably somewhat easier to configure (using the GUI), it was shareware. So I ended up using Tunnelblick and it seems to be doing its job quite well.</p>
<p style="text-align: left;">First of all, make sure Gentoo is set up and working as intended. I used my home router as VPN server (having both eth0 and eth1 (= ppp0).</p>
<p style="text-align: left;">Using this <a href="http://forums.gentoo.org/viewtopic-p-5849651.html" target="_blank" rel="noopener">howto</a>, you'll be able to get the server up and running.</p>
<p style="text-align: left;">Besides the installation, and perhaps (config) file locations it should be pretty similar on other Linux distros.</p>
<p style="text-align: left;">As I have dnsmasq running on my server (taking care of DNS) I added the following to the server.conf:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">push <span class="s2">&#34;dhcp-option DNS 10.0.0.1&#34;</span>
</span></span><span class="line"><span class="cl">push <span class="s2">&#34;redirect-gateway def1&#34;</span>
</span></span><span class="line"><span class="cl">client-config-dir ccd
</span></span><span class="line"><span class="cl">route 10.20.30.0 255.255.255.252
</span></span></code></pre></div><p>Don&rsquo;t forget to allow DNS requests over tun0 interface in dnsmasq.conf.</p>
<p>The first line tells the server to hand out 10.0.0.1 as DNS server to its connecting clients (10.0.0.1 being the internal eth0 IP of my server).</p>
<p>The 2nd line, tells all clients to route ALL of their traffic through the VPN. I used the VPN to access a website that allowed only Belgian IPs, and I was in The Netherlands at the time I had to access the site (Skynet&rsquo;s Rock Werchter stream). So I connected through my server at home.</p>
<p>And the 3rd and 4th line are needed if the client access the VPN is on a private IP subnet (like being connected on a WiFi router, using IP 192.168.178.x).</p>
<p>You&rsquo;ll have to add, in the client-config directory a file per username connecting to the VPN with something similar to this:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">iroute 192.168.178.0 255.255.255.0
</span></span></code></pre></div><p>I&rsquo;m not entirely sure if you can add multiple iroutes; something I&rsquo;ll have to figure out when being on a different network.</p>
<p>This is what my client config looks like (vpn-server-name.conf, located in ~<em>/</em>Library/openvpn/):</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">client
</span></span><span class="line"><span class="cl">dev tun
</span></span><span class="line"><span class="cl">proto udp
</span></span><span class="line"><span class="cl">remote home.tiete.be <span class="m">9000</span>
</span></span><span class="line"><span class="cl">resolv-retry infinite
</span></span><span class="line"><span class="cl">nobind
</span></span><span class="line"><span class="cl">tun-mtu <span class="m">1500</span>
</span></span><span class="line"><span class="cl">tun-mtu-extra <span class="m">32</span>
</span></span><span class="line"><span class="cl">mssfix <span class="m">1200</span>
</span></span><span class="line"><span class="cl">persist-key
</span></span><span class="line"><span class="cl">persist-tun
</span></span><span class="line"><span class="cl">ca <span class="s2">&#34;ca.crt&#34;</span>
</span></span><span class="line"><span class="cl">cert <span class="s2">&#34;yeri.crt&#34;</span>
</span></span><span class="line"><span class="cl">key <span class="s2">&#34;yeri.key&#34;</span>
</span></span><span class="line"><span class="cl">tls-auth <span class="s2">&#34;ta.key&#34;</span> <span class="m">1</span>
</span></span><span class="line"><span class="cl">comp-lzo
</span></span><span class="line"><span class="cl">verb <span class="m">3</span>
</span></span></code></pre></div><p>Yeri being my username. Don&rsquo;t forget to download and add the ca.crt, user.crt, user.key (located in /usr/share/openvpn/easy-rsa/keys/) and ta.key (located in /etc/openvpn/) you&rsquo;ve created on the server.</p>
<p>If your client asks for &ldquo;directions&rdquo;, pick 1.</p>
<p>Start up server and client software.</p>
<p>Hitting connect in Tunnelblick should connect you to the VPN server, and (in my case) giving me an IP similar to 10.20.30.6. You can check this using &ldquo;ifconfig&rdquo; in Terminal.</p>
<p>Client:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">tun0: <span class="nv">flags</span><span class="o">=</span><span class="m">8851</span> mtu <span class="m">1500</span>
</span></span><span class="line"><span class="cl">    inet 10.20.30.6 --&gt; 10.20.30.5 netmask 0xffffffff
</span></span><span class="line"><span class="cl">    open <span class="o">(</span>pid 20551<span class="o">)</span>
</span></span></code></pre></div><p>Server:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">tun0      Link encap:UNSPEC  HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
</span></span><span class="line"><span class="cl">inet addr:10.20.30.1  P-t-P:10.20.30.2  Mask:255.255.255.255
</span></span><span class="line"><span class="cl">UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
</span></span><span class="line"><span class="cl">RX packets:407595 errors:0 dropped:0 overruns:0 frame:0
</span></span><span class="line"><span class="cl">TX packets:574351 errors:0 dropped:0 overruns:0 carrier:0
</span></span><span class="line"><span class="cl">collisions:0 txqueuelen:100
</span></span><span class="line"><span class="cl">RX bytes:27473209 <span class="o">(</span>26.2 MiB<span class="o">)</span>  TX bytes:603524377 <span class="o">(</span>575.5 MiB<span class="o">)</span>
</span></span></code></pre></div><p>Don&rsquo;t forget; when using &ldquo;tun&rdquo; as driver, your gateway/VPN server will always have the IP ending on .1 (e.g.: 10.20.30.1).</p>
<p>Now, if you want to route all traffic throug the VPN, like I did, you&rsquo;ll have to change some stuff in iptables (as the server is also acting as my home router, I already did have a few rules in it).</p>
<p>Allow all traffic through tun0 interface:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">iptables -A OUTPUT -o tun0 -j ACCEPT
</span></span><span class="line"><span class="cl">iptables -A INPUT -i tun0 -j ACCEPT
</span></span></code></pre></div><p>Allow traffic through the external port 9000 (UDP):</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">iptables -A INPUT -i ppp0 -p udp -m udp --dport <span class="m">9000</span> -j ACCEPT
</span></span></code></pre></div><p>Enable forwarding and NAT:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">iptables -A FORWARD -s 10.20.30.0/24 -i tun0 -j ACCEPT
</span></span><span class="line"><span class="cl">iptables -A FORWARD -d 10.20.30.0/24 -i ppp0 -j ACCEPT
</span></span><span class="line"><span class="cl">iptables -A POSTROUTING -o ppp0 -j MASQUERADE
</span></span></code></pre></div><p>And lastly, as I have Squid running on my server, I want to transparently forward all port 80 requests to the Squid server running on port 8080:</p>
<div class="highlight"><pre tabindex="0" class="chroma"><code class="language-bash" data-lang="bash"><span class="line"><span class="cl">iptables -t nat -A PREROUTING -i tun0 -p tcp -m tcp --dport <span class="m">80</span> -j REDIRECT --to-ports <span class="m">8080</span>
</span></span></code></pre></div><p>That&rsquo;s about it. You should have a running VPN from your current location to your VPN server. And you&rsquo;re able to use it as a gateway.</p>
<p>You can always traceroute/tracepath to your VPN server (10.20.30.1). It should only find one hop.</p>
]]></content:encoded>
      <category>apple</category><category>linux</category><category>networking</category>
      <category>apple</category><category>linux</category><category>gentoo</category><category>openvpn</category><category>vpn</category>
    </item>
    
  </channel>
</rss>
