I am struggling to establish a network route from my laptop to another device. I will admit that my networking background is lacking, so sorry for the ignorance. I have the following setup:
[Device-A] <--WiFi--> [router] <--WiFi--> [Device-B] <--Ethernet--> [Device-C]
I have the following IP addresses (which were configured automatically):
Device-A:
Device-B:
- wifi: 192.168.0.121
- ethernet: 10.42.0.1
Device-C:
All devices are using Ubuntu 20.04. I configured the wired connection between Device-B and Device-C on Device-B using network manager GUI with IPv4 Method set to "Share to other computers". All other settings were left at defaults. On Device-A, I tried to set a route to Device-C using:
sudo ip route add 10.42.0.0/24 via 192.168.0.121 dev wlo1
Device-C is able to ping Device-A and Device-A can ping Device-B at both 192.168.0.121 and 10.42.0.1. However, when I try to ping Device-C from Device-A I get:
$ ping 10.42.0.134
PING 10.42.0.134 (10.42.0.134) 56(84) bytes of data.
From 192.168.0.121 icmp_seq=1 Destination Port Unreachable
How can a configure the devices so that Device-A is able to talk to Device-C? This seems like something that should be fairly simple but I have not been able to figure it out.
Update
Forwarding is enabled on B
$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
Here are my iptables
rulesets on B:
$ sudo iptables -L -n -v
Chain INPUT (policy ACCEPT 20319 packets, 21M bytes)
pkts bytes target prot opt in out source destination
6 2236 ACCEPT udp -- eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:67
0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:67
12 863 ACCEPT udp -- eth0 * 0.0.0.0/0 0.0.0.0/0 udp dpt:53
0 0 ACCEPT tcp -- eth0 * 0.0.0.0/0 0.0.0.0/0 tcp dpt:53
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
193 33179 ACCEPT all -- * eth0 0.0.0.0/0 10.42.0.0/24 state RELATED,ESTABLISHED
201 19734 ACCEPT all -- eth0 * 10.42.0.0/24 0.0.0.0/0
0 0 ACCEPT all -- eth0 eth0 0.0.0.0/0 0.0.0.0/0
9 756 REJECT all -- * eth0 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
0 0 REJECT all -- eth0 * 0.0.0.0/0 0.0.0.0/0 reject-with icmp-port-unreachable
Chain OUTPUT (policy ACCEPT 18275 packets, 2577K bytes)
pkts bytes target prot opt in out source destination
$ sudo iptables -L -n -v -t nat
Chain PREROUTING (policy ACCEPT 577 packets, 172K bytes)
pkts bytes target prot opt in out source destination
Chain INPUT (policy ACCEPT 59 packets, 4904 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 476 packets, 67069 bytes)
pkts bytes target prot opt in out source destination
Chain POSTROUTING (policy ACCEPT 468 packets, 65733 bytes)
pkts bytes target prot opt in out source destination
178 14264 MASQUERADE all -- * * 10.42.0.0/24 !10.42.0.0/24
I have not configured any firewall rules on B.