LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   if there are 2 NIC on the same machine, can a tcp client on one NIC connect to a tcp (https://www.linuxquestions.org/questions/linux-networking-3/if-there-are-2-nic-on-the-same-machine-can-a-tcp-client-on-one-nic-connect-to-a-tcp-4175462375/)

esolve 05-17-2013 12:58 PM

if there are 2 NIC on the same machine, can a tcp client on one NIC connect to a tcp
 
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?

thanks!

nini09 05-17-2013 02:24 PM

You can create two tun interface, one for client and another for server. These two tun0 can communicate each other. The packet on real NIC will send to wire and never come back except another device make it back.

esolve 05-17-2013 05:33 PM

Quote:

Originally Posted by nini09 (Post 4953279)
You can create two tun interface, one for client and another for server. These two tun0 can communicate each other. The packet on real NIC will send to wire and never come back except another device make it back.

I just heard that if they are on the same machine, the packets will never reach the tun interface, but they will go to loopback interface, is it right?

nini09 05-20-2013 02:16 PM

Dependant on what do you talk about? If you talk about whether the packet sending to interface is delivered to wire, no, tun/tap interface only exist in kernel and they never send the packet to wire. But loopback interface doesn't send packet to wire, either.
The advantage to use tun/tap interface is that you can create a network on same machine without any network device.
Check following Website and it can help understand tun/tap interface.
http://backreference.org/2010/03/26/...face-tutorial/


All times are GMT -5. The time now is 05:17 PM.