1

The TunTap documentation on the vtun site points out that the driver is only supported till Linux kernel 2.4. Is there any way to get it to run on 2.6 and 3.2 versions of Linux?

A cat on the device shows:

# cat /dev/net/tun
 cat: File descriptor in bad state

I tried installing directly from the rpm file to see how far I could go and got:

# rpm -i tun-1.1-6.rh71.i386.rpm
error: Failed dependencies:
     /bin/sh is needed by tun-1.1-6.i386

Is there any way I can get this to work on linux 2.6+ or are there any good alternatives to tuntap that you are aware of?

5
  • 1
    That FAQ is out of date. Linux 2.6 (and 3.x) comes with a tun/tap driver. You can create tuntap devices with e.g. the ip tuntap add command. Documentation is as per usual scarce/non-existing though, perhaps this could be of help
    – nos
    Jul 26, 2013 at 16:16
  • I have the /dev/net/tun but a cat on the file says "cat: /dev/net/tun: File descriptor in bad state". ip tuntap add says "Object "tuntap" is unknown" Jul 26, 2013 at 17:45
  • I read somewhere that ip command is outdated on some versions and I have to use tunctl. Let me try that and get back to you. Jul 26, 2013 at 17:58
  • 1
    You shouldn't be able to read (using cat) /dev/net/tun anyway, at least not without configuring the device by ioctl's first. What are you actually trying to do ?
    – nos
    Jul 26, 2013 at 18:17
  • I got it to work by using tunctl instead of ip tuntap add. Thanks everyone. Jul 26, 2013 at 19:35

2 Answers 2

2

The tuntap documentation is outdated. Also, in newer versions of linux, you might need to use

tunctl 

instead of

ip tuntap add

To install tunctl on debian Squeeze, install the package 'uml-utilities' which provides the tunctl command. You can add a new tunnel using

tunctl -t tun1
1

Use the below script to create it automatically, just copy the contents in to a file.sh, change the "ETHOIPADDR" to your ip address, similarly also the change the gateway and broadcast address and run the script with sudo permission.

#!/bin/sh 
# 
# script to bring up the tun device in QEMU in bridged mode 
# first parameter is name of tap device (e.g. tap0)
#
# some constants specific to the local host - change to suit your host
#
ETH0IPADDR=192.168.0.3
GATEWAY=192.168.0.1
BROADCAST=192.168.0.255
#
# First take eth0 down, then bring it up with IP address 0.0.0.0 
#
/sbin/ifdown eth0
/sbin/ifconfig eth0 0.0.0.0 promisc up
#
# Bring up the tap device (name specified as first argument, by QEMU)
#
/usr/sbin/openvpn --mktun --dev $1 --user `id -un`
/sbin/ifconfig $1 0.0.0.0 promisc up
#
# create the bridge between eth0 and the tap device
#
/usr/sbin/brctl addbr br0
/usr/sbin/brctl addif br0 eth0
/usr/sbin/brctl addif br0 $1
# 
# only a single bridge so loops are not possible, turn off spanning tree protocol
#
/usr/sbin/brctl stp br0 off 
# 
# Bring up the bridge with ETH0IPADDR and add the default route 
#
/sbin/ifconfig br0 $ETH0IPADDR netmask 255.255.255.0 broadcast $BROADCAST
/sbin/route add default gw $GATEWAY
#
# stop firewall - comment this out if you don't use Firestarter
#
/sbin/service firestarter stop 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.