2013-07-26 42 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