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 server's IP address is 10.10.10.83, and the local network subnet is 10.10.10.0/24
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.
My issues arise are:
- Once connected to the OpenVPN-pi, all devices connected to the hotspot-pi loose internet access. -> no longer an issue
- piHotspot can ping 10.8.0.1(PiVPNServer) ONLY, PiVPNServer can ping ANYONE in the PiHotspot network. ONLY VPNServer can ping attached devices to the client's network. I still can't ping from server's network's devices
What's left to do:
- Re-allow internet access to devices connected to the Hotspot-pi while it is connected to VPN. -> done
- 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/24 brd 10.10.10.255 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::ba27:ebff:fefa:a5b9/64 scope link
valid_lft forever preferred_lft forever
4: 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 peer 10.8.0.2/32 scope global tun0
valid_lft forever preferred_lft forever
inet6 fe80::c367:82ee:1948:743b/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 proto static
10.8.0.2 dev tun0 proto kernel scope link src 10.8.0.1
10.10.10.0/24 dev eth0 proto kernel scope link src 10.10.10.83
192.168.50.0/24 via 10.8.0.2 dev tun0
Result of systemctl status [email protected]
● [email protected] - OpenVPN connection to server
Loaded: loaded (/lib/systemd/system/[email protected]; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-11-21 23:13:32 EST; 1min 48s ago
Docs: man:openvpn(8)
https://community.openvpn.net/openvpn/wiki/Openvpn24ManPage
https://community.openvpn.net/openvpn/wiki/HOWTO
Main PID: 1750 (openvpn)
Status: "Pre-connection initialization successful"
Tasks: 1 (limit: 2200)
Memory: 1.0M
CGroup: /system.slice/system-openvpn.slice/[email protected]
└─1750 /usr/sbin/openvpn --daemon ovpn-server --status /run/openvpn/server.status 10 --cd /etc/openvpn --config /etc/openvpn/server.conf --writepid /run/openvpn/server.pid
Nov 21 23:13:32 PiVPNServer ovpn-server[1750]: disabling NCP mode (--ncp-disable) because not in P2MP client or server mode
Nov 21 23:13:32 PiVPNServer ovpn-server[1750]: OpenVPN 2.4.7 arm-unknown-linux-gnueabihf [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [PKCS11] [MH/PKTINFO] [AEAD] built on Feb 20 2019
Nov 21 23:13:32 PiVPNServer systemd[1]: Started OpenVPN connection to server.
Nov 21 23:13:32 PiVPNServer ovpn-server[1750]: library versions: OpenSSL 1.1.1d 10 Sep 2019, LZO 2.10
Nov 21 23:13:32 PiVPNServer ovpn-server[1750]: TUN/TAP device tun0 opened
Nov 21 23:13:32 PiVPNServer ovpn-server[1750]: /sbin/ip link set dev tun0 up mtu 1500
Nov 21 23:13:32 PiVPNServer ovpn-server[1750]: /sbin/ip addr add dev tun0 local 10.8.0.1 peer 10.8.0.2
Nov 21 23:13:32 PiVPNServer ovpn-server[1750]: Could not determine IPv4/IPv6 protocol. Using AF_INET
Nov 21 23:13:32 PiVPNServer ovpn-server[1750]: UDPv4 link local (bound): [AF_INET][undef]:1194
Nov 21 23:13:32 PiVPNServer ovpn-server[1750]: UDPv4 link remote: [AF_UNSPEC]
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: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast master br0 state DOWN 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: 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 peer 10.8.0.1/32 scope global tun0
valid_lft forever preferred_lft forever
inet6 fe80::31c0:593e:d389:b8b7/64 scope link flags 800
valid_lft forever preferred_lft forever
6: ppp0: <POINTOPOINT,MULTICAST,NOARP,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UNKNOWN group default qlen 3
link/ppp
inet 25.108.227.234/32 scope global ppp0
valid_lft forever preferred_lft forever
Result of ip route on piHotspot (client):
default via 25.108.227.234 dev ppp0 proto static
10.8.0.1 dev tun0 proto kernel scope link src 10.8.0.2
10.10.10.0/24 via 10.8.0.1 dev tun0
10.176.0.0/16 via 25.108.227.234 dev ppp0 proto static
10.254.0.0/16 via 25.108.227.234 dev ppp0 proto static
192.168.50.0/24 dev br0 proto kernel scope link src 192.168.50.1
I think here there should be a call to my server's ip address no?
Result of systemctl status [email protected]
● [email protected] - OpenVPN connection to piHotspot
Loaded: loaded (/lib/systemd/system/[email protected]; enabled; vendor preset: enabled)
Active: active (running) since Thu 2019-11-21 23:20:13 EST; 7s ago
Docs: man:openvpn(8)
https://community.openvpn.net/openvpn/wiki/Openvpn23ManPage
https://community.openvpn.net/openvpn/wiki/HOWTO
Process: 739 ExecStart=/usr/sbin/openvpn --daemon ovpn-piHotspot --status /run/openvpn/piHotspot.status 10 --cd /
Main PID: 740 (openvpn)
Tasks: 1 (limit: 4915)
CGroup: /system.slice/system-openvpn.slice/[email protected]
└─740 /usr/sbin/openvpn --daemon ovpn-piHotspot --status /run/openvpn/piHotspot.status 10 --cd /etc/open
Nov 21 23:20:13 RPiNet systemd[1]: Starting OpenVPN connection to piHotspot...
Nov 21 23:20:13 RPiNet systemd[1]: Started OpenVPN connection to piHotspot.
Nov 21 23:20:13 RPiNet ovpn-piHotspot[740]: TUN/TAP device tun0 opened
Nov 21 23:20:13 RPiNet ovpn-piHotspot[740]: do_ifconfig, tt->did_ifconfig_ipv6_setup=0
Nov 21 23:20:13 RPiNet ovpn-piHotspot[740]: /sbin/ip link set dev tun0 up mtu 1500
Nov 21 23:20:13 RPiNet ovpn-piHotspot[740]: /sbin/ip addr add dev tun0 local 10.8.0.2 peer 10.8.0.1
Nov 21 23:20:13 RPiNet ovpn-piHotspot[740]: TCP/UDP: Preserving recently used remote address: [AF_INET][My IP Address]
Nov 21 23:20:13 RPiNet ovpn-piHotspot[740]: UDP link local (bound): [AF_INET][undef]:1194
Nov 21 23:20:13 RPiNet ovpn-piHotspot[740]: UDP link remote: [AF_INET][My IP Address]:1194
Update: Nov 21, 2019
I am able to ping server and client from each other using the 10.8.0.0 subnets (10.8.0.1 10.8.0.2).
I have gained the ability to ping from the VPNServer to any device attached to the VPNClient (PiHotspot).
I have gained the ability to ssh to the VPNClient's attached devices and control them
I have gained internet connection back from attached devices while the VPN is enabled in the client.
I cannot ping from devices in the Client or the Client itself to the attached devices in the server's side, I can only ping the server.
This is my server.conf before the error. Once I changed the 192.168.50.1 to 192.168.50.0, I became a step closer to a finished result :)
dev tun
ifconfig 10.8.0.1 10.8.0.2
secret static.key
cipher AES-256-CBC
auth-nocache
route 192.168.50.1 255.255.255.0
This is the 04-eth.network file on the server:
[Match]
Name=e*
[Network]
Address=10.10.10.83/24
Gateway=10.10.10.1
DNS=84.200.69.80 1.1.1.1
IPForward=yes
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!