Raspberry Pi 4 as VPN Router (having trouble)

Hello,

I have an ISP provided modem which I have bridged to my own router. I am endeavouring to place a Rasp Pi 4 (running Openwrt) between these 2 units to provide VPN. I have installed Openwrt onto the Pi. I have basically placed the Pi between the modem and router on the same line that used to go directly from modem to router. So, the modem now plugs into a USB3/Ethernet adapter on the Pi and the router plugs into the regular ethernet outlet on the Pi.

From my PC when I am connected to the router I can see and connect to the Pi (via Luci or Putty), however, the router does not have access to the internet as it did when it was connected directly to the modem. I am assuming that my setup in Openwrt is not quite right. Firstly, I have setup the OpenVPN within OpenWrt as per outlined by my vpn provider (ProtonVPN). The other main things I have setup in OpenWrt are as follows:

LAN Interface
- static address
- IPV4 Address = the address for the Pi
- IPV4 Netmask = 255.255.255.0
- IPV4 Gateway = blank
- IPV4 Broadcast = same as IPV4 Address except last number is replaced with '255'

WAN Interface
- Protocol = DHCP
- send hostname of this device

Can anyone comment on whether I am barking up the right tree on trying to get this going? Is there anything in the interface settings that are obviously incorrect? Any other settings I should be looking at?

Any suggests are very much appreciated. Thank you

Does it work when you disable the VPN ?

it's hard to provide help, since you skipped all the IPs.
Your public IP can be skipped though, or mask it.

1 Like

Thank you for your response. And good idea. I guess I'm not that smart because when I go into luci>VPN>OpenVPN I see that my defined OpenVPN instance isn't running. And, if I try to start it, nothing happens. So it won't start for some reason - maybe because the connection to the internet isn't set right. I suppose the other possibility is that maybe the USB3 Ethernet adapter isn't connecting properly. I got the QGeeM brand but was unable to find any information on things I might need to install on the Pi to make sure it works. I did install kmod-usb-net-asix-ax88179. Is there an easy way to confirm it is working or maybe I just need to buy a make/model that is known to work for sure.

Anyways, with respect to the IP numbers:

RASPBERRY PI
192.168.2.1 (ipv4 address specifically set at that as per some directions I was following)

PI LAN Interface
Protocol - static address
Ipv4 address - 192.168.2.1
Ipv4 netmask - 255.255.255.0
Ipv4 gateway - blank
Ipv4 broadcast - 192.168.2.255
Status - device: br-lan, ipv4: 192.168.2.1/24, ipv6: undefined/0
Advanced settings: use custom dns servers: 192.168.3.1

PI WAN Interface
Protocol - DHCP client
Send the hostname of this device
Status - device: eth0

ROUTER (connected to Pi via eth port)
Int IP - 192.168.3.1
WAN connection type - auto DHCP
Ipv6 - disabled
Ddns - disabled
Operating mode - gateway
WAN config:
IP address: 192.168.2.234
Subnet mask: 255.255.255.0
Gateway: 192.168.2.1
Dns 1: 10.8.0.1
Dns 2: 192.168.2.1

MODEM (connected to Pi via USB port)
Accessed via 192.168.1.254
IP address: 66.xxx.xx.xxx
Subnet mask: 255.255.252.0
Default gateway: 66.xxx.xx.x
Dns address 1: 75.xxx.xxx.1
Dns address 2: 75.xxx.xxx.9

I can't believe I have given so much info - if it is too much to look at I will understand. But maybe you can see an obvious problem.

Thank you in advance for any suggestions.

Check internet connectivity:

ping -q -c 3 8.8.8.8; \
ping -q -c 3 example.org; \
nslookup example.org 8.8.8.8; \
nslookup example.org; \
traceroute example.org

Then check the VPN connection logs.

None of these pings were successful. Network unreachable. Also, not sure where to find the vpn logs. Maybe they don't exist because the vpn doesn't seem to be running (when I press start nothing happens)

1 Like

Hi guys, I'm struggling with the exact same setup though I'm trying with the RPi4 between my computer ethernet port and the router LAN port for testing before setting it up between the router and the modem;

About the VPN connection, I had the same problem before with it not starting, it was because the OVPN connection asked for username and password, which I didn't provide.

There are instructions for it here: [OpenWrt Wiki] OpenVPN client using LuCI

Other than that, my current setup was working up untill I set up the VPN, ping and traceroute works on the Luci interface, but the computer can't connect to anything else than the router.

What could I be missing?

Thanks for the info. Can I ask what make/model of USB3/Ethernet adapter you are using? And did you have to install anything in particular on the Pi for it to function? Actually, maybe you aren't having to use the USB port yet?

I'm using a chinese gigabit usb adapter with no brand on it, bought on the internet, I installed kmod-usb-net and kmod-usb-net-asix-ax88179 for it to work;

