FirstName LastName
FirstName LastName

Reputation: 1911

Using TunTap with linux kernel 2.6

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?

Upvotes: 1

Views: 3314

Answers (2)

Santosh A
Santosh A

Reputation: 5351

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 

Upvotes: 1

FirstName LastName
FirstName LastName

Reputation: 1911

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

Upvotes: 2

Related Questions