Score:2

Ping device connected to host having LAN access

wf flag

I've been playing back and forth routing games for a couple of days.

As it is quite hard to describe with words I made a diagram below:

Network diagram

What I want to achieve is being able to ping Rpi 4B from Rpi 3B and vice versa. However, with the default setup I'm only able to reach Host A eth0 from Rpi 3B eth0.

NOTE: I don't have any control over the router. So all routing/forwarding should happen within Host A/B and Rpi 3B/4B.

Below are steps I made which took me bit further but I don't know if there are correct:

  1. Set routing rule on Host A, which allowed me to reach Host B eth1 from Rpi 3B eth0:

    sudo ip route add 192.168.10.0/24 via 192.168.18.70

  2. Set routing rule on Host B, which allowed me to reach Host A eth1 from Rpi 4B eth0:

    sudo ip route add 192.168.11.0/24 via 192.168.18.69

But I'm still not able to ping Rpi 3B eth0 <--> eth0 Rpi 4B. Any suggestions and explanations most welcomed?

EDIT: Configuration host A(and respectively for host B):

user@localhost:~$ ip a
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 mq state UP group default qlen 1000
    link/ether 00:04:9f:07:3a:df brd ff:ff:ff:ff:ff:ff
    inet 192.168.18.69/24 brd 192.168.18.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::204:9fff:fe07:3adf/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:04:9f:07:3a:e0 brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.1/24 brd 192.168.11.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::204:9fff:fe07:3ae0/64 scope link
       valid_lft forever preferred_lft forever
4: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:a1:01:e8:50 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
user@localhost:~$ ip route
default via 192.168.18.1 dev eth0
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
192.168.10.0/24 via 192.168.18.70 dev eth0
192.168.11.0/24 dev eth1 proto kernel scope link src 192.168.11.1
192.168.18.0/24 dev eth0 proto kernel scope link src 192.168.18.69
user@localhost:~$ ip a
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 mq state UP group default qlen 1000
    link/ether 00:04:9f:07:3a:39 brd ff:ff:ff:ff:ff:ff
    inet 192.168.18.70/24 brd 192.168.18.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::204:9fff:fe07:3a39/64 scope link
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether 00:04:9f:07:3a:3a brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.1/24 brd 192.168.10.255 scope global eth1
       valid_lft forever preferred_lft forever
    inet6 fe80::204:9fff:fe07:3a3a/64 scope link
       valid_lft forever preferred_lft forever
4: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000
    link/sit 0.0.0.0 brd 0.0.0.0
5: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:b0:5e:9a:50 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
user@localhost:~$ ip r
default via 192.168.18.1 dev eth0
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
192.168.10.0/24 dev eth1 proto kernel scope link src 192.168.10.1
192.168.11.0/24 via 192.168.18.69 dev eth0
192.168.18.0/24 dev eth0 proto kernel scope link src 192.168.18.70

Configuration Rpi 3B (and respectively for Rpi 4B):

user@raspberrypi3:~ $ ip a
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:53:e4:ef brd ff:ff:ff:ff:ff:ff
    inet 192.168.11.100/24 brd 192.168.11.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 169.254.215.51/16 brd 169.254.255.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::389a:40b4:ec75:7634/64 scope link
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether b8:27:eb:06:b1:ba brd ff:ff:ff:ff:ff:ff
    inet 192.168.18.48/24 brd 192.168.18.255 scope global dynamic noprefixroute wlan0
       valid_lft 212378sec preferred_lft 179978sec
    inet6 fe80::160d:2dd3:e73d:d65c/64 scope link
       valid_lft forever preferred_lft forever
user@raspberrypi3:~ $ ip r
default via 192.168.11.1 dev eth0 onlink
default via 192.168.18.1 dev wlan0 proto dhcp src 192.168.18.48 metric 303
169.254.0.0/16 dev eth0 scope link src 169.254.215.51 metric 202
192.168.11.0/24 dev eth0 proto kernel scope link src 192.168.11.100
192.168.18.0/24 dev wlan0 proto dhcp scope link src 192.168.18.48 metric 303
user@raspberrypi4:~ $ ip a
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 mq state UP group default qlen 1000
    link/ether dc:a6:32:7a:7b:bf brd ff:ff:ff:ff:ff:ff
    inet 192.168.10.150/24 brd 192.168.10.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet 169.254.58.248/16 brd 169.254.255.255 scope global noprefixroute eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::bf3:d533:b50a:cf7a/64 scope link
       valid_lft forever preferred_lft forever
3: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether dc:a6:32:7a:7b:c1 brd ff:ff:ff:ff:ff:ff
    inet 192.168.18.33/24 brd 192.168.18.255 scope global dynamic noprefixroute wlan0
       valid_lft 209358sec preferred_lft 176958sec
    inet6 fe80::368:6092:4094:328c/64 scope link
       valid_lft forever preferred_lft forever
