Getting Raspberry Pi as VPN
Download the latest Raspian Stretch
Write to sdcard using Raspberry Pi Imager
Add ssh file to the sdcard to enable SSH
Start with Extending with filesystem
Advanced > Extend filesystem
sudo apt update && sudo apt full-upgrade && sudo reboot
Ds-install Classic Networking
sudo -Es apt --autoremove purge ifupdown dhcpcd5 isc-dhcp-client isc-dhcp-common rsyslog apt-mark hold ifupdown dhcpcd5 isc-dhcp-client isc-dhcp-common rsyslog raspberrypi-net-mods openresolv rm -r /etc/network /etc/dhcp
Setup and Enable Systemd-Resolved and Systemd-networkd
apt --autoremove purge avahi-daemon apt-mark hold avahi-daemon libnss-mdns apt install libnss-resolve ln -sf /run/systemd/resolve/stub-resolv.conf /etc/resolv.conf systemctl enable systemd-networkd.service systemd-resolved.service
Configure wpa_supplicant as access point
cat > /etc/wpa_supplicant/wpa_supplicant-wlan0.conf <<EOF country=DE ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev update_config=1 network={ ssid="RpiNet" mode=2 frequency=2437 #key_mgmt=NONE # uncomment this for an open hotspot # delete next 3 lines if key_mgmt=NONE key_mgmt=WPA-PSK pairwise=CCMP TKIP group=CCMP TKIP psk="SetPasscode" } EOF chmod 600 /etc/wpa_supplicant/wpa_supplicant-wlan0.conf systemctl disable wpa_supplicant.service systemctl enable [email protected] rfkill unblock wlan
Setting up Access Point (wlan0) and BRIDGE (eth0)
cat > /etc/systemd/network/02-br0.netdev <<EOF [NetDev] Name=br0 Kind=bridge EOF cat > /etc/systemd/network/08-eth2.network <<EOF [Match] Name=eth2 EOF cat > /etc/systemd/network/12-br0_add-eth2.network <<EOF [Match] Name=eth2 [Network] Bridge=br0 EOF cat > /etc/systemd/network/08-eth1.network <<EOF [Match] Name=eth1 EOF cat > /etc/systemd/network/12-br0_add-eth4.network <<EOF [Match] Name=eth1 [Network] Bridge=br0 EOF cat > /etc/systemd/network/16-br0_up.network <<EOF [Match] Name=br0 [Network] Address=10.168.42.100/24 MulticastDNS=yes IPMasquerade=yes DHCPServer=yes [DHCPServer] ServerAddress=10.168.7.1 PoolOffset=10 EOF
Asking wpa_supplicant to use a bridge. We do it by modifying its service with
ExecStartPre=/sbin/iw dev %i set type __ap ExecStartPre=/bin/ip link set %i master br0 ExecStart= ExecStart=/sbin/wpa_supplicant -c/etc/wpa_supplicant/wpa_supplicant-%I.conf -Dnl80211,wext -i%I -bbr0 ExecStopPost=-/bin/ip link set %i nomaster ExecStopPost=-/sbin/iw dev %i set type managed
Reboot to check if the bridge works. This would no longer allow you to connect over the previous IP. Now connect the device at 10.168.7.1
sudo -Es cat > /etc/systemd/network/04-eth0.network <<EOF [Match] Name=eth0 [Network] DHCP=yes MulticastDNS=yes EOF
systemctl daemon-reload systemctl restart systemd-networkd.service exit
sh <(wget -qO - https://downloads.nordcdn.com/apps/linux/install.sh) sudo usermod -aG nordvpn $USER sudo reboot
Login into NordVPN using Nord Account
nordvpn whitelist add port 22
nordvpn set technology nordlynx
Now any device connected downstream of the Raspberry pi will go through the vpn.