<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>ScottDotDot </title>
	<atom:link href="http://s.co.tt/tag/vpn/feed/" rel="self" type="application/rss+xml" />
	<link>http://s.co.tt</link>
	<description>Babblings of a computer curmudgeon.</description>
	<lastBuildDate>Mon, 26 Jan 2026 16:08:52 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.1</generator>
	<item>
		<title>Redundant VPN Tunnels via Different ISPs</title>
		<link>http://s.co.tt/2019/04/23/redundant-vpn-tunnels/</link>
		<comments>http://s.co.tt/2019/04/23/redundant-vpn-tunnels/#comments</comments>
		<pubDate>Tue, 23 Apr 2019 18:57:12 +0000</pubDate>
		<dc:creator><![CDATA[Scott]]></dc:creator>
				<category><![CDATA[Computers]]></category>
		<category><![CDATA[OpenVPN]]></category>
		<category><![CDATA[routers]]></category>
		<category><![CDATA[tunnel]]></category>
		<category><![CDATA[VPN]]></category>

		<guid isPermaLink="false">http://s.co.tt/?p=2016</guid>
		<description><![CDATA[Intro My friends will tell you that I&#8217;m obsessed with redundancy, both in life and in I.T. At home I have two main internet connections, via Altice Optimum (&#8220;cable&#8221;) and Verizon FiOS. They&#8217;re both relatively high bandwidth, and are connected to my two core routers that operate in an active/passive configuration. Basically this: O------O +--------+ / \ &#124; &#124;------------/ O +------------------+--------------------&#124; Core &#124; / / &#124; Optimum Router &#124; &#124; Router &#124;----------O / +------------------+\ ______________&#124; 01 &#124; \ O \ / &#124; &#124;------------O \ \ / +--------+ / \ X Keepalived &#124; / Various O / \ Heartbeat &#124; O Networks / / \ +--------+ \ O +------------------+/ \_____________&#124; &#124;-----------\ \ &#124; FiOS Router &#124; &#124; Core &#124; \ O … <a class="continue-reading-link" href="http://s.co.tt/2019/04/23/redundant-vpn-tunnels/"> Continue reading</a>]]></description>
				<content:encoded><![CDATA[<h2>Intro</h2>
<p>My friends will tell you that I&#8217;m obsessed with redundancy, both in life and in I.T.</p>
<p>At home I have two main internet connections, via Altice Optimum (&#8220;cable&#8221;) and Verizon FiOS.  They&#8217;re both relatively high bandwidth, and are connected to my two core routers that operate in an active/passive configuration.  Basically this:</p>
<pre>
                                                                O------O
                                        +--------+             /        \
                                        |        |------------/          O
+------------------+--------------------|  Core  |           /          /
|  Optimum Router  |                    | Router |----------O          /
+------------------+\     ______________|   01   |           \        O
                     \   /              |        |------------O        \
                      \ /               +--------+           /          \
                       X          Keepalived |              /  Various   O
                      / \          Heartbeat |             O  Networks  /
                     /   \              +--------+          \          O
+------------------+/     \_____________|        |-----------\          \
|   FiOS Router    |                    |  Core  |            \          O
+------------------+--------------------| Router |-------------O        /
                                        |   02   |            /        /
                                        |        |-----------O        /
                                        +--------+            \      /
                                                               O----O		   
</pre>
<p>Hmmm.. I can&#8217;t tell if that thing on the right looks like a cloud or a turd.  Probably the latter.  I&#8217;ll skip the ASCII &#8220;art&#8221; next time.</p>
<p>But is that really enough?  Ever since &#8220;hurricane&#8221; Sandy I&#8217;ve been worried about losing both FiOS and Optimum simultaneously.  It&#8217;s never happened due to a coincidence of network failures on both providers, but it&#8217;s a different story if a tree takes out the lines.</p>
<p>Enter Sprint.  Many years ago, I <a href="/2014/08/25/netgear-lg-6100d-lte-gateway-for-sprint-review/">configured a Netgear 6100D</a> from Sprint to act as an emergency failover (and backdoor) so some things would stay up and running in the event of a failure.  But lately I started thinking about the scenario of a core router failure.</p>
<p>Now, I should point out that, aside from misconfiguration oopsies on my end, I&#8217;ve never had a complete failure of both core routers.</p>
<p>Nonetheless, wouldn&#8217;t it be better to have yet another router &#8212; sorta seperate from the other two &#8212; in case they go down for whatever reason?  And wouldn&#8217;t it be yet better if that new router wasn&#8217;t reliant on the Optimum and FiOS lines?  And wouldn&#8217;t it be even superer betterer if the new router also had two independent internet connections?</p>
<p>Yes.</p>
<p>This isn&#8217;t as costly as it sounds, btw.  My routers are just commodity hardware (right now they all happen to be Dell T110 II chassis with a bunch of NICs giving 12 ports per router).</p>
<p>The Sprint connection costs ~$15/mo (after taxes and fees) for 1GB per month (more than enough for the veritable trickle of pings that run through it on a regular basis).</p>
<p>And it was cheap enough for me to add a second cell connection via T-Mobile&#8217;s network, because I have Google Fi (aka Project Fi) which provides free &#8220;data only&#8221; SIMs that operate on TMo.  (Note that a full Fi phone will choose the best connection amongst TMo, Sprint, and Something Cellular.)  The &#8220;data only&#8221; SIM shares its allowance with my regualr Fi user account, so the cost there is negligible.  I did, however, purchase a Netgear LB1121 which is a very simple 4G LTE to Ethernet &#8220;adapter&#8221; (to call it a router would do disservice to actual routers).</p>
<p><a href="http://s.co.tt/2019/04/23/redundant-vpn-tunnels/network-diagram-or-whatever/" rel="attachment wp-att-2019"><img src="http://s.co.tt/wp-content/uploads/2019/04/Network-Diagram-or-Whatever-740x510.png" alt="Network Diagram or Whatever" width="740" height="510" class="aligncenter size-large wp-image-2019" /></a></p>
<p>To be fair, I think the ASCII diagram was better.</p>
<p>The one thing that might be perplexing about this diagram is the External Backup VPN01 machine in the lower-right.</p>
<p>Perhaps needless to say, the Sprint and TMo connections won&#8217;t have static IPs.  To make matters worse, they&#8217;ll only have one IP each.  I did prevously use dynamic DNS with the Sprint device, but the Netgear 6100D is a <a href="/2014/08/25/netgear-lg-6100d-lte-gateway-for-sprint-review/">HUGE pile of shit</a>.*</p>
<p>*The biggest embarassment for the 6100D is that it comes with a telnet interface exposed.  Which you can&#8217;t turn off.  Which has no password.  Which lets you view AND EDIT the config files for the entire device.  Oh, and did I mention that a config file includes the admin password?  IN PLAIN TEXT?  Disgusting.</p>
<p>Besides, dynamic DNS would still only afford me one non-redundant IP per connection, and cellular network IPs can change <strong>very</strong> frequently.</p>
<p>Hence I spooled up an Amazon EC2 instance and installed OpenVPN on it.  The backup router at my house connects to it via two independent tunnels, such that if one internet connection/VPN tunnel goes down, traffic will still flow on the other one.</p>
<h2>Network Interface Naming</h2>
<p>It took me a shockingly long time to figure out that this was a good idea, but I change the udev rules on my systems to rename the network ports to something logical.  Usually it&#8217;s the name of the network to which the port is connected.  So, for example:</p>
<blockquote><p>
File: <code>/etc/udev/rules.d/70-persistent-net.rules</code></p>
<p><code>SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1f:29:5a:c5:d7", ATTR{type}=="1", KERNEL=="eth*", NAME="<b>ethdev</b>"</code></p>
<p><code>SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="00:1f:29:5a:c5:d6", ATTR{type}=="1", KERNEL=="eth*", NAME="<b>ethgst</b>"</code></p>
<p><code>SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="90:e2:ba:69:bf:91", ATTR{type}=="1", KERNEL=="eth*", NAME="<b>ethmgt</b>"</code>
</p></blockquote>
<p>That&#8217;s a snippet from one of my core routers.  (Note that I&#8217;m using CentOS/RedHat; The location and format of that file may differ.)  The interface names are bolded, and correlate this way:</p>
<p><code>ethdev</code> = Development network<br />
<code>ethgst</code> = Guest network<br />
<code>ethmgt</code> = Management network</p>
<p>Of course, if you rename the interfaces here you&#8217;ll have to rename them anywhere else.  <code>grep -R eth0 /etc/* 2> /dev/null</code> should find every existing use of <code>eth0</code> if, for example, that were the name of the interface before the change.  Particularly look at your network configuration scripts (<code>/etc/sysconfig/network-scripts/ifcfg-*</code> in my case) and your firewall rules which may or may not specify interface names.</p>
<p>Strictly speaking, it&#8217;s not necessary to start the interface name with &#8220;<code>eth</code>&#8220;, but I stick with that to distinguish, for example, hardline ethernet interfaces from VPN tunnel or WLAN interfaces.</p>
<p>And likewise I also name the VPN tunnels, usually based upon what&#8217;s on the opposite end of the tunnel.  But in the case of this article, I named them based upon the ISP via which the traffic transits.</p>
<h2>OpenVPN Server Configuration Files</h2>
<p>I&#8217;m using OpenVPN 2.4.7.  If you&#8217;re using a different version, the options presented here may differ.  But this should be acceptable for many a version.</p>
<p>Per my poorly construed diagram above, I want to connect a router at my house (<code>rtr-backup01</code>) to an Amazon EC2 instance in &#8220;the cloud&#8221; (<code>ext-backup-vpn01</code>).</p>
<p>The EC2 host is a nano instance, incidentally.  One CPU core, 1GB RAM, and 8GB disk space.  That&#8217;s actually more than what&#8217;s required for this purpose, so don&#8217;t go overboard in a similar circumstance.</p>
<p>There will be two VPN tunnels connecting those two hosts, which will be redundant to each other.  One tunnel will be connected via Sprint, and the other via T-Mobile.</p>
<p>Here&#8217;s the <code>tmobile</code> server config:  </p>
<p>(I show the <code>sprint</code> configs all together down below so you can see the differences, though they&#8217;re broadly similar.)</p>
<blockquote><p>
port 1199<br />
proto tcp<br />
dev tuntmobile<br />
ca ext-backup-vpn01/ca.crt<br />
cert ext-backup-vpn01/ext-backup-vpn01.crt<br />
key ext-backup-vpn01/ext-backup-vpn01.key<br />
dh ext-backup-vpn01/dh2048.pem<br />
server 10.208.3.0 255.255.255.0<br />
push &#8220;route 172.31.41.125 255.255.255.255&#8243;<br />
push &#8220;route 172.31.41.126 255.255.255.255&#8243;<br />
push &#8220;route 10.71.246.0 255.255.255.0&#8243;<br />
client-connect ext-backup-vpn01/ccd/client-connect-tmobile.bsh<br />
client-disconnect ext-backup-vpn01/ccd/client-disconnect-tmobile.bsh<br />
route-metric 10<br />
client-config-dir ext-backup-vpn01/ccd<br />
topology p2p<br />
cipher AES-128-CBC<br />
comp-lzo<br />
tcp-nodelay<br />
persist-key<br />
#persist-tun<br />
keepalive 5 30<br />
status /var/log/openvpn/ext-backup-vpn01-tmobile.status<br />
log /var/log/openvpn/ext-backup-vpn01-tmobile.log<br />
verb 3<br />
mute 20
</p></blockquote>
<p>The <code>port</code>, <code>proto</code>col, and <code>dev</code> fields are pretty standard and self explanatory.</p>
<p>Same goes for the <code>ca</code>, <code>cert</code>, <code>key</code> and <code>dh</code> fields.  I won&#8217;t get into the generation of certificates (etc.) here, but there are plenty of good tutorials on the subject.</p>
<p><code>server</code> must be different between the two tunnels, otherwise it&#8217;ll lead to confusion when trying to route traffic.  This essentially defines the network that will be used within the VPN tunnel, between the server and client.  (In this case there&#8217;s only ever going to be one client, but all clients would be allocated an address in this space.)</p>
<p>The <code>push</code> commands tell the clients which networks are accessible via the tunnel, on the server side.  In this example, the two addresses beginning with <code>172.31.41</code> are the private network addresses of the EC2 instance, as assigned by Amazon.  The network <code>10.71.246.0</code> is used by a different VPN instance, allowing me to connect to <code>ext-backup-vpn01</code> from anywhere.</p>
<p><strong>These are the two most important configuration items</strong>, at least as far as making these redundant tunnels function properly:</p>
<p><code>client-connect</code> and <code>client-disconnect</code> specify shell scripts that are run when the client connects and then disconnects, respectively.  In my case, the purpose of those scripts is to establish routes to the networks behind each client when they connect, and to tear down those routes when they disconnect.  I&#8217;ll post the full code for those below.</p>
<p><code>route-metric</code> is essentially ignored, as the two scripts mentioned above set the routes and their metrics.  Usually this setting would be used to establish the metric for routes created by OpenVPN, e.g. with the <code>route</code> configuration option.  I left it in the config as a reminder:  The <code>tmobile</code> routes have a metric of <code>10</code> whereas the <code>sprint</code> routes have a metric of <code>20</code>.</p>
<p><code>client-config-dir</code> points to a directory that contains various configuration options specific to each client.  I&#8217;ll also show that below.</p>
<p><code>topology p2p</code> specifies that it&#8217;s a point-to-point configuration.  (Not valid when using Windows.)  <a target="_blank" href="https://community.openvpn.net/openvpn/wiki/Topology">Here&#8217;s a more robust discussion of that option.</a></p>
<p><code>cipher</code>, <code>comp-lzo</code>, and <code>persist-key</code> are pretty standard options.  See <a target="_blank" href="https://openvpn.net/community-resources/reference-manual-for-openvpn-2-4/">the OpenVPN reference manual</a> for more info on these and all other options.</p>
<p><code>persist-tun</code> may be essential for other use cases, as it causes the tunnel interface (i.e. <code>tuntmobile</code>) to remain even when there&#8217;s no connectivity between server and client.  You may have some scripts or programs that rely on finding your tunnel&#8217;s interface, or it may be referenced elsewhere.  For example, I&#8217;m not sure what would happen if you referenced a transient network interface in your <code>iptables</code> config.  In my case, I want the tunnel interface to be torn down when the tunnel isn&#8217;t established.</p>
<p><strong>Another important option:</strong> <code>keepalive [interval] [timeout]</code>.  The interval parameter is the frequency at which the client &#8220;pings&#8221; the server to determine if the tunnel is still up.  The timeout parameter is the amount of time without a successful ping that would elapse before OpenVPN decides the tunnel is actually down.  Importantly, when it decides the tunnel is down, <strong>the <code>client-disconnect</code> script is run</strong>. </p>
<p>You may need to fine-tune <code>keepalive</code> to suit your needs, but remember that the <code>timeout</code> is the minimum amount of time that the primary tunnel will be down before its routes disappear, thereby allowing the secondary tunnel to take over traffic.</p>
<p>Due to the routing metric of the <code>tmobile</code> tunnel being lower (10) than that of the <code>sprint</code> tunnel (20), <code>tmobile</code> is the primary tunnel.  So when that connection goes down, it will take at least 30 seconds (but probably no more than 40-ish) for <code>sprint</code> to take over.</p>
<p><code>status</code>, <code>log</code>, <code>verb</code>, and <code>mute</code> all relate to logging (and status, natch), and can be set as desired.</p>
<h2>Client [Dis]connect Scripts</h2>
<p>Incidentally, these scripts don&#8217;t need to live in the <code>client-config-dir</code> (named <code>ccd</code>), but that&#8217;s where I felt like putting them.</p>
<p><strong>Note that they do need to be readable and executable by the OpenVPN process.</strong>  So if, for example, <code>openvpn</code> runs in the user:group context of <code>openvpn:openvpn</code>, then you&#8217;ll want to <code>chown openvpn:openvpn *</code> and <code>chmod ug+rx *</code> for your scripts (where <code>*</code> would only reference the applicable scripts).</p>
<p>Also, <strong>your OpenVPN process must have the ablity to create routes in the kernel routing table</strong> (though you can use tables other than the main/default table).  It can be useful, when troubleshooting, to run the OpenVPN process as <code>root:root</code>.  Once everything is working, you can manipulate the user/group context. </p>
<p>Here&#8217;s what I have in the script referenced by <code>client-connect ext-backup-vpn01/ccd/client-connect-tmobile.bsh</code> (one also exists for <code>sprint</code>, and is shown much farther down on this page):</p>
<blockquote><p>
#!/bin/bash<br />
while read ROUTE; do<br />
        ip route <b>add</b> $ROUTE via <b>$ifconfig_local</b> metric <b>10</b> >> /var/log/openvpn/client-connect-tmobile.log 2>&#038;1<br />
done < /etc/openvpn/ext-backup-vpn01/ccd/client-connection-routes<br />
exit 0
</p></blockquote>
<p>And here&#8217;s <code>client-connect ext-backup-vpn01/ccd/client-disconnect-tmobile.bsh</code> (one also exists for <code>sprint</code>:</p>
<blockquote><p>
#!/bin/bash<br />
while read ROUTE; do<br />
        ip route <b>del</b> $ROUTE via <b>$ifconfig_local</b> metric <b>10</b> >> /var/log/openvpn/client-disconnect-tmobile.log 2>&#038;1<br />
done < /etc/openvpn/ext-backup-vpn01/ccd/client-connection-routes<br />
exit 0
</p></blockquote>
<p>Both of those files reference the file <code>/etc/openvpn/ext-backup-vpn01/ccd/client-connection-routes</code>, which in my case contains:</p>
<blockquote><p>
10.201.0.0/16<br />
10.253.0.0/16<br />
10.1.1.0/24<br />
10.1.2.0/24<br />
192.168.0.0/21<br />
192.168.10.0/24<br />
10.250.0.0/16<br />
10.101.0.0/16<br />
10.121.0.0/16<br />
192.168.90.0/24<br />
192.168.81.0/24
</p></blockquote>
<p>Each of the networks above are accessible on the client end of the tunnels.</p>
<p>The scripts iterate through each line of <code>/etc/openvpn/ext-backup-vpn01/ccd/client-connection-routes</code>, calling <code>ip route add</code> or <code>ip route del</code> to either establish or remove the routes when the <code>client-connect</code> or <code>client-disconnect</code> scripts are called.</p>
<p><strong>The only difference between the <code>client-connect</code> and <code>client-disconnect</code> scripts above is that one contains <code>add</code> and the other contains <code>del</code>.</strong></p>
<p><strong>The only difference between the <code>tmobile</code> version of the scripts shown above and the <code>sprint</code> versions is the <code>metric</code>.</strong>  (And, as you can see, the name of the log file.. which is not required, but may help with debugging.)</p>
<p><strong>The astute viewers amongst you</strong> will say &#8220;WTF? That could all be done with one script!&#8221;</p>
<p>Kinda.</p>
<p>Because I&#8217;m running two separate instances of OpenVPN servers, each one needs both a connect and disconnect script.  (That&#8217;s 4 total.)  Those scripts could then call a single script which would do all the route manipulation.  I dunno, what I have is pretty functional, but yes, it could be a bit more streamlined.</p>
<p>Note that OpenVPN sets a whole bunch of environment variables in the context of each script when calling it.  See <a target="_blank" href="https://openvpn.net/community-resources/reference-manual-for-openvpn-2-4/">the OpenVPN reference manual</a> for a full list.  (The document doesn&#8217;t appear to have anchor tags, but search the page for &#8220;bytes_received&#8221;.  That&#8217;s the first variable in the list.)</p>
<p>So you could have all sorts of caveats (if/then) and other functionality within those scripts.  If you had multiple clients connecting to the same server instance, those variables would tell you who that client is, and as such you could take different actions for different clients.  It&#8217;s actually a pretty robust arrangement.</p>
<p>The only environment variable I&#8217;m using is <code>$ifconfig_local</code>, which is the IP address of the server on its end of the VPN tunnel.  So, in the examples above, <code>10.208.3.0 255.255.255.0</code> is the VPN&#8217;s network (defined by the <code>server</code> option in the config file), and so <code>10.208.3.1</code> is the server&#8217;s IP.  Thusly, <code>$ifconfig_local</code> is  <code>10.208.3.1</code>.</p>
<p>The last bit of the configs are the client config directory files.</p>
<p>Here&#8217;s the contents of <code>ext-backup-vpn01/ccd/client-tmobile01</code>.  </p>
<p>BTW, that directory is defined in the main OpenVPN config file by the parameter <code>client-config-dir</code>, and the file name (<code>client-tmobile01</code>) is the X509 name of the client certificate (defined when you created the certificate).</p>
<blockquote><p>
ifconfig-push 10.208.3.100 10.208.3.1<br />
iroute 10.201.0.0 255.255.0.0<br />
iroute 10.253.0.0 255.255.0.0<br />
iroute 10.1.1.0 255.255.255.0<br />
iroute 10.1.2.0 255.255.255.0<br />
iroute 192.168.0.0 255.255.248.0<br />
iroute 192.168.10.0 255.255.255.0<br />
iroute 10.250.0.0 255.255.0.0<br />
iroute 10.250.0.0 255.255.0.0<br />
iroute 10.101.0.0 255.255.0.0<br />
iroute 10.121.0.0 255.255.0.0<br />
iroute 192.168.90.0 255.255.255.0<br />
iroute 192.168.81.0 255.255.255.0
</p></blockquote>
<p>There is something important to note here: <strong><code>iroute</code> does NOT create routes in the kernel routing table.</strong>  That&#8217;s what the scripts above do.</p>
<p><code>iroute</code> tells OpenVPN itself that it is capable of transiting traffic to that network.  Hence every single one of those <code>iroute</code> commands correlates to a network in the file <code>/etc/openvpn/ext-backup-vpn01/ccd/client-connection-routes</code>, above.  <strong>The routes need to be enumerated in both places.</strong></p>
<p>(I only thought of this just now, but to avoid maintaining two different lists the <code>client-[dis]connect</code> scripts could iterate through the client config file and create a route in the kernel routing table for each of the <code>iroute</code> lines.)</p>
<h2>OpenVPN Client Config Files</h2>
<p>Here&#8217;s the OpenVPN conf file for the <code>tmobile</code> client:</p>
<blockquote><p>
client<br />
dev tuntmobile<br />
proto tcp<br />
port 1199<br />
local 10.222.3.5<br />
remote 50.60.70.80<br />
route-metric 10<br />
resolv-retry infinite<br />
persist-key<br />
dh client-tmobile01/dh2048.pem<br />
ca client-tmobile01/ca.crt<br />
cert client-tmobile01/client-tmobile01.crt<br />
key client-tmobile01/client-tmobile01.key<br />
topology p2p<br />
up-delay<br />
cipher AES-128-CBC<br />
comp-lzo<br />
verb 3<br />
status /var/log/openvpn/client-tmobile01.status<br />
log /var/log/openvpn/client-tmobile01.log
</p></blockquote>
<p>There&#8217;s nothing too crazy on the client side, but there are a few things to discuss:</p>
<p><code>local 10.222.3.5</code> is the address of the ethernet interface which connects to the T-Mobile cell modem / &#8220;router&#8221; (the Netgear LB1121).</p>
<p>I&#8217;ve changed <code>remote</code> to a nonsense address to protect the innocent, but it&#8217;s the public (Elastic) IP of my EC2 instance on which the <code>tmobile</code> OpenVPN server runs.</p>
<p><code>up-delay</code> is probably best defined by the OpenVPN reference manual:</p>
<blockquote><p>Delay TUN/TAP open and possible –up script execution until after TCP/UDP connection establishment with peer.In –proto udp mode, this option normally requires the use of –ping to allow connection initiation to be sensed in the absence of tunnel data, since UDP is a “connectionless” protocol.</p>
<p>On Windows, this option will delay the TAP-Win32 media state transitioning to “connected” until connection establishment, i.e. the receipt of the first authenticated packet from the peer.</p></blockquote>
<p>Needless to say, the client configuration for the <code>sprint</code> connection is nearly identical, and is shown below.</p>
<h2>The Sprint-Related Files</h2>
<p>Just for completeness, here are the full readouts of the files on the <code>sprint</code> server.</p>
<p>I marked in <b>bold</b> each place where the files differ from the <code>tmobile</code> files.</p>
<blockquote><p>
<b>port 1198</b><br />
proto tcp<br />
<b>dev tunsprint</b><br />
ca ext-backup-vpn01/ca.crt<br />
cert ext-backup-vpn01/ext-backup-vpn01.crt<br />
key ext-backup-vpn01/ext-backup-vpn01.key<br />
dh ext-backup-vpn01/dh2048.pem<br />
<b>server 10.208.2.0 255.255.255.0</b><br />
push &#8220;route 10.71.246.0 255.255.255.0&#8243;<br />
push &#8220;route 172.31.41.125 255.255.255.255&#8243;<br />
push &#8220;route 172.31.41.126 255.255.255.255&#8243;<br />
<b>client-connect ext-backup-vpn01/ccd/client-connect-sprint.bsh</b><br />
<b>client-disconnect ext-backup-vpn01/ccd/client-disconnect-sprint.bsh</b><br />
<b>route-metric 20</b><br />
client-config-dir ext-backup-vpn01/ccd<br />
topology p2p<br />
cipher AES-128-CBC<br />
comp-lzo<br />
tcp-nodelay<br />
persist-key<br />
#persist-tun<br />
keepalive 10 30<br />
<b>status /var/log/openvpn/ext-backup-vpn01-sprint.status</b><br />
<b>log /var/log/openvpn/ext-backup-vpn01-sprint.log</b><br />
verb 3<br />
mute 20
</p></blockquote>
<p>Note that I used <strong>the same server certification authority, certificate, and key file</strong> for both servers.  It&#8217;s perhaps not best practice, but honestly what does it matter&#8230; if someone compromises one tunnel&#8217;s encryption, then they compromise both.  But they&#8217;re redundant connections serving the same purpose, so the risk is minimal.  You may, of course, use completely different certificates for both.</p>
<p><code>client-connect-sprint.bsh</code>:</p>
<blockquote><p>
#!/bin/bash<br />
while read ROUTE; do<br />
        ip route add $ROUTE via $ifconfig_local <b>metric 20</b> >> /var/log/openvpn/client-connect-<b>sprint</b>.log 2>&#038;1<br />
done < /etc/openvpn/ext-backup-vpn01/ccd/client-connection-routes<br />
exit 0
</p></blockquote>
<p><code>client-disconnect-sprint.bsh</code>:</p>
<blockquote><p>
#!/bin/bash<br />
while read ROUTE; do<br />
        ip route del $ROUTE via $ifconfig_local <b>metric 20</b> >> /var/log/openvpn/client-disconnect-<b>sprint</b>.log 2>&#038;1<br />
done < /etc/openvpn/ext-backup-vpn01/ccd/client-connection-routes<br />
exit 0
</p></blockquote>
<p><code>ext-backup-vpn01/ccd/client-sprint01</code>:</p>
<blockquote><p>
ifconfig-push <b>10.208.2.100 10.208.2.1</b><br />
iroute 10.201.0.0 255.255.0.0<br />
iroute 10.253.0.0 255.255.0.0<br />
iroute 10.1.1.0 255.255.255.0<br />
iroute 10.1.2.0 255.255.255.0<br />
iroute 192.168.0.0 255.255.248.0<br />
iroute 192.168.10.0 255.255.255.0<br />
iroute 10.250.0.0 255.255.0.0<br />
iroute 10.250.0.0 255.255.0.0<br />
iroute 10.101.0.0 255.255.0.0<br />
iroute 10.121.0.0 255.255.0.0<br />
iroute 192.168.90.0 255.255.255.0<br />
iroute 192.168.81.0 255.255.255.0
</p></blockquote>
<p>Here&#8217;s the configuration file on the <code>sprint</code> <strong>client</strong>.</p>
<blockquote><p>
client<br />
<b>dev tunsprint</b><br />
proto tcp<br />
<b>port 1198</b><br />
<b>local 10.222.2.5</b><br />
<b>remote 10.20.30.40</b><br />
<b>route-metric 20</b><br />
resolv-retry infinite<br />
persist-key<br />
#persist-tun<br />
<b>dh client-sprint01/dh2048.pem<br />
ca client-sprint01/ca.crt<br />
cert client-sprint01/client-sprint01.crt<br />
key client-sprint01/client-sprint01.key</b><br />
cipher AES-128-CBC<br />
topology p2p<br />
up-delay<br />
comp-lzo<br />
verb 3<br />
<b>status /var/log/openvpn/client-sprint01.status<br />
log /var/log/openvpn/client-sprint01.log</b>
</p></blockquote>
<h2>In Conclusion</h2>
<p>With both tunnels providing routes to my home infrastructure via Amazon&#8217;s network and my EC2 instance, I have the ability to have unlimited static, public IPs for the Sprint and T-Mobile connections.</p>
<p>Using iptables&#8217; <code>DNAT</code> manipulation, I can reverse NAT those public IPs to any internal IP addresses I desire.</p>
<p>Moreover, I have a separate VPN server running on the EC2 instance which will allow me to connect to it, and therefore my entire infrastructure, using an OpenVPN client on one of my laptops, tablets, or phones.  That&#8217;s particularly useful when I&#8217;m traveling and my network goes dark.  Up until now, if my cable and FiOS connections went down or my core routers went down, I&#8217;d have no visibility as to what happened.  This was also true if I became subject to a DDOS attack.</p>
<p>Finally, by having the backup router and backup internet connections, I can route outgoing mail through them as a redundant path.  That means that my Zabbix servers (for system monitoring) and other scripts can communicate issues to me even during a widespread outage.</p>
<p>Overkill?</p>
<p>Definitely.</p>
<p>Fun?</p>
<p>Definitely.  </p>
<p>Though your mileage may vary ;)</p>
<h2>Gratuitous Pics</h2>
<div id="attachment_2047" style="width: 565px" class="wp-caption aligncenter"><a href="http://s.co.tt/wp-content/uploads/2019/04/IMG_20190425_232118.jpg"><img src="http://s.co.tt/wp-content/uploads/2019/04/IMG_20190425_232118-555x740.jpg" alt="Backup Router (Dell PowerEdge T110 II)" width="555" height="740" class="size-large wp-image-2047" /></a><p class="wp-caption-text">This is the backup router which maintains the VPN tunnels via Sprint and T-Mobile to Amazon&#8217;s network (and hence my EC2 instance).   In addition to the connections for those two cellular ISPs, it also connects to my FiOS line for direct VPN access.  The other connections are for various in-house networks.</p></div>
<div id="attachment_2048" style="width: 565px" class="wp-caption aligncenter"><a href="http://s.co.tt/2019/04/23/redundant-vpn-tunnels/img_20190425_232155/" rel="attachment wp-att-2048"><img src="http://s.co.tt/wp-content/uploads/2019/04/IMG_20190425_232155-555x740.jpg" alt="Netgear / T-Mobile LB1121 WWAN to LAN Router" width="555" height="740" class="size-large wp-image-2048" /></a><p class="wp-caption-text">This is the Netgear LB1121 which provides connectivity to T-Mobile&#8217;s network.  It&#8217;s not exactly feature rich, but it serves the purpose of providing an ethernet port routed to T-Mobile.  It does have PoE, though, which is pretty awesome.  Here I&#8217;m just using the internal antennae, and as you can see I get mediocre service in the basement.  (I may put this upstairs eventually&#8230; hmmm.)</p></div>
<div id="attachment_2049" style="width: 565px" class="wp-caption aligncenter"><a href="http://s.co.tt/2019/04/23/redundant-vpn-tunnels/img_20190425_232207/" rel="attachment wp-att-2049"><img src="http://s.co.tt/wp-content/uploads/2019/04/IMG_20190425_232207-555x740.jpg" alt="Netgear / Sprint 6100D WWAN to LAN Router" width="555" height="740" class="size-large wp-image-2049" /></a><p class="wp-caption-text">This is the Netgear 6100D, providing connectivity via Sprint&#8217;s network.  Even though the software of this device is terrible, it&#8217;s pretty good hardware-wise.  It even has PoE!  (But only on the WAN port for some bizarre reason.  That&#8217;s why it has 2 ethernet cables running to it; One is just for power.)  There&#8217;s also a coax cable attached to it, connecting to a directional antenna in my attic!  <a href="/2014/12/15/sprint-netgear-6100d-4g-antenna-installation-video/" style="color: #FFFFFF; text-decoration: underline;">I did a whole video about that install, which you can check out if you&#8217;re bored.</a>  :)</p></div>
]]></content:encoded>
			<wfw:commentRss>http://s.co.tt/2019/04/23/redundant-vpn-tunnels/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
