![尝试桥接 NIC。此错误是什么意思?](https://linux22.com/image/561184/%E5%B0%9D%E8%AF%95%E6%A1%A5%E6%8E%A5%20NIC%E3%80%82%E6%AD%A4%E9%94%99%E8%AF%AF%E6%98%AF%E4%BB%80%E4%B9%88%E6%84%8F%E6%80%9D%EF%BC%9F.png)
我想在我的 OpenVPN 服务器之间建立桥接br0
,tap0
但是我收到了此帖子底部的错误。
背景
该服务器有一个物理eth0
IP xxx.xxx.68.58
。
桥接器应该具有xxx.xxx.85.5
NIC ,OpenVPN 客户端从该tap0
NIC 获取 IP 在范围内xxx.xxx.85.50
。xxx.xxx.85.100
为了建造这座桥我做了以下事情:
#!/bin/bash
br="br0"
tap="tap0"
eth="eth0:0"
eth_ip="xxx.xxx.85.5"
eth_netmask="255.255.255.0"
eth_broadcast="255.255.71.255"
openvpn --mktun --dev $tap
brctl addbr $br
brctl addif $br $eth
brctl addif $br $tap
ifconfig $tap 0.0.0.0 promisc up
echo "debug"
ifconfig $eth 0.0.0.0 promisc up
echo "debug"
ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast
但出现这个错误;
Tue Sep 13 10:40:46 2011 TUN/TAP device tap0 opened
Tue Sep 13 10:40:46 2011 Persist state set to: ON
debug
SIOCSIFFLAGS: Cannot assign requested address
SIOCSIFFLAGS: Cannot assign requested address
SIOCSIFFLAGS: Cannot assign requested address
debug
我究竟做错了什么?
更新
set -vx
在脚本顶部添加后,我得到:
br="br0"
+ br=br0
tap="tap0"
+ tap=tap0
eth="eth0:0"
+ eth=eth0:0
eth_ip="xxx.xxx.85.5"
+ eth_ip=xxx.xxx.85.5
eth_netmask="255.255.255.0"
+ eth_netmask=255.255.255.0
eth_broadcast="255.255.71.255"
+ eth_broadcast=255.255.71.255
openvpn --mktun --dev $tap
+ openvpn --mktun --dev tap0
Tue Sep 13 11:42:33 2011 TUN/TAP device tap0 opened
Tue Sep 13 11:42:33 2011 Persist state set to: ON
brctl addbr $br
+ brctl addbr br0
brctl addif $br $eth
+ brctl addif br0 eth0:0
brctl addif $br $tap
+ brctl addif br0 tap0
ifconfig $tap 0.0.0.0 promisc up
+ ifconfig tap0 0.0.0.0 promisc up
ifconfig $eth 0.0.0.0 promisc up
+ ifconfig eth0:0 0.0.0.0 promisc up
SIOCSIFFLAGS: Cannot assign requested address
SIOCSIFFLAGS: Cannot assign requested address
SIOCSIFFLAGS: Cannot assign requested address
ifconfig $br $eth_ip netmask $eth_netmask broadcast $eth_broadcast
+ ifconfig br0 xxx.xxx.85.5 netmask 255.255.255.0 broadcast 255.255.71.255
答案1
查看各个命令的输出(而不仅仅是批处理文件)会非常有用;或者您可以将其放在set -vx
批处理文件的顶部附近,这样会提供更多有用的输出。
但乍一看,问题可能是你试图将以太网子接口 (eth0:0) 绑定到网桥,而不是物理端口。如果你替换
eth="eth0:0"
和
eth="eth0"
在脚本的顶部?
如果您不想这样做,因为您将 eth0 用于不同的目的,您能否更详细地解释一下您想要实现的目标?