1
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?
What do you mean by "a socket descriptor to the tun0"? – David Schwartz – 2017-11-06T04:49:24.067
ah, I got it, since the IPs are all local, the packets will be sent to
lo
but not tun0. If I use raw socket to modify the source IP to an non-local IP, for example, I use raw socket to send a packet to the TCP server on 10.10.10.2, will the server react a TCP SYN/ACK destined to that non-local IP. Can I hook/intercept the SYN/ACK packet(including TCP/IP Header)? thanks – misteryes – 2013-05-17T22:30:27.7901The packets destined to remote destinations will be sent according to the machine's routing table. You could of course use promisc mode on the network interface or set up a NAT to a local address, however you may want to take a look at something like LXC. It allows you to run two minimalistic virtual machines with separate network stacks. – Janos Pasztor – 2013-05-18T13:49:49.270
no, what I want to do is: I have a tcp server listening on 10.10.10.2(that is the tun0), and I open a socket descriptor to the tun0. Then I can use the socket descriptor to write TCP SYN packet to the socket descriptor and read the responding TCP SYN/ACK packet. Is this usage correct? thanks! – misteryes – 2013-05-18T17:30:58.717