Can anyone assist with a linux routing question? Essentially I want to use an Ubuntu laptop to provide internet access to an attached network.
I have a Raspberry pi on a wifi network (192.168.42.0/24). Its ip address is 192.168.42.20.
Internet access is provided by a cell phone hotspot. (192.168.43.0/24). The internet gateway is 192.168.43.1
I have a linux laptop (Ubuntu) with two wifi cards - one on each of the above networks. (192.168.42.21 & 192.168.43.10)
I also have another network connected on the ethernet card which successfully shares the internet connection with clients. This network is 10.42.0.0/24. The laptop is a DHCP server in this case and its ip is 10.42.0.1
I am trying to use the laptop to provide an internet access route for the Pi I have added the following iptable rules to the laptop. They are derived from the forwarding rules for the 10.42.0./24 network which as I say can connect to the internet.
-A FORWARD -d 192.168.42.0/24 -o wlx801f0281f02a -m state --state RELATED,ESTABLISHED -j ACCEPT -A FORWARD -s 192.168.42.0/24 -i wlx801f0281f02a -j ACCEPT -A FORWARD -i wlx801f0281f02a -o wlx801f0281f02a -j ACCEPT ip_forwarding is enabled
I have added a route on the Pi. The route table now reads:
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.42.21 0.0.0.0 UG 0 0 0 wlan0 192.168.42.0 0.0.0.0 255.255.255.0 U 303 0 0 wlan0
The Pi can ping through to both the other networks and both other networks can ping through to the Pi.
BUT ... the Pi still doesn't have internet access, although a device on the 10.42.0.117 happily reaches the outside world.
The routing table on 10.42.0.117 is exactly "parallel" to the Pi's:
Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 10.42.0.1 0.0.0.0 UG 0 0 0 eth0 10.42.0.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0 127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
What am I missing?