【问题标题】:Using TunTap with linux kernel 2.6在 Linux 内核 2.6 中使用 TunTap
【发布时间】:2013-07-26 16:11:32
【问题描述】:

TunTap 文档on the vtun site 指出该驱动程序仅支持到 Linux 内核 2.4。有没有办法让它在 2.6 和 3.2 版本的 Linux 上运行?

设备上的一只猫显示:

# 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 替代品吗?

【问题讨论】:

  • 该常见问题解答已过时。 Linux 2.6(和 3.x)带有一个 tun/tap 驱动程序。您可以使用例如创建 tuntap 设备。 ip tuntap add 命令。文档像往常一样稀缺/不存在,也许this 可能会有所帮助
  • 我有 /dev/net/tun 但文件上的猫说“猫:/dev/net/tun:文件描述符处于错误状态”。 ip tuntap add 说“对象“tuntap”未知”
  • 我在某处读到 ip 命令在某些版本上已过时,我必须使用 tunctl。让我试试,然后回复你。
  • 无论如何,您都不应该能够读取(使用 cat)/dev/net/tun,至少在没有通过 ioctl 配置设备的情况下是这样。你到底想做什么?
  • 我通过使用 tunctl 而不是 ip tuntap add 让它工作。谢谢大家。

标签: networking linux-kernel tunnel tun


【解决方案1】:

tuntap 文档已过时。此外,在较新版本的 linux 中,您可能需要使用

tunctl 

而不是

ip tuntap add

要在 debian Squeeze 上安装 tunctl,请安装提供 tunctl 命令的软件包“uml-utilities”。您可以使用

添加新隧道
tunctl -t tun1

【讨论】:

    【解决方案2】:

    使用以下脚本自动创建它,只需将内容复制到 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 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-09-03
      • 2014-08-22
      • 2011-05-09
      • 1970-01-01
      • 1970-01-01
      • 2015-07-07
      • 2012-11-26
      相关资源
      最近更新 更多