我正在尝试使用 openvpn 将虚拟机连接到主机。当我使用以下命令在虚拟机中创建 tap 接口时:/usr/sbin/openvpn --mktun --dev tap1 tap 接口的状态始终为“NO-CARRIER”
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 16436 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether fa:16:3e:07:55:b5 brd ff:ff:ff:ff:ff:ff
inet 12.1.1.2/24 brd 12.1.1.255 scope global eth0
inet6 fe80::f816:3eff:fe07:55b5/64 scope link tentative dadfailed
valid_lft forever preferred_lft forever
3: br-ex: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN
link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff
inet 10.10.100.2/24 scope global br-ex
inet6 fe80::3c23:adff:feb3:6d9d/64 scope link
valid_lft forever preferred_lft forever
8: tap1: <NO-CARRIER,BROADCAST,MULTICAST,PROMISC,UP> mtu 1500 qdisc pfifo_fast state DOWN qlen 100
link/ether ce:e9:4a:1d:80:55 brd ff:ff:ff:ff:ff:ff
知道为什么会发生这种情况吗?我检查了 /dev/net/tun 的权限,看起来没问题:
root@ip-10-66-210-99:~# ls -l /dev/net/tun
crw-rw-rw- 1 root root 10, 200 2014-02-15 07:15 /dev/net/tun
主机本身似乎没有问题。我遗漏了什么?
答案1
问题在于 tap 接口必须有一个与之关联的应用程序才能处于“正在运行”状态。一旦我启动绑定到 tap0 的 Openvpn 服务,状态就会变为“正在运行”