LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
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 02-24-2009, 10:12 PM   #1
jayadhanesh
Member
 
Registered: Feb 2009
Location: Bangalore
Posts: 61

Rep: Reputation: 15
How do I send and receive data through a TUN interface?


Hi all,

I opened a TUN interface and used select to listen on that interface.
I have another program which opens a socket and writes data into
the socket continously. I want all the data written into the socket to
be read by the TUN interface.
As far as i know, the kernal puts the data into the TUN interface which
can be read by the user application.
What should I do to make the kernal pass all the data through the socket
to be written to the TUN interface?

Thanks,
Dhanesh.
 
Old 02-24-2009, 10:20 PM   #2
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
i dont have too much experience with TUN interfaces except with automatically created ones by hamachi, however my guess would be that you would treat a tun interface as you would any other interface and simply configure whatever program you need to use that interface to bind to that interface instead of the physical interface or if you want ALL traffic through the TUN interface, set it as your default route instead of your physical interface, if that makes any sense
i'm guessing your interfaces would look something like
lo
-yadayadayada
eth0
-yadayadayada
tun0
-yadayadayada
?
edit: in short what i'm trying to say is if the interface exists, the kernel already IS capable of sending information through it, so it isn't a kernel issue you need to look at but rather a routing issue

Last edited by frieza; 02-24-2009 at 10:40 PM.
 
Old 02-24-2009, 11:23 PM   #3
jayadhanesh
Member
 
Registered: Feb 2009
Location: Bangalore
Posts: 61

Original Poster
Rep: Reputation: 15
Thanks Frieza, After opening the TUN interface, the program is
blocking on the select call. When I did an ifconfig, i get the
following for TUN interface:
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:500
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)

Is it possible to route packets only from certain applications
to be passed onto the TUN interface?
 
Old 02-25-2009, 12:04 AM   #4
frieza
Senior Member
 
Registered: Feb 2002
Location: harvard, il
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233

Rep: Reputation: 406Reputation: 406Reputation: 406Reputation: 406Reputation: 406
again i can't provide details since i havnt really needed to use this information but
i would look into iptables and ipchains, depending on what programs you are using you might be able to route certain traffic to the appropriate information based on port number,regardless, iptables/ipchains are useful programs that are used to configure how your computer routes network traffic

Last edited by frieza; 02-25-2009 at 12:05 AM.
 
Old 02-26-2009, 01:49 AM   #5
jayadhanesh
Member
 
Registered: Feb 2009
Location: Bangalore
Posts: 61

Original Poster
Rep: Reputation: 15
I found somewhere on the net that TAP/TUN are not supported by
all kernel versions. Does 2.6-X support TAP/TUN?
 
  


Reply

Tags
tun



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
Not able to send/receive the data packets through my own Ethernet driver b/w 2 pc jagadisha_bs Linux - Newbie 5 02-26-2009 12:31 AM
How to send and receive data from a single socket in perl?? murahman Programming 0 07-28-2008 03:29 AM
How to send data to WAN Interface card at Data link Layer in linux environment krishna_karne Linux - Software 0 05-09-2008 04:01 AM
Modem Data Send/Receive Problem mofargel Linux - Hardware 1 10-16-2007 08:42 PM
can i send or receive data in compress form to internet alvi2 Linux - Networking 1 03-05-2005 07:48 AM

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

All times are GMT -5. The time now is 11:01 AM.

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