Linux – If there are 2 NICs on the same machine, can a TCP client on one NIC connect to a TCP server on the other NIC

linuxnetwork-adapternetworkingtcp

I use TUN/TAP to create a tun NIC tun0 with IP 10.10.10.2, and I have a real NIC eth0 with IP 202.112.34.49

Then I run a TCP client which binds its socket to 202.112.34.49 and a TCP server binding 10.10.10.2. but I can't establish a tcp connection between them.

So can a TCP client on one NIC connect to a tcp server on the other NIC?

Best Answer

Packets to local addresses will always run on the lo interface; they will never leave the machine. (Packets to local addresses arriving on non-lo interfaces are regarded as martians.)

In other words, your packets must get stuck on the lo interface somewhere, possibly due to a firewall. Check your iptables-save output and do a tcpdump on the lo interface for those packets to debug this issue.

Related Question