Linux

試圖橋接網卡。這個錯誤是什麼意思?

  • September 13, 2011

我想在我的 OpenVPN 伺服器之間架起橋樑br0tap0但我在這篇文章的底部收到了錯誤消息。

背景

伺服器有一個物理eth0IP xxx.xxx.68.58

網橋應該有xxx.xxx.85.5,並且 OpenVPN 客戶端從中獲取 IP 的tap0NIC 位於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

查看單個命令的輸出,而不僅僅是批處理文件,這將非常有用;或者您可以放在set -vx批處理文件的頂部附近,這將提供更有用的輸出。

但乍一看,問題可能是您試圖將乙太網子介面 (eth0:0) 奴役到網橋,而不是物理埠。如果更換會發生什麼

eth="eth0:0"

eth="eth0"

在腳本的頂部?

如果您不想這樣做,因為您將 eth0 用於不同的目的,您能否更詳細地解釋您想要實現的目標?

引用自:https://serverfault.com/questions/310790