I started by configuring the Rpi to get the internet by connecting to the wi-fi from the router, but after downloading the packages, I connected through the cable on the USB adapter, and had a few problems with the Rpi being able to ping sites but the computer couldn't reach the internet; But I managed to make it able to connect after setting up option netmask '255.255.255.0'
option gateway '192.168.0.1' (That's my router IP, the openwrt IP still is 192.168.1.1)
on /etc/config/network.

My only problem now is that whenever I start the openVPN connection, it can't reach the internet again, I'm trying to find out what do I have to do

EDIT: Here's a picture of the adapter: image

I guess a good first step for me is to at least get the arrangement working (modem <-> Pi <-> router) without VPN, then I can try to figure out why the vpn isn't working. I am probably in over my head on this one - I thought I could follow these instructions I found on the internet (instructables.com) and everything would work. However, I did deviate from the instruction on one they - it was setting up for wireguard VPN while I was just going to stick with the OpenVPN. I did order a new TP-Link adapter to see if I have any more luck with that. My various settings may be off though (as I am no expert on that).

Thanks for the info and adapter picture

I got a new usb3 ethernet adapter today - a tp-link. So at this point I have the pi plugged into modem (via this new adapter) then I have the pi ethernet port going to my router. So the pi is wired between modem and router. From another computer I can connect to the router although there is not internet. I can also connect to the pi via the router (putty or luci). At the pi terminal a ping 0.0.0.0 produces continuous connections in ms (I assume this means it is getting out to the internet?). If that's the case then the adapter must be working. But you can't get internet via the router. What settings should I be checking to get router communicating through pi to internet? The IP of pi is 192.168.2.1. On the router the gateway is showing same number (192.168.2.1), dns1 is 10.8.0.1 and dns2 is the 192.168.2.1 number again.

Furthermore, the network interface settings found via luci on the pi are as follows:

LAN
Device - br-lan
Protocol - static address
IPv4 - 192.168.2.1
IPv4 netmask - 255.255.255.0
IPv4 gateway - blank
IPv4 broadcast - 192.168.2.255

WAN
Device - eth0
Protocol - DHCP client
Hostname to send - send name of this device

I know that's a lot of info. Is anyone able to suggest what settings I might need to change/adjust? Anything obvious?

Many thanks to anyone willing to comment. Thank you.

Actually, I realize I was probably checking internet connectivity from pi terminal incorrectly. This time I executed "ping 8.8.8.8". The response I received was 'network unreachable'. So perhaps this new tp-link not working?

On your router the dns should just point to the pi, meaning just 192.168.2.1 in your case, and the Surfshark dns, 10.8.0.1 should be in wan of the pi. The ipv4 gateway of the pi being blank seems a little strange, so just to make sure, the wire from the modem should go to the pi's built in port (lan) and the wire from the pi to the router should go from the tp-link USB adapter to one of the 4 lan ports on the router. If that still doesn't work, using the vpn client guide for the pi and the dumb ap guide for the router is what I used (I have the same setup, modem>pi>router) and it's working, the only thing you would need to change is putting the Surfshark dns in the wan of the pi, that should get it running.

Thank you so much for the feedback and suggestions. I will definitely try this out tomorrow. This evening I did find something online that suggested I may also need to install another driver into the pi to enable the adapter. So I connected the router back to the modem (to gain access to the internet) and left the pi connected to router (so that I could gain access to the internet from router and install driver into the pi). However, I couldn't for the life of me connect to the pi from my computer anymore via connecting to router (even though this is how I had it connected previously so as to gain access to internet from the pi). For whatever reason I can no longer connect to the pi from a computer that is connected to router. Hoping to have better luck tomorrow connecting back into the pi so that I can update the driver and try your suggestions.

I am now having a small problem that I cannot figure out. If you have a suggestion let me know. I had been able to connect to the pi from my computer via the modem (when the pi was plugged into modem). for some reason now I cannot make a connection to the pi through the modem. The pi's ipv4 address was set to 192.168.2.1 and since that setting was made I could connect to it from my pc via the modem (until now). I can plug the pi directly into the computer and access via that address but not when it is plugged into modem. Again, it was working yesterday and before.

If by via modem you mean the modem is now acting as a modem/router and the pi an access point, giving the pi a static ip (192.168.2.1) in the modem and rebooting should bring back access, if the modem is still bridged and you haven't made any other changes I'm not sure, I just did a quick test on mine (changing lan ip to 192.168.2.1) and was able to connect ok

sorry, i meant router not modem. I connect pi to the router and then also connect into the same router with my pc. in this way i was able to connect to the pi via 192.168.2.1 with my computer. this gave my pi access to the internet to download drivers etc (because the router is wired to the modem). however, no longer can i connect to the pi. in fact the router seems to be showing it as a different IP (192.168.3.108). Nevertheless I cannot connect to the pi from my computer via 192.168.2.1 or 192.168.3.108.

Sorry, I'm a little lost at this point, it sounds like you've changed your setup from modem>pi>router to modem>router>pi (router is wired to modem), I'd suggest resetting and following the vpn client and dumb ap wikis I linked above using the the modem>pi>router setup.

1 Like

at this point all i am trying to do is get the pi connected to the internet so i can update the drivers (for the usb/ethernet adapter). So I am trying to do what I have already done before and that is simply attach pi to router so that I can connect to it from my pc and update luci. So in this case leave router attached to modem (for access to internet), connect pi to modem and access/update pi from computer via modem. once i get the pi properly updated i will go back to putting it between modem and router.

What do you currently have installed for the tp link adapter? The packages you need are kmod-usb-net and kmod-usb-net-rtl8152, if those are installed you're good to go. If they're not installed, the easiest way to install would be to use your comp/router to download them, then install them to your pi offline (disconnect comp from router/modem, connect it to pi) using winscp to transfer them to the /tmp file of the pi and use opkg to install. If that's the case, first check the version of Openwrt you have on the pi (luci>status>overview), if it's just Snapshot and you installed it before April 14, you'll need to download and install the latest Snapshot first (packages won't install due to kernel mismatch otherwise). Once you've done that, you can download the two packages here, transfer them to the pi with winscp, ssh into the pi and run these two commands -

cd /tmp
opkg install kmod-usb-net kmod-usb-net-rtl8152

Sounds more complicated than it actually is.

yes, that is the package I found out that i needed - the kmod-usb-net-rtl8152. I will try your method noted here to get it onto the pi (i know i can connect to the pi directly to computer). Thanks for the suggestion!