I have an Ubuntu host with two ethernet interfaces, one connected to the internet, the other connected to a Raspberri Pi.
Goal: reach the Raspberri Pi from my container (ping 169.254.1.25). I can not use Docker's host network because it conflicts with other requirements I have.
These are the relevant IPs I am testing:
192.168.178.1my router in the WLAN192.168.178.155my host in my WLAN169.254.1.25my Raspberri Pi connected to an ethernet interface in the linux host169.254.1.100: the second eth interface in my host (the one connected to the Raspberri pi)8.8.8.8: a known internet host172.70.0.1: docker0 on the host (bridge created by docker)172.70.0.2: veth on the container (created by docker)
The Ubuntu host can ping everything:
- my router (
192.168.178.1) - itself (both
169.254.1.100and192.168.178.155) - the Raspberri Pi (
169.254.1.25) - the
8.8.8.8
My docker container, started in the default manner (Docker attaches the docker0 bridge), gets the following interfaces:
- eth0:
172.70.0.2 - lo:
127.0.0.1
The container can ping:
- itself (
127.0.0.1and172.70.0.2) - my router (
192.168.178.1) - the docker0 bridge (
172.70.0.1) - the host as seen on WLAN (
192.168.178.155) - the host on the second eth interface (
169.254.1.100) - the
8.8.8.8
But it has trouble with:
- the Raspberri Pi (
169.254.1.25)
This is the routing table in the host:
» ip route
default via 192.168.178.1 dev wlp2s0 proto dhcp metric 600
169.254.1.0/24 dev enx000ec6a42183 proto kernel scope link src 169.254.1.100 metric 100
172.70.0.0/24 dev docker0 proto kernel scope link src 172.70.0.1
192.168.178.0/24 dev wlp2s0 proto kernel scope link src 192.168.178.155 metric 600
IP forwarding is enabled on the host:
» sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1
These are the docker networks:
» docker network ls
NETWORK ID NAME DRIVER SCOPE
8e2d62a7186d bridge bridge local
4d041aedcd2a host host local
71278e64d14b none null local
The routing table in the docker container:
root@8f50776e53dc:~# ip route
default via 172.70.0.1 dev eth0
172.70.0.0/24 dev eth0 proto kernel scope link src 172.70.0.2
The host routing table clearly specifies what to do when it sees a packet with destination 169.254.1.x: send it on the interface connected to Raspberri Pi.
Why is it not working then? Routing is enabled!