user@raspberrypi4:~ $ ip r
default via 192.168.10.1 dev eth0
default via 192.168.18.1 dev wlan0 proto dhcp src 192.168.18.33 metric 303
169.254.0.0/16 dev eth0 scope link src 169.254.58.248 metric 202
192.168.10.0/24 dev eth0 proto kernel scope link src 192.168.10.150
192.168.18.0/24 dev wlan0 proto dhcp scope link src 192.168.18.33 metric 303

Following configuration enables green marked pings. Diagram concerns only left side of diagram, but same behavior applies to right side as well. Ping diagram

pt flag
I've updated my answer to not require any changes on the router.
pt flag
Host rpi3b appears to have two default routes (and an interface on the 192.168.18.0/24 network). You didn't show that on your network diagram. Shut down interface `wlan0` and see if that changes the behavior.
Ogy89 avatar
wf flag
Excuses for not pointing it out, wasn't aware it is relevant. wlan0 was used for ssh. Used "ip link set wlan0 down" but still I'm not able to ping rpi 4B, nor I'm able to ping from Host A eth1 to Host B eth1.
pt flag
You can ssh in from hostA. Does disabling `wlan0` on `rpi3b` allow it to ping hostA? What about hostB?
Ogy89 avatar
wf flag
No. I'm not able to ping eth0 on hostA, but that fore I didn't have to disable wlan0 (however I did that to check) as I was already using 'ping -I eth0 192.168.18.69' from rpi3b. I'm not even I'm able to ping from Host A eth1 to Host B eth1.
pt flag
This may be a dumb question, but do your hosts have ip forwarding enabled? Check the value of the `net.ipv4.ip_forward` sysctl and make sure it is `1` (in particular on hostA and hostB).
Ogy89 avatar
wf flag
net.ipv4.ip_forward is set to 1. I have to correct myself a bit as I'm able to ping from hostA eth1 to hostB eth1 but with using IP address of hostA, instead of ifcae name. E.g. this works 'ping -I 192.168.11.1 192.168.10.1', while 'ping -I eth1 192.168.10.1' doesn't.
pt flag
Please stop using `ping -I`. Does it work without the `-I`?
Ogy89 avatar
wf flag
Ok. Was using -I because having multiple ifaces on host devices. Ping works from hostA eth1 to hostB eth1. Also to correct my previous statement ping of hostA eth1 from rpi3b works even when wlan0 off.
Score:1
pt flag

Even without the ability to modify the configuration on the router, this is still just a routing problem.

I've simulated your network topology in mininet using this code:

from mininet.cli import CLI
from mininet.net import Mininet
from mininet.node import OVSBridge
from mininet.topo import Topo
from mininet.log import info, error, setLogLevel

class HomeNetwork(Topo):
    def build(self):
        s0 = self.addSwitch('s0')

        router = self.addHost('router', ip='192.168.18.1/24')
        hostA = self.addHost('hostA', ip='192.168.18.69/24')
        hostB = self.addHost('hostB', ip='192.168.18.70/24')
        rpi3b = self.addHost('rpi3b', ip='192.168.11.100/24')
        rpi4b = self.addHost('rpi4b', ip='192.168.10.150/24')

        self.addLink(router, s0)
        self.addLink(hostA, s0)
        self.addLink(hostB, s0)

        self.addLink(rpi3b, hostA, params2=dict(ip='192.168.11.1/24'))
        self.addLink(rpi4b, hostB, params2=dict(ip='192.168.10.1/24'))


topos = {"home": HomeNetwork}

We start up the simulated environment like this:

sudo mn --custom homenetwork.py --topo home

Because we're not actually using DHCP in this example, none of our hosts have appropriate routes, so let's populate the necessary default routes around the network:

mininet> hostA ip route add default via 192.168.18.1
mininet> hostB ip route add default via 192.168.18.1
mininet> rpi3b ip route add default via 192.168.11.1
mininet> rpi4b ip route add default via 192.168.10.1

With this in place, we should to be able to ping hostA from rpi3b:

mininet> rpi3b ping -c1 hostA
PING 192.168.18.69 (192.168.18.69) 56(84) bytes of data.
64 bytes from 192.168.18.69: icmp_seq=1 ttl=64 time=0.032 ms

--- 192.168.18.69 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.032/0.032/0.032/0.000 ms

We want to be able to reach rpi4b (192.168.10.150) from rpi3b. If we try that right now, it won't work:

  • rpi3b doesn't have a direct route to 192.168.10.0/24, so it sends traffic via its default route (which is hostA)
  • hostA doesn't have a direct route to 192.168.10.0/24, so it sends traffic via its default route (which is the isp router)
  • The isp router doesn't have a direct route to 192.168.10.0/24, so it effectively drops the traffic.

The easiest solution here is just to take the isp router out of the equation.

We can add a route from hostA to the 192.168.10.0/24 network via hostB:

mininet> hostA ip route add 192.168.10.0/24 via 192.168.18.70

And a route from hostB to the 192.168.11.0/24 network via hostA:

