<h1>Internet Failover (dual wan pfsense setup) </h1>
<b>Threat Model:</b>
<p>Your ISP connection comes with a closed-source router. What makes you think that your ISP isn't giving access to it to an adversary so that he may be able to spy on your home network ? How do you protect against that?</p>
<p>That same adversary suspects that you are running a hidden service from home. That adversary makes your ISP shut down your internet connection to check if you are actually running it or not. How do you ensure your hidden service keeps running ?</p>
<imgsrc="0.png"style="width:250px">
<p>In this tutorial we're going to setup a pfsense VM inside of virt-manager to make sure that our .onion Hidden service is hidden behind an open-source router, rather than a closed-source one. as detailed below:</p>
<imgsrc="1.png"class="imgRz">
<p>We're going to also make sure that we protect the hidden service from controlled internet downtimes, with a failover internet connection to a mobile hotspot.</p>
</div>
</div><!-- /row -->
</div><!-- /container -->
</div><!-- /grey -->
<!-- +++++ Second Post +++++ -->
<divid="anon3">
<divclass="container">
<divclass="row">
<divclass="col-lg-8 col-lg-offset-2">
<h2><b>Initial Setup </b></h2>
<p>First you're going to need a Libvirtd QEMU hypervisor on your home server, check <ahref="../antiforensics/index.html">this</a> tutorial to know how to set it up.</p>
<p>So here we create the pfsense VM as shown in <ahref="../pf_virt/index.html">this</a> tutorial, and we make sure to adjust it to have the following network configuration:</p>
<p>So for the main network interface we setup the network interface as a direct attachment to the host network interface enp8s0 (as a macvtap device in virt-manager):</p>
<imgsrc="2.png"class="imgRz">
<p>As detailed in the previous tutorial, for the LAN network we setup an isolated network and use it like so:</p>
<imgsrc="3.png"class="imgRz">
<p>Then from inside pfsense we can set them both like so:</p>
<imgsrc="4.png"class="imgRz">
<p>Then we setup the second WAN, which is our mobile USB tethering hotspot. First just connect the mobile phone to the homeserver via USB:</p>
<imgsrc="5.png"class="imgRz">
<p>Once plugged in, you can check if the homeserver detects it via the lsusb command, and if it does, just add the USB host device to the VM directly like so:</p>
<imgsrc="6.png"class="imgRz">
<imgsrc="7.png"class="imgRz">
<p>However that's not enough as when you enable USB tethering the USB device ID changes, so we enable USB tethering like so (ex: in Graphene OS you go to: <b>Settings > Network and Internet > Hotspot & Tethering > Toggle USB Tethering ON</b>) before adding it in the pfsense VM:</p>
<p>Now that the device is added, enable USB tethering from your phone , then let's make sure that it is properly configured as a second WAN interface in pfsense:</p>
<p>Here you see the pfsense VM detecting the usb device from console, however to make the setup simpler we'll set it up from the pfsense dashboard, from the VM inside the LAN network:</p>
<imgsrc="10.png"class="imgRz">
<p>So after clicking "add" we have now the OPT3 interface that we can configure:</p>
<imgsrc="11.png"class="imgRz">
<p>We rename it to WAN-Mobile, set it to DHCP (as it is the mobile phone that gives the DHCP lease to that interface), and hit save:</p>
<imgsrc="12.png"class="imgRz">
<imgsrc="13.png"class="imgRz">
<p>Here you can also see that pfsense detects that interface as a gateway in the routing section:</p>
<imgsrc="14.png"class="imgRz">
<p>Now that's done, we need to setup the failover by first having both gateways into the same gateway group: </p>
<imgsrc="15.png"class="imgRz">
<imgsrc="16.png"class="imgRz">
<p>Now here we have a gateway group, we have set our main WAN interface (WANGW, the ethernet connection) to be tier 1 as in first priority, and we have set our secondary WAN interface (WANMOBILE) to be Tier 2 as in second priority. The trigger level to switch between the 2 is going to be Packet Loss. <b>Meaning if the ethernet connection goes down, the internet connection will resume through the mobile USB tethering hotspot</b>: </p>
<p>Now we hit save and apply, then we need to edit the LAN firewall rule because otherwise it won't accept any traffic to be routed to the other gateway:</p>
<imgsrc="17.png"class="imgRz">
<imgsrc="18.png"class="imgRz">
<imgsrc="19.png"class="imgRz">
<p>Now with this, the lan subnet will automatically route traffic through either gateway as dictated by pfsense. which is what we want. Now hit save and apply:</p>
<imgsrc="20.png"class="imgRz">
<p>And now we can see it in action when we unplug the ethernet cable like so:</p>
<imgsrc="22.png"class="imgRz">
<p>As you can see here, the traffic first goes through the default WAN interface, and after i unplug the ethernet cable, the same traffic starts to go through the other WAN interface via the mobile connection. Which concludes today's tutorial.</p>
Until there is Nothing left.</p></br></br><p>Creative Commons Zero: <ahref="../../../../opsec/runtheblog/index.html">No Rights Reserved</a></br><imgsrc="\CC0.png">