I have a Raspberry Pi 3B+ which is working as a hotspot using a Hologram Nova usb ppp0 device where it receives Internet from and routes the internet through WiFi and Ethernet. This Hologram usb ppp0 device does not allow port forwarding so can't play around with ports on it.
I have realized that the IP address on the hotspot-pi changes every time the hotspot-pi reboots, Given that it's a mobile SIM, the cellphone company does not assign a permanent IP address. This makes it very hard or impractical to connect through SSH or access the local network.
The hotspot-pi's local IP address is 192.168.50.1; and it uses a bridge with a range of 192.168.50.0/24 that work or route both wlan0 and eth0 interfaces. All devices connected to the hotspot via wlan0 or eth0 obtain an ip in the range of the 192.168.50.0/24.
I created a home VPN using OpenVPN and a second raspberry pi (different Pi, located at home and acting as a server), and have the hotspot-pi connect to the OpenVPN-pi (at home) using OpenVPN as a client.
The purpose of this is so that once the hotspot-pi is connected to the OpenVPN-pi, I can see the hotspot-pi and all the other devices connected to it on my local network at home (OpenVPN-pi) using either FING (phone app) or nmap (linux) or any type of ip scanner application.
Edit: I have Completed part 1, 2 and 3 of Ingo's Answer. I get OpenVPN to start and connect to the server successfully. However where my issues arise are:
- Once connected to the OpenVPN-pi, all devices connected to the hotspot-pi loose internet access.
- Only the hotspot-pi is able to ping the OpenVPN-pi at 10.8.0.1 or any IP's in the server's local network
- Only the hotspot-pi retains the ability to connect to internet
What's left to do:
- Re-allow internet access to devices connected to the Hotspot-pi while it is connected to VPN.
- Allow devices in the server side network (OpenVPN-pi at home) to see devices attached to hotspot-pi (client VPN side on the field)
- The ability to ping or ssh from any device on the server side to any devices on the client side.
I have done a bit more research:
I now know, that I need to do a type of bridging or layer 2 vpn. and I have found some information about it: OpenVPN bridged vpn
However with this new given information I know that if I try to simply implement it, it will definitely break something else. I am not a network engineer nor do I have the tremendous experience with networks, so I would greatly appreciate if someone experienced would be able to explain this a bit better for me.
Current settings on the client vpn hotspot-pi:
Result of ip addr on the PiVPN Server:
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether b8:27:eb:fa:a5:b9 brd ff:ff:ff:ff:ff:ff
inet 10.10.10.83/8 brd 10.255.255.255 scope global noprefixroute eth0
valid_lft forever preferred_lft forever
inet6 fe80::d187:36d0:fc8e:f762/64 scope link
valid_lft forever preferred_lft forever
3: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
link/none
inet 10.8.0.1/24 brd 10.8.0.255 scope global tun0
valid_lft forever preferred_lft forever
inet6 fe80::48a1:44d3:21b8:577e/64 scope link stable-privacy
valid_lft forever preferred_lft forever
Result of ip route in the PiVPN server:
default via 10.10.10.1 dev eth0 src 10.10.10.83 metric 202
10.0.0.0/8 dev eth0 proto dhcp scope link src 10.10.10.83 metric 202
10.8.0.0/24 dev tun0 proto kernel scope link src 10.8.0.1
Result of ip addr in piHotspot (client):
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
link/ether b8:27:eb:3f:0e:89 brd ff:ff:ff:ff:ff:ff
3: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
link/ether 8a:ea:17:87:3f:87 brd ff:ff:ff:ff:ff:ff
inet 192.168.50.1/24 brd 192.168.50.255 scope global br0
valid_lft forever preferred_lft forever
inet6 fe80::88ea:17ff:fe87:3f87/64 scope link
valid_lft forever preferred_lft forever
4: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master br0 state UP group default qlen 1000
link/ether b8:27:eb:6a:5b:dc brd ff:ff:ff:ff:ff:ff
inet6 fe80::ba27:ebff:fe6a:5bdc/64 scope link
valid_lft forever preferred_lft forever
5: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 3
link/ppp
inet 25.109.132.138/32 scope global ppp0
valid_lft forever preferred_lft forever
6: tun0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 100
link/none
inet 10.8.0.2/24 brd 10.8.0.255 scope global tun0
valid_lft forever preferred_lft forever
inet6 fe80::2d59:9bc:22c1:42f3/64 scope link flags 800
valid_lft forever preferred_lft forever
Result of ip route on piHotspot (client):
0.0.0.0/1 via 10.8.0.1 dev tun0
default via 25.109.132.138 dev ppp0 proto static
10.8.0.0/24 dev tun0 proto kernel scope link src 10.8.0.2
10.176.0.0/16 via 25.109.132.138 dev ppp0 proto static
10.254.0.0/16 via 25.109.132.138 dev ppp0 proto static
(my IP xx.xxx.xx.xxx) via 25.109.132.138 dev ppp0
128.0.0.0/1 via 10.8.0.1 dev tun0
192.168.50.0/24 dev br0 proto kernel scope link src 192.168.50.1
Update: Nov 14, 2019
I am able to ping server and client from each other, I can ping devices attached to the server's local network but I cannot ping devices attached to the hotspot network. I'd prefer it the other way for my specific use. In fact I'd like to be able to ssh or control any devices in the client's network from the server. Devices attached to the client loose internet connection when I establish the vpn tunnel. The moment I stop the service, internet is back up.
Lastly, in the client/server files, they both have a tun set not a tap, won't this explain why I can't get an IP Address the same as my server's local network?
As always, I would greatly appreciate any and all help! I feel I'm so close to finishing this project I'm at the end of the line!
Thank you kindly!