LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 05-17-2013, 12:58 PM   #1
esolve
LQ Newbie
 
Registered: Oct 2012
Posts: 18

Rep: Reputation: Disabled
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!
 
Old 05-17-2013, 02:24 PM   #2
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,854

Rep: Reputation: 161Reputation: 161
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.
 
Old 05-17-2013, 05:33 PM   #3
esolve
LQ Newbie
 
Registered: Oct 2012
Posts: 18

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by nini09 View Post
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?
 
Old 05-20-2013, 02:16 PM   #4
nini09
Senior Member
 
Registered: Apr 2009
Posts: 1,854

Rep: Reputation: 161Reputation: 161
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/
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
qt tcp client, C tcp server deadeyes Programming 3 09-04-2011 10:23 AM
Force TCP traffic out over specific interface when IP is bound to another local NIC yeager Linux - Networking 7 08-17-2010 09:16 AM
how to connect to a remote machine using tcp socket sangupari Linux - Networking 3 03-03-2010 11:11 PM
tcp proxy with one nic, redirect traffic to other IP RattleSn@ke Linux - Networking 3 03-09-2009 07:34 AM
Dropped/hung TCP sessions on both NIC's, Compaq server with Debian doctorcisco Linux - Networking 1 01-16-2006 08:16 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:12 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration