Hello everyone,
Issue type: I have incoming traffic on my router/firewalls LAN interface using the source IP of one of my docker containers internal IP: 172.17.0.3.
OS: Ubuntu 20.04.2 LTS
App version: Docker version 20.10.2, build 20.10.2-0ubuntu1~20.04.2
I find the issue quite peculiar. Everything seems to be fine. I’m running linuxserver.io:s qbittorrent container and it seems to run fine. The incoming port is exposed correctly and I can access everything. If i log into the container I can curl internet adresses just fine. Since I use another IP-range for my LAN all packets with this source IP is dropped by the firewall, i.e. I shouldnt have internet access at all if all packets hit the firewall with the incorrect source IP.
I checked the iptables nat tables postrouting chain, looks legit. The strange thing is most of the connections (95%) with the internal IP 172.17.0.3 have 63793 as source port. This is a port I have exposed on the host to the container, 5% use another port. It seems as if most traffic is getting SNAT:ed into the host IP since I can curl from within the container, connect to the exposed services and everything just seems to work fine.
Any ideas on how to further debug this issue?
iptables -t nat -S output:
-P PREROUTING ACCEPT
-P INPUT ACCEPT
-P OUTPUT ACCEPT
-P POSTROUTING ACCEPT
-N DOCKER
-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 POSTROUTING -s 172.17.0.3/32 -d 172.17.0.3/32 -p tcp -m tcp --dport 63793 -j MASQUERADE
-A POSTROUTING -s 172.17.0.3/32 -d 172.17.0.3/32 -p tcp -m tcp --dport 8080 -j MASQUERADE
-A POSTROUTING -s 172.17.0.5/32 -d 172.17.0.5/32 -p tcp -m tcp --dport 8096 -j MASQUERADE
-A POSTROUTING -s 172.17.0.4/32 -d 172.17.0.4/32 -p tcp -m tcp --dport 4040 -j MASQUERADE
-A POSTROUTING -s 172.17.0.2/32 -d 172.17.0.2/32 -p tcp -m tcp --dport 445 -j MASQUERADE
-A DOCKER -i docker0 -j RETURN
-A DOCKER ! -i docker0 -p tcp -m tcp --dport 63793 -j DNAT --to-destination 172.17.0.3:63793
-A DOCKER ! -i docker0 -p tcp -m tcp --dport 8080 -j DNAT --to-destination 172.17.0.3:8080
-A DOCKER ! -i docker0 -p tcp -m tcp --dport 8096 -j DNAT --to-destination 172.17.0.5:8096
-A DOCKER ! -i docker0 -p tcp -m tcp --dport 4040 -j DNAT --to-destination 172.17.0.4:4040
-A DOCKER ! -i docker0 -p tcp -m tcp --dport 445 -j DNAT --to-destination 172.17.0.2:445