mininet> hostB ip route add 192.168.11.0/24 via 192.168.18.69

With these routes in place, rpi3b can reach rpi4b without a problem:

mininet> rpi3b ping -c2 rpi4b
PING 192.168.10.150 (192.168.10.150) 56(84) bytes of data.
64 bytes from 192.168.10.150: icmp_seq=1 ttl=62 time=0.037 ms
64 bytes from 192.168.10.150: icmp_seq=2 ttl=62 time=0.043 ms

--- 192.168.10.150 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1003ms
rtt min/avg/max/mdev = 0.037/0.040/0.043/0.003 ms

And the reverse is also true:

mininet> rpi4b ping -c2 rpi3b
PING 192.168.11.100 (192.168.11.100) 56(84) bytes of data.
64 bytes from 192.168.11.100: icmp_seq=1 ttl=62 time=0.474 ms
64 bytes from 192.168.11.100: icmp_seq=2 ttl=62 time=0.043 ms

--- 192.168.11.100 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1005ms
rtt min/avg/max/mdev = 0.043/0.258/0.474/0.215 ms

After running the above commands, routes on hostA look like:

mininet> hostA ip route
default via 192.168.18.1 dev hostA-eth0
192.168.10.0/24 via 192.168.18.70 dev hostA-eth0
192.168.11.0/24 dev hostA-eth1 proto kernel scope link src 192.168.11.1
192.168.18.0/24 dev hostA-eth0 proto kernel scope link src 192.168.18.69

And on hostB look like:

mininet> hostB ip route
default via 192.168.18.1 dev hostB-eth0
192.168.10.0/24 dev hostB-eth1 proto kernel scope link src 192.168.10.1
192.168.11.0/24 via 192.168.18.69 dev hostB-eth0
192.168.18.0/24 dev hostB-eth0 proto kernel scope link src 192.168.18.70
Ogy89 avatar
wf flag
thx for the assist. Well I did exactly follow your steps, and while routing table on hostA/B side match yours I'm still not able to ping rpi3b from rpi4b and vice versa. The furthest I've come when starting from rpi3b is hostA eth0, I can not even ping router's IP address (unless I use forwarding rules described in original post). When using traceroute on rpi3b: traceroute -i eth0 192.168.18.1 -> only 192.168.11.1 returned traceroute -i eth0 192.168.18.69 -> only 192.168.18.69 returned
pt flag
You're not going to be able to ping the router with this solution (the router doesn't know how to talk to either 192.168.10.0/24 or 192.168.11.0/24). Everything else here is pretty straightforward. Make sure you've removed any NAT rules or other firewall changes you made earlier. Apply `tcpdump` liberally on your interfaces to see where packets are getting stuck.
Ogy89 avatar
wf flag
When from rpi3B "ping -I eth0 192.168.10.150", I used tcpdump with option "dst 192.168.10.150" on all other ifaces. Only place I caught ICMP echo request was on hostA eth1. It didn't even reach eth0 on hostA as it should per routing tables. I'm using LSDK built around Ubuntu 18.04 and LS1012A-FRWY dev boards as hostA/B.
pt flag
Try to avoid setting `dst` or `src` arguments with `tcpdump`, because if you're hitting erroneous NAT rules or something you won't catch it. Just run something like `tcpdump -i any icmp` (and don't use `ping -I` either; drop the `-I` and let your routing table pick an appropriate interface).
Ogy89 avatar
wf flag
Same result as beforehand. Just checked. Firewall disabled and NAT rules seems nothing related to hostA eth1 nor eth0: # Generated by iptables-save v1.6.1 on Tue Oct 18 19:57:18 2022 *nat :PREROUTING ACCEPT [2766:273024] :INPUT ACCEPT [1009:119877] :OUTPUT ACCEPT [43:3479] :POSTROUTING ACCEPT [43:3479] :DOCKER - [0:0] -A PREROUTING -m addrtype --dst-type LOCAL -j DOCKER -A OUTPUT ! -d 127.0.0.0/8 -m addrtype --dst-type LOCAL -j DOCKER -A POSTROUTING -s 172.17.0.0/16 ! -o docker0 -j MASQUERADE -A DOCKER -i docker0 -j RETURN COMMIT
pt flag
I suspect a typo in your configuration; there's really nothing complex going on here. If I could move this conversation to chat I would ask for some additional details, but the comments aren't a good place for it. I'm hoping that if we get a few more comments in here we'll be prompted for that option.
pt flag
Here, let's try this. If you're around, see if you can join me [here](https://chat.stackexchange.com/rooms/139954/ping-device-connected-to-host-having-lan-access).
Ogy89 avatar
wf flag
Unfortunately, can not use chat. Supposedly I lack reputation points.
pt flag
Yeah, that is unfortunate. Could you update your question to include, at the bottom, the output of `ip a` and `ip route` on `rpi3b` and the same information for `hostA`?
Ogy89 avatar
wf flag
Edited my original post
I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.