Reading packets from a tun device.

PenguinOfDoom pahan at
Sun Jul 13 15:26:35 CEST 2003

Andre <andre at> wrote in message news:<mailman.1058041398.21541.python-list at>...
> I'm trying to read packets from a tun device in Python, the code I used 
> for this is the following:
> f = file( '/dev/tun0', 'r+' )
<snip sad story>

You appear to be using the ethertap driver. That is obsolete. You want
the new tuntap driver (module tun).
Also, Twisted ( can conveniently handle tuntap
devices. You'll have to get the CVS version. The code is in
twisted.pair.tuntap. This is not terribly tested or stable.
Low-level functionality (opening the tuntap device) is provided by the
Eunuchs project. I can't seem to find a website for it, but the module
is available in Debian as python2.2-eunuchs.
You could poke Tommi Virtanen for more details. He's Tv on

More information about the Python-list mailing list