2013-07-26 95 views
1

TunTap文档on the vtun site指出,只有Linux内核2.4才支持该驱动程序。有什么办法让它在2.6和3.2版本的Linux上运行?在Linux内核2.6中使用TunTap

设备上的猫显示:

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

我试图直接从RPM文件安装,看我怎么能走多远,并得到:

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

有什么办法,我可以得到这在Linux 2.6+上工作还是有任何你知道的tuntap的替代品吗?

+1

该FAQ已过期。 Linux 2.6(和3.x)带有tun/tap驱动程序。您可以使用例如创建tuntap设备。 'ip tuntap add'命令。虽然文档是按照常规稀缺/不存在的,但可能[this](http://backreference.org/2010/03/26/tuntap-interface-tutorial/)可能有帮助 – nos

+0

我有/ dev/net/tun,但文件上的一个猫说“cat:/ dev/net/tun:文件描述符处于不良状态”。 ip tuntap add说“对象”tuntap“未知” –

+0

我读了某处ip命令已经过时的一些版本,我不得不使用tunctl。让我试试这个,回到你身边。 –

回答

2

tuntap文档已过时。另外,在Linux的新版本,你可能需要使用的

tunctl 

代替

ip tuntap add 

要在Debian的挤压安装tunctl,安装包'UML的公用事业提供的tunctl命令。您可以添加使用

tunctl -t tun1 
1

使用下面的脚本来自动创建它,在内容直接复制到file.sh新的隧道,改变“ETHOIPADDR”你的IP地址,同样也改变网关并广播地址并使用sudo权限运行脚本。

#!/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