OpenVSwitch 网桥配置
方法一:临时配置
# ovs-vsctl add-br ovs-br0
# ip addr flush dev enp1s0f1
# ip addr add 10.0.10.4/24 dev ovs-br0
# ovs-vsctl add-port ovs-br0 enp1s0f1
# ip link set up dev ovs-br0
验证配置是否成功
# ovs-vsctl show
方法二:方法一是临时配置,重启后配置失效,想要永久有效需要修改配置文件
# cd /etc/sysconfig/network-scripts/
# cp ifcfg-enp1s0f1 ifcfg-ovs-br0
# vim ifcfg-ovs-br0
修改如下配置项:
DEVICE=ovs-br0
DEVICETYPE=ovs
TYPE=OVSBridge
BOOTPROTO=static
IPADDR=192.168.81.129
NETMASK=255.255.255.0
GATEWAY=192.168.81.1
ONBOOT=yes
修改后ifcfg-ovs-br0如下截图:
# vim ifcfg-enp1s0f1
修改如下配置项:
DEVICE=eth1
TYPE=OVSPort
DEVICETYPE=ovs
NAME=enp1s0f1
OVS_BRIDGE=ovs-br0
ONBOOT=yes
修改后ifcfg-enp1s0f1如下截图:
重启查看网络:
# systemctl restart network
验证是否配置成功
# ovs-vsctl show
3.在KVM中定义一个ovs-network
[root@localhost ~]# cat << EOF > /tmp/ovs-network.xml
<network>
<name>ovs-network</name>
<forward mode='bridge'/>
<bridge name='ovs-br0'/>
<virtualport type='openvswitch'/>
</network>
EOF
生成ovs-network网络:
# virsh net-define /tmp/ovs-network.xml
# virsh net-start ovs-network
# virsh net-autostart ovs-network
查看网络是否创建成功:
# virsh net-list