在 OpenWRT 中将 Linux Bridge 更改为 Openvswitch
Change Linux Bridge to Openvswitch in OpenWRT
我正在尝试用 openvswitch 更改 openwrt 中的 linux 桥,我用 openvswitch 包编译 openwrt 用于 tp-link tlwr1043nd,它完成了...问题是当我删除br-lan (linux brige) 并用 openvswitch 替换它,它总是错误和变砖
这是我用来更改为 ovs 的脚本:
我 运行 这个和 ((/root/ovs-tplink.sh > /dev/null 2&>1)&)&
这样可以在后台 运行ning,
#!/bin/sh
OVS_BR=ovslan
#IP Controller, Port for OvS Manager, Linux Bridge
IP_CONTROLLER=192.168.0.100
PORT_CONTROLLER=6633
LINUX_BRIDGE=br-lan
echo -e "3[0;32m Declare Necessary Variable Successful"
# Add Bridge Open vSwitch
ovs-vsctl --may-exist add-br $OVS_BR
echo -e "3[0;32m Add OvS Bridge $OVS_BR Succesful"
sleep 2
#Delete Port if added to $LINUX_BRIDGE
for i in eth0.1 eth0.2 eth0.3 eth0.4 eth0.5 eth0.6
do
brctl delif $LINUX_BRIDGE $i
echo -e "3[0;32m Delete Port $i in $LINUX_BRIDGE successful"
sleep 1
done
# Add Port to Bridge
for i in eth0.1 eth0.2 eth0.3 eth0.4 eth0.5 eth0.6 wlan0
do
ovs-vsctl --may-exist add-port $OVS_BR $i
echo -e "3[0;32m Add OvS Port $i to $OVS_BR successful"
sleep 1
done
# Up The Interface
for i in eth0.1 eth0.2 eth0.3 eth0.4 eth0.5 eth0.6 wlan0 ovslan
do
ifconfig $i up
echo -e "3[0;32m Up interface $i"
sleep 1
done
#Set All Options Necessary for Controller
ovs-vsctl set bridge $OVS_BR stp_enable=true
echo -e "3[0;32m Set STP Enabled True in $OVS_BR Successful"
sleep 1
ovs-vsctl set-controller $OVS_BR tcp:$IP_CONTROLLER:$PORT_CONTROLLER
echo -e "3[0;32m Set IP:$IP_CONTROLLER as Controller in $OVS_BR and Successful"
sleep 1
ovs-vsctl set-fail-mode $OVS_BR standalone
echo -e "3[0;32m Set Standalone Mode in $OVS_BR and Successful"
sleep 1
ovs-vsctl set bridge $OVS_BR protocols=OpenFlow13
echo -e "3[0;32m Set OpenFlow Protocol to 1.3 in $OVS_BR Successful"
sleep 1
ovs-vsctl set-manager ptcp:6640
sleep 1
ovs-ofctl del-flows $OVS_BR
echo -e "3[0;32m Delete Previous Flows in $OVS_BR and Successful"
sleep 1
echo -e "3[0;32m Restart Network Service. . . . . . "
/etc/init.d/network restart
echo -e "3[0;32m Restart Network Service Successful"
# Check Result
echo -e "3[0;32m Result : "
ovs-vsctl show
echo " "
reboot
exit 0
这是/etc/config/network中的网络配置:
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fded:6c7d:48c4::/48'
config interface 'lan'
option type 'bridge'
option ifname 'eth0.1 eth0.2 eth0.3 eth0.4 eth0.5 eth0.6'
option proto 'static'
option ipaddr '192.168.0.110'
option netmask '255.255.255.0'
option gateway '192.168.0.1'
config interface 'ovslan'
option ifname 'ovslan'
option proto 'static'
option ipaddr '192.168.0.111'
option netmask '255.255.255.0'
option gateway '192.168.0.1'
config interface 'eth0_1'
option ifname 'eth0.1'
option proto 'static'
config interface 'wan'
option ifname 'ovs-wan'
option proto 'dhcp'
config interface 'eth0_2'
option ifname 'eth0.2'
option proto 'dhcp'
config interface 'ovs1'
option proto 'static'
option ifname 'eth0.3'
option proto 'dhcp'
config interface 'ovs2'
option proto 'static'
option ifname 'eth0.4'
option proto 'dhcp'
config interface 'ovs3'
option proto 'static'
option ifname 'eth0.5'
option proto 'dhcp'
config interface 'ovs4'
option proto 'static'
option ifname 'eth0.6'
option proto 'dhcp'
config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'
config switch_vlan
option device 'switch0'
option vlan '1'
option ports '0t 6'
option vid '1'
config switch_vlan
option device 'switch0'
option vlan '2'
option ports '0t 5'
option vid '2'
config switch_vlan
option device 'switch0'
option vlan '3'
option vid '3'
option ports '0t 4'
config switch_vlan
option device 'switch0'
option vlan '4'
option vid '4'
option ports '0t 3'
config switch_vlan
option device 'switch0'
option vlan '5'
option vid '5'
option ports '0t 2'
config switch_vlan
option device 'switch0'
option vlan '6'
option vid '6'
option ports '0t 1'
我在使用openvswitch bridge时使用ovslan来统计IP,
请大家帮我解决这个问题...
感谢您的回答...
[已解决]
脚本很好,只需使用 nano
或 vi
/etc/config/network
通过 ssh 手动编辑 lan 配置,如下所示:
config interface 'lan'
#option type 'bridge' <= delete this
#option ifname 'eth0.1 eth0.2 eth0.3 eth0.4 eth0.5 eth0.6' <= edit
option ifname 'ovslan' <= add this
option proto 'static'
option ipaddr '192.168.0.110'
option netmask '255.255.255.0'
option gateway '192.168.0.1'
然后 运行 上面的脚本 ((/root/ovs-tplink.sh > /dev/null 2&>1)&)&
,等待,然后 check with ovs-vsctl show
基本上我们 :
在我们的网络配置中添加vlan /etc/config/network
禁用我们的防火墙和 DHCP 服务器,以便在我们的网络中使用父配置,因为我们使用 openvswitch(我们设置了转储 ap 路由器)
像上面一样删除br-lan(删除option type 'bridge'
),将ifname改成你喜欢的ovs bridge
运行 上面的脚本:
脚本基本上告诉:
- 添加 Openvswitch 桥
- 删除 linux 网桥中的端口
- 将端口添加到 openvswitch
- 在 openvswitch 中设置必要的选项
在这种情况下,我在TP-Link TL-WR1043nd v4中使用OpenWRT,我认为在v3或v2中也是如此,
谢谢大家,
我正在尝试用 openvswitch 更改 openwrt 中的 linux 桥,我用 openvswitch 包编译 openwrt 用于 tp-link tlwr1043nd,它完成了...问题是当我删除br-lan (linux brige) 并用 openvswitch 替换它,它总是错误和变砖
这是我用来更改为 ovs 的脚本:
我 运行 这个和 ((/root/ovs-tplink.sh > /dev/null 2&>1)&)&
这样可以在后台 运行ning,
#!/bin/sh
OVS_BR=ovslan
#IP Controller, Port for OvS Manager, Linux Bridge
IP_CONTROLLER=192.168.0.100
PORT_CONTROLLER=6633
LINUX_BRIDGE=br-lan
echo -e "3[0;32m Declare Necessary Variable Successful"
# Add Bridge Open vSwitch
ovs-vsctl --may-exist add-br $OVS_BR
echo -e "3[0;32m Add OvS Bridge $OVS_BR Succesful"
sleep 2
#Delete Port if added to $LINUX_BRIDGE
for i in eth0.1 eth0.2 eth0.3 eth0.4 eth0.5 eth0.6
do
brctl delif $LINUX_BRIDGE $i
echo -e "3[0;32m Delete Port $i in $LINUX_BRIDGE successful"
sleep 1
done
# Add Port to Bridge
for i in eth0.1 eth0.2 eth0.3 eth0.4 eth0.5 eth0.6 wlan0
do
ovs-vsctl --may-exist add-port $OVS_BR $i
echo -e "3[0;32m Add OvS Port $i to $OVS_BR successful"
sleep 1
done
# Up The Interface
for i in eth0.1 eth0.2 eth0.3 eth0.4 eth0.5 eth0.6 wlan0 ovslan
do
ifconfig $i up
echo -e "3[0;32m Up interface $i"
sleep 1
done
#Set All Options Necessary for Controller
ovs-vsctl set bridge $OVS_BR stp_enable=true
echo -e "3[0;32m Set STP Enabled True in $OVS_BR Successful"
sleep 1
ovs-vsctl set-controller $OVS_BR tcp:$IP_CONTROLLER:$PORT_CONTROLLER
echo -e "3[0;32m Set IP:$IP_CONTROLLER as Controller in $OVS_BR and Successful"
sleep 1
ovs-vsctl set-fail-mode $OVS_BR standalone
echo -e "3[0;32m Set Standalone Mode in $OVS_BR and Successful"
sleep 1
ovs-vsctl set bridge $OVS_BR protocols=OpenFlow13
echo -e "3[0;32m Set OpenFlow Protocol to 1.3 in $OVS_BR Successful"
sleep 1
ovs-vsctl set-manager ptcp:6640
sleep 1
ovs-ofctl del-flows $OVS_BR
echo -e "3[0;32m Delete Previous Flows in $OVS_BR and Successful"
sleep 1
echo -e "3[0;32m Restart Network Service. . . . . . "
/etc/init.d/network restart
echo -e "3[0;32m Restart Network Service Successful"
# Check Result
echo -e "3[0;32m Result : "
ovs-vsctl show
echo " "
reboot
exit 0
这是/etc/config/network中的网络配置:
config interface 'loopback'
option ifname 'lo'
option proto 'static'
option ipaddr '127.0.0.1'
option netmask '255.0.0.0'
config globals 'globals'
option ula_prefix 'fded:6c7d:48c4::/48'
config interface 'lan'
option type 'bridge'
option ifname 'eth0.1 eth0.2 eth0.3 eth0.4 eth0.5 eth0.6'
option proto 'static'
option ipaddr '192.168.0.110'
option netmask '255.255.255.0'
option gateway '192.168.0.1'
config interface 'ovslan'
option ifname 'ovslan'
option proto 'static'
option ipaddr '192.168.0.111'
option netmask '255.255.255.0'
option gateway '192.168.0.1'
config interface 'eth0_1'
option ifname 'eth0.1'
option proto 'static'
config interface 'wan'
option ifname 'ovs-wan'
option proto 'dhcp'
config interface 'eth0_2'
option ifname 'eth0.2'
option proto 'dhcp'
config interface 'ovs1'
option proto 'static'
option ifname 'eth0.3'
option proto 'dhcp'
config interface 'ovs2'
option proto 'static'
option ifname 'eth0.4'
option proto 'dhcp'
config interface 'ovs3'
option proto 'static'
option ifname 'eth0.5'
option proto 'dhcp'
config interface 'ovs4'
option proto 'static'
option ifname 'eth0.6'
option proto 'dhcp'
config switch
option name 'switch0'
option reset '1'
option enable_vlan '1'
config switch_vlan
option device 'switch0'
option vlan '1'
option ports '0t 6'
option vid '1'
config switch_vlan
option device 'switch0'
option vlan '2'
option ports '0t 5'
option vid '2'
config switch_vlan
option device 'switch0'
option vlan '3'
option vid '3'
option ports '0t 4'
config switch_vlan
option device 'switch0'
option vlan '4'
option vid '4'
option ports '0t 3'
config switch_vlan
option device 'switch0'
option vlan '5'
option vid '5'
option ports '0t 2'
config switch_vlan
option device 'switch0'
option vlan '6'
option vid '6'
option ports '0t 1'
我在使用openvswitch bridge时使用ovslan来统计IP, 请大家帮我解决这个问题...
感谢您的回答...
[已解决]
脚本很好,只需使用 nano
或 vi
/etc/config/network
通过 ssh 手动编辑 lan 配置,如下所示:
config interface 'lan'
#option type 'bridge' <= delete this
#option ifname 'eth0.1 eth0.2 eth0.3 eth0.4 eth0.5 eth0.6' <= edit
option ifname 'ovslan' <= add this
option proto 'static'
option ipaddr '192.168.0.110'
option netmask '255.255.255.0'
option gateway '192.168.0.1'
然后 运行 上面的脚本 ((/root/ovs-tplink.sh > /dev/null 2&>1)&)&
,等待,然后 check with ovs-vsctl show
基本上我们 :
在我们的网络配置中添加vlan
/etc/config/network
禁用我们的防火墙和 DHCP 服务器,以便在我们的网络中使用父配置,因为我们使用 openvswitch(我们设置了转储 ap 路由器)
像上面一样删除br-lan(删除
option type 'bridge'
),将ifname改成你喜欢的ovs bridge运行 上面的脚本:
脚本基本上告诉:
- 添加 Openvswitch 桥
- 删除 linux 网桥中的端口
- 将端口添加到 openvswitch
- 在 openvswitch 中设置必要的选项
在这种情况下,我在TP-Link TL-WR1043nd v4中使用OpenWRT,我认为在v3或v2中也是如此, 谢谢大家,