I want to use my raspberry pi 3 as a wireless AP that I could connect to via my laptop or cell phone for use with my VPN subscription (PIA).
Simultaneously, I want to keep my static eth0 IP address 192.168.0.222 so that I can keep SSHing from my main PC over my LAN.
I have already set up an access point that allowed my phone to connect to the pi via wlan0 and bridge through to eth0 but not tun0. This setup kept my 192.168.0.222 for local SSH, and provided internet to my laptop and phone. But this setup didn't route traffic over wlan0 to my VPN.
I also set up the access point such that it successfully sent traffic coming into wlan0 to tun0 (tested by going to ipinfo.io on my phone while connected to raspberry pi wifi network and seeing that i was indeed connected to a VPN server somewhere far far away). But when I got this successfully set up, it stopped me from being able to SSH over LAN at all: no more 192.168.0.222 static ip, and the assigned IP didn't work in putty either.
How can I get this set up to work? I followed these guides for AP and VPN AP respectively: Raspberry Pi Wireless Access Point
I also used a script stored in /etc/ipstartup file, that is run using crontab @reboot:
ip address flush dev eth0 ip address add 192.168.0.222 dev eth0 ip link set eth0 up ip route add default via 192.168.0.1 printf "nameserver 18.104.22.168\nnameserver 22.214.171.124" > /etc/resolv.conf
Note: The above script worked to get my eth0 connection going for the access point without vpn, but no longer kept my static ip (did it's job) when I went forward with trying to set up a VPN wireless AP.
Thanks in advance, and sorry if my unix/ networking lingo is bad!
EDIT: It works now. For anyone that might run into this issue themselves, here's what I did:
reverted all networking files to defaults (dhcpcd.conf, wpa_supplicant, etc.)
Followed this guide on setting up an access point except, and here's the important part, instead of doing step 18 I followed the troubleshooting provided by Ingo in the selected best answer below. Namely the flushing of the iptables section, and the iptables rules they provided.
- I then continued with the AP guide through to the end.
- To maintain my static IP of 192.168.0.222, I continued to use my crontab script that runs at boot.