I'm running a VPN client in a docker container. I'm trying to connect from the host to a web server running in the docker container over port 8080. When I try to connect, I see my incoming packet on port 8080 via tcpdump, but the web server never sees it. I've added iptables '-j LOG' rules for all possible state transitions of the packet to try to trace it down. I see the packet at:
- table 'raw', chain PREROUTING
- table 'mangle', chain PREROUTING
- table'nat', chain PREROUTING
and then... nothing. After a small delay, the packet is re-sent, and I see the new packet go through PREROUTING. Nothing ever appears on the mangle INPUT or mangle FORWARD chains - which as far as I can tell is impossible - it has to hit one of those. Is there any way for a packet to go through PREROUTING, but not hit INPUT or FORWARD? My iptables are below:
root@87ff7ad8e4f9:/# iptables -t raw -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
NFLOG tcp -- anywhere anywhere tcp spt:http-alt nflog-prefix "raw pre-route Src incoming packet"
NFLOG tcp -- anywhere anywhere tcp dpt:http-alt nflog-prefix "raw pre-route Dest incoming packet"
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
NFLOG tcp -- anywhere anywhere tcp dpt:http-alt nflog-prefix "Dest outgoing packet"
NFLOG tcp -- anywhere anywhere tcp spt:http-alt nflog-prefix "Src outgoing packet"
root@87ff7ad8e4f9:/# iptables -t mangle -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
NFLOG tcp -- anywhere anywhere tcp dpt:http-alt nflog-prefix "mangle PREROUTING Dest incoming packet"
Chain INPUT (policy ACCEPT)
target prot opt source destination
NFLOG all -- anywhere anywhere nflog-prefix "mangle INPUT Dest incoming packet any2"
Chain FORWARD (policy ACCEPT)
target prot opt source destination
NFLOG all -- anywhere anywhere nflog-prefix "mangle FORWARD Dest incoming packet any"
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
MARK tcp -- anywhere anywhere tcp spt:http-alt MARK set 0x1
MARK tcp -- anywhere anywhere tcp dpt:http-alt MARK set 0x1
NFLOG tcp -- anywhere anywhere tcp spt:http-alt nflog-prefix "MARK set 0x1"
NFLOG tcp -- anywhere anywhere tcp dpt:http-alt nflog-prefix "Dest MARK set 0x1"
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
root@87ff7ad8e4f9:/# iptables -t nat -L
Chain PREROUTING (policy ACCEPT)
target prot opt source destination
NFLOG tcp -- anywhere anywhere tcp dpt:http-alt nflog-prefix "nat PREROUTING Dest incoming packet"
Chain INPUT (policy ACCEPT)
target prot opt source destination
NFLOG tcp -- anywhere anywhere tcp dpt:http-alt nflog-prefix "nat INPUT Dest incoming packet"
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
Chain POSTROUTING (policy ACCEPT)
target prot opt source destination
root@87ff7ad8e4f9:/# iptables -t filter -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
NFLOG tcp -- anywhere anywhere nflog-prefix "connection made"
NFLOG tcp -- anywhere anywhere tcp dpt:http-alt nflog-prefix "filter INPUT Dest incoming packet"
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere ctstate RELATED,ESTABLISHED
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT all -- anywhere 172.17.0.0/16
ACCEPT udp -- anywhere anywhere udp dpt:domain
ACCEPT tcp -- anywhere anywhere owner GID match vpn
ACCEPT udp -- anywhere anywhere owner GID match vpn
DROP all -- anywhere anywhere
And my syslog shows:
Oct 4 07:22:56 87ff7ad8e4f9 raw pre-route Dest incoming packet IN=eth0 OUT= MAC=02:42:ac:11:00:02:02:42:2e:2c:fd:2e:08:00 SRC=76.167.254.196 DST=172.17.0.2 LEN=60 TOS=00 PREC=0x00 TTL=63 ID=39119 DF PROTO=TCP SPT=46644 DPT=8080 SEQ=4027056663 ACK=0 WINDOW=29200 SYN URGP=0 MARK=0
Oct 4 07:22:56 87ff7ad8e4f9 mangle PREROUTING Dest incoming packet IN=eth0 OUT= MAC=02:42:ac:11:00:02:02:42:2e:2c:fd:2e:08:00 SRC=76.167.254.196 DST=172.17.0.2 LEN=60 TOS=00 PREC=0x00 TTL=63 ID=39119 DF PROTO=TCP SPT=46644 DPT=8080 SEQ=4027056663 ACK=0 WINDOW=29200 SYN URGP=0 MARK=0
Oct 4 07:22:56 87ff7ad8e4f9 nat PREROUTING Dest incoming packet IN=eth0 OUT= MAC=02:42:ac:11:00:02:02:42:2e:2c:fd:2e:08:00 SRC=76.167.254.196 DST=172.17.0.2 LEN=60 TOS=00 PREC=0x00 TTL=63 ID=39119 DF PROTO=TCP SPT=46644 DPT=8080 SEQ=4027056663 ACK=0 WINDOW=29200 SYN URGP=0 MARK=0
Oct 4 07:22:57 87ff7ad8e4f9 raw pre-route Dest incoming packet IN=eth0 OUT= MAC=02:42:ac:11:00:02:02:42:2e:2c:fd:2e:08:00 SRC=76.167.254.196 DST=172.17.0.2 LEN=60 TOS=00 PREC=0x00 TTL=63 ID=39120 DF PROTO=TCP SPT=46644 DPT=8080 SEQ=4027056663 ACK=0 WINDOW=29200 SYN URGP=0 MARK=0
Oct 4 07:22:57 87ff7ad8e4f9 mangle PREROUTING Dest incoming packet IN=eth0 OUT= MAC=02:42:ac:11:00:02:02:42:2e:2c:fd:2e:08:00 SRC=76.167.254.196 DST=172.17.0.2 LEN=60 TOS=00 PREC=0x00 TTL=63 ID=39120 DF PROTO=TCP SPT=46644 DPT=8080 SEQ=4027056663 ACK=0 WINDOW=29200 SYN URGP=0 MARK=0
Oct 4 07:22:57 87ff7ad8e4f9 nat PREROUTING Dest incoming packet IN=eth0 OUT= MAC=02:42:ac:11:00:02:02:42:2e:2c:fd:2e:08:00 SRC=76.167.254.196 DST=172.17.0.2 LEN=60 TOS=00 PREC=0x00 TTL=63 ID=39120 DF PROTO=TCP SPT=46644 DPT=8080 SEQ=4027056663 ACK=0 WINDOW=29200 SYN URGP=0 MARK=0