User Tools

Site Tools


vpn-pi

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
vpn-pi [2020/04/29 11:35]
robm [Configure WiFi settings]
vpn-pi [2020/04/29 16:54] (current)
robm
Line 13: Line 13:
 <code>sudo wpa_cli terminate</code> <code>sudo wpa_cli terminate</code>
  
-Forever:+Forever: Disabling the service permanently is tricky, as lots of events can cause it to be started. A better solution is to exclude ''wlan0'' from being managed by it, by adding ''nohook wpa_supplicant'' to ''/etc/network/interfaces.d/wlan0'' (created in the next section).
  
-Disabling the ''wpa_supplicant.service'' in systemd doesn't work, but see below for how to disable the ''wpa_supplicant'' hook in ''/etc/network/interfaces.d/wlan0'' 
 ===== Configure WiFi settings ===== ===== Configure WiFi settings =====
  
Line 23: Line 22:
 auto wlan0 auto wlan0
 iface wlan0 inet static iface wlan0 inet static
-  address 192.168.167.40/24 +  address 172.16.0.1/24 
-  nohook wpa_supplicant+  nohook wpa_supplicant  # Conflicts with hostapd (WPA is for clients, not access points)
 </code> </code>
  
Line 38: Line 37:
 <code> <code>
 root@raspberrypi4:~# ip -br addr show wlan0 root@raspberrypi4:~# ip -br addr show wlan0
-wlan0            UP             192.168.167.40/24 169.254.114.246/16 fe80::3592:65db:94e0:c992/64+wlan0            UP             172.16.0.1/24 169.254.114.246/16 fe80::3592:65db:94e0:c992/64
 </code> </code>
  
 ===== DHCP & DNS Services ===== ===== DHCP & DNS Services =====
 +
 +Disable the default ''systemd-resolved'' service which runs on localhost, as it takes control of ''/etc/resolv.conf'', which in turn prevents the DHCP + DNS server we're about to install from noticing when expressvpn changes the DNS server.
 +
 +It's important that ''dnsmasq'' notices when ''/etc/resolv.conf'' changes, or DNS lookups will fail entirely due to ExpressVPN adding firewall rules to drop all DNS queries that don't go via ExpressVPN.
 +
 +<code>
 +sudo systemctl disable --now systemd-resolved
 +</code>
  
 <code> <code>
Line 54: Line 61:
 && sudo dnsmasq \ && sudo dnsmasq \
   --no-daemon \   --no-daemon \
-  --dhcp-range=172.160.0.50,172.16.0.150,12h \+  --dhcp-range=172.16.0.10,172.16.0.20,1h \
   --except-interface=eth0 \   --except-interface=eth0 \
   --dhcp-authoritative \   --dhcp-authoritative \
 +  --log-queries \
   --clear-on-reload   --clear-on-reload
 </code> </code>
Line 141: Line 149:
  
 Then try to connect from another device (e.g. mobile phone). The WiFi network should be visible, and when you connect you should get an IP address, but probably an error about no internet connection. That's next. Then try to connect from another device (e.g. mobile phone). The WiFi network should be visible, and when you connect you should get an IP address, but probably an error about no internet connection. That's next.
 +
 +===== Network Address Translation =====
 +
 +Enable Network Address Translation (NAT) on any traffic that leaves us via ExpressVPN's ''tun0'' interface.
 +
 +Note that the interface doesn't exist until you run ''expressvpn connect'', but you can add the rule to ''iptables'' without issue.
 +
 +<code>
 +iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
 +</code>
 +
 +Note that is this is the **only** MASQUERADE rule (check with ''iptables -t nat -nvL'') then devices using this access point will experience 100% packet loss when ExpressVPN is not connected. I consider this a feature, but if you don't you can add another rule for ''eth0'':
 +
 +<code>
 +iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
 +</code>
 +
vpn-pi.1588160133.txt.gz · Last modified: 2020/04/29 11:35 by robm