ovs 添加物理端口
Bridge ovs-switch Port ovs-switch Interface ovs-switch type: internal Port "enahisic2i1" Interface "enahisic2i1"
注意:进行OVS设置时很容易造成虚拟交换机与物理交换机构成二层环路(比如虚拟交换机包含两块网卡,而这两块网卡都连接到物理交换机上,就是一个环路),一旦有广播报文,比如ARP请求,就会引发广播风暴,使网络瘫痪。因此,应该把虚拟交换机开启STP支持,避免广播风暴:
ovs−vsctl set bridge 交换机名 stp_enable=true
[root@kunpeng82 devuser]# ifconfig enahisic2i1 enahisic2i1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 172.18.100.82 netmask 255.255.255.0 broadcast 0.0.0.0 ether 48:57:02:64:e7:ac txqueuelen 1000 (Ethernet) RX packets 12123135 bytes 1711038311 (1.5 GiB) RX errors 0 dropped 5349108 overruns 0 frame 0 TX packets 540 bytes 41452 (40.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
当把物理端口添加到虚拟交换机上之后,这些物理端口上原先的IP设置将失效(IP属于三层,而交换机工作在二层),无法与外界进行三层的互联。解决方法是添加一个类型为internal的端口,然后设置IP和路由(本例是添加一个名为veth3的虚拟端口):
[root@kunpeng82 devuser]# ifconfig enahisic2i1 0 [root@kunpeng82 devuser]# ifconfig enahisic2i1 enahisic2i1: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 ether 48:57:02:64:e7:ac txqueuelen 1000 (Ethernet) RX packets 12129000 bytes 1715085158 (1.5 GiB) RX errors 0 dropped 5349155 overruns 0 frame 0 TX packets 540 bytes 41452 (40.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
Bridge ovs-switch Port ovs-switch Interface ovs-switch type: internal Port "enahisic2i1" Interface "enahisic2i1"
[root@kunpeng82 devuser]# ifconfig ovs-switch 172.18.100.82/24
[root@kunpeng82 devuser]# ifconfig ovs-switch
ovs-switch: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 172.18.100.82 netmask 255.255.255.0 broadcast 172.18.100.255
inet6 fe80::4a57:2ff:fe64:e7ac prefixlen 64 scopeid 0x20<link>
ether 48:57:02:64:e7:ac txqueuelen 1000 (Ethernet)
RX packets 2381 bytes 1749631 (1.6 MiB)
RX errors 0 dropped 9871 overruns 0 frame 0
TX packets 14 bytes 1076 (1.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0