Linux系統(tǒng)安裝
安裝時(shí)勾選虛擬機(jī)主機(jī)服務(wù)霜定。
OVS虛擬交換機(jī)軟件安裝
$ sudo zypper in openvswitch ///opensuse
$ sudo dnf install centos-release-nfv-openvswitch ///centos默認(rèn)源不包含嗤放,需安裝該repo
$ sudo dnf repolist all ///檢查源centos-nfv-openvswitch是否啟用
$ sudo dnf search openvswitch ///搜索OVS軟件包
$ sudo dnf install openvswitch2.13 ///一般選擇最新版本安裝
///dnf為最新的rhel centos fedora包管理思喊,老版本替換為yum
檢查系統(tǒng)服務(wù)
$ systemctl status libvirtd ///虛擬化接口服務(wù)
$ systemctl status openvswitch ///OVS服務(wù)
///確保服務(wù)開機(jī)自啟并處于運(yùn)行狀態(tài)
OVS配置
opensuse
網(wǎng)絡(luò)選用wicked管理,參考鏈接https://en.opensuse.org/Portal:Wicked/OpenvSwitch
///生成ovs橋并綁定到物理網(wǎng)口次酌,假定物理網(wǎng)口名為eth0恨课,ovs橋命名為ovsbr
$ sudo ovs-vsctl add-br ovsbr
$ sudo ovs-vsctl add-port ovsbr eth0
///修改物理網(wǎng)口網(wǎng)絡(luò)配置文件
# /etc/sysconfig/network/ifcfg-eth0
STARTMODE='auto'
BOOTPROTO='none'
///ovs創(chuàng)建橋時(shí)默認(rèn)會(huì)自動(dòng)創(chuàng)建同名稱的虛擬內(nèi)部網(wǎng)絡(luò)接口供虛擬化主機(jī)通信
///因此,創(chuàng)建新的網(wǎng)絡(luò)配置文件岳服,用于物理主機(jī)訪問網(wǎng)絡(luò)
# /etc/sysconfig/network/
$ sudo touch ifcfg-ovsbr
STARTMODE='auto'
BOOTPROTO=dhcp
OVS_BRIDGE='yes'
OVS_BRIDGE_PORT_DEVICE='eth0'
///重啟網(wǎng)絡(luò)使配置生效
$ sudo systemctl restart network
///檢查網(wǎng)絡(luò)狀態(tài)剂公,正常如下顯示
$ ip a
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq master ovs-system state UP group default qlen 1000
3: ovs-system: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
4: ovsbr: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
inet xxx.xxx.xxx.xxx/xx brd xxx.xxx.xxx.xxx scope global
valid_lft forever preferred_lft forever
inet6 xxxx::xxxx:xxxx:xxxx:xxxx/64 scope link
valid_lft forever preferred_lft forever
rhel centos fedora
網(wǎng)絡(luò)采用NetworkManager管理,參考鏈接https://developer.gnome.org/NetworkManager/stable/nm-openvswitch.html
老版本采用的network-scripts從rhel8開始棄用吊宋,不推薦使用
///nm是直接寫數(shù)據(jù)到ovs數(shù)據(jù)庫纲辽,因此,需要手動(dòng)創(chuàng)建ovs橋,端口(port)及接口(interface)
$ nmcli conn add type ovs-bridge conn.interface ovsbr ///創(chuàng)建ovs橋
$ nmcli conn add type ovs-port conn.interface ovsbr master ovsbr ///創(chuàng)建內(nèi)部port
$ nmcli conn add type ovs-interface slave-type ovs-port conn.interface ovsbr \
master ovsbr ipv4.method auto ///創(chuàng)建內(nèi)部interface拖吼,并采用dhcp獲取ip
$ nmcli conn add type ovs-port conn.interface eth0 master ovsbr ///創(chuàng)建物理網(wǎng)口port
$ nmcli conn add type ethernet conn.interface eth0 master eth0 ///綁定到物理網(wǎng)口interface
$ sudo systemctl restart NetworkManager ///重啟網(wǎng)絡(luò)服務(wù)使配置生效
///ovs接口狀態(tài)如下
$ sudo ovs-vsctl show
Bridge ovsbr
Port ovsbr
Interface ovsbr
type: internal
Port eth0
Interface eth0
ovs_version: "2.14.2"
libvirt綁定ovs
$ sudo virsh net-list ///列出當(dāng)前虛擬化中定義的網(wǎng)絡(luò)
$ sudo virsh net-edit network ///編輯名稱為network的網(wǎng)絡(luò)
<network>
<name>ovsbr</name>
<uuid></uuid>
<forward mode='bridge'/>
<bridge name='ovsbr'/>
<virtualport type='openvswitch'/>
</network>
///配置文件為xml格式鳞上,轉(zhuǎn)發(fā)模式改為bridge,橋名稱即為ovs橋名稱绿贞,虛擬端口類型為openvswitch
到此因块,基本完成配置,后續(xù)創(chuàng)建虛擬機(jī)時(shí)籍铁,將網(wǎng)絡(luò)指向此處即可涡上。