目前遇到各戶新購的機器太新,得安裝 CentOS 8.3 的版本才有支援新的 Intel Chipset;然而,部分的 EDA tools 又只正運行在 CentOS 7 的OS 上,真的挺傷腦筋的。經過幾番波折後,才決定採取 CentOS 8.3 + KVM ( 安裝 CentOS 7.9) 的方式解決這些問題。預計的配置如下:
Host ( CentOS 8.3)
> NIS Server
> NFS Server
Guest ( KVM : CentOS 7.9 )
> Mount NFS Folder
> 加入 NIS Domain.
夢想是豐腴的,現實是骨感的。這幾個星期真的對這句話有相當的理解,主要在於自己對 KVM 的不熟悉,對此白走了不少路;尤其是在 Bridge network 的設定,更是傷神。好不容易透過網友無私地分享,總算搞定 bridge network for KVM。步驟如下:
- Open the Terminal app.
- Get info about the current connection
透過 nmcli connection 取得目前的網路設定資訊.[empyrean@WS1 ~]$ nmcli connection NAME UUID TYPE DEVICE enp0s3 3e19abc6-8e28-403c-94fa-89e17d7aaadf ethernet enp0s3 virbr0 2d7cae19-e9f5-4eda-a2a1-8fa753acf529 bridge virbr0 [empyrean@WS1 ~]$
- Add a new bridge
透過 nmcli con add ifname br0 type bridge con-name br0 建立一個新的 Bridge interface, br0.[root@WS1 empyrean]# nmcli con add ifname br0 type bridge con-name br0 Connection 'br0' (5fc144ab-fa54-4524-85f0-370007a89477) successfully added. [root@WS1 empyrean]# nmcli connection NAME UUID TYPE DEVICE br0 5fc144ab-fa54-4524-85f0-370007a89477 bridge br0 enp0s3 3e19abc6-8e28-403c-94fa-89e17d7aaadf ethernet enp0s3 virbr0 2d7cae19-e9f5-4eda-a2a1-8fa753acf529 bridge virbr0 [root@WS1 empyrean]#
-
Add a new slave bridge
透過 nmcli con add type bridge-slave ifname enp0s3 master br0 建立一個新的 slave interface, 用來連結 enp0s3 與 br0.[root@WS1 empyrean]# nmcli con add type bridge-slave ifname enp0s3 master br0 Connection 'bridge-slave-enp0s3' (8ebd4cb5-8bef-4bed-b420-c7772be7f3f0) successfully added. [root@WS1 empyrean]# nmcli connection NAME UUID TYPE DEVICE br0 5fc144ab-fa54-4524-85f0-370007a89477 bridge br0 enp0s3 3e19abc6-8e28-403c-94fa-89e17d7aaadf ethernet enp0s3 virbr0 2d7cae19-e9f5-4eda-a2a1-8fa753acf529 bridge virbr0 bridge-slave-enp0s3 8ebd4cb5-8bef-4bed-b420-c7772be7f3f0 ethernet -- [root@WS1 empyrean]#
-
Turn on Bridge interface
記得先透過這個指令 nmcli con down enp0s3 來 turn off 與 br0 連結的 ethernet device, enp0s3。
接這透過這個指令 nmcli con up br0 來 trun on bridge interface, br0.[root@WS1 empyrean]# nmcli con down enp0s3 Connection 'enp0s3' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/1) [root@WS1 empyrean]# nmcli connection NAME UUID TYPE DEVICE br0 5fc144ab-fa54-4524-85f0-370007a89477 bridge br0 virbr0 2d7cae19-e9f5-4eda-a2a1-8fa753acf529 bridge virbr0 bridge-slave-enp0s3 8ebd4cb5-8bef-4bed-b420-c7772be7f3f0 ethernet enp0s3 enp0s3 3e19abc6-8e28-403c-94fa-89e17d7aaadf ethernet -- [root@WS1 empyrean]# nmcli con up br0 Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/6) [root@WS1 empyrean]# nmcli connection NAME UUID TYPE DEVICE br0 5fc144ab-fa54-4524-85f0-370007a89477 bridge br0 virbr0 2d7cae19-e9f5-4eda-a2a1-8fa753acf529 bridge virbr0 bridge-slave-enp0s3 8ebd4cb5-8bef-4bed-b420-c7772be7f3f0 ethernet enp0s3 enp0s3 3e19abc6-8e28-403c-94fa-89e17d7aaadf ethernet -- [root@WS1 empyrean]#
完成上述步驟, bridge interface 就設定完成了。以上的設定預設都是透過 DHCP 來取得 IP,如果需要設定 static IP 則修改下檔案 (以本次的範例來說)的設定即可。
/etc/sysconfig/network-scripts/ifcfg-br0 <--- Guest Bridge 的網卡設定192.168.11.66 就是 Host OS 對外的 IP Address
STP=yes BRIDGING_OPTS=priority=32768 TYPE=Bridge PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPADDR=192.168.11.66 PREFIX=24 GATEWAY=192.168.11.1 DNS1=192.168.11.1 NAME=br0 UUID=e2a2bd9f-6ae0-415a-bf23-e63a9bbeef4d DEVICE=br0 ONBOOT=yes
到這裏,就完成 bridge interface 的設定。接下來就是KVM 的網路設定,Network source: 選取 Bridge br0 這個選項。
接下來 KVM 開機後,即可透過 Guest OS 內的網路設定來調整設定為 DHCP or Static IP. 下列為 Guest OS 的網路設定。
[test1@centos7 ~]$ cat /etc/sysconfig/network-scripts/ifcfg-eth0 TYPE=Ethernet PROXY_METHOD=none BROWSER_ONLY=no BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no NAME=eth0 UUID=2e6c1d54-bc71-4730-9f79-3bd29c3440bd DEVICE=eth0 ONBOOT=yes IPADDR=192.168.11.88 PREFIX=24 GATEWAY=192.168.11.1 DNS1=192.168.11.1 PEERDNS=no
最後作個測試
[test1@centos7 ~]$ ping -c 3 192.168.11.66
PING 192.168.11.66 (192.168.11.66) 56(84) bytes of data.
64 bytes from 192.168.11.66: icmp_seq=1 ttl=64 time=0.172 ms
64 bytes from 192.168.11.66: icmp_seq=2 ttl=64 time=0.099 ms
64 bytes from 192.168.11.66: icmp_seq=3 ttl=64 time=0.145 ms
--- 192.168.11.66 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 1999ms
rtt min/avg/max/mdev = 0.099/0.138/0.172/0.033 ms
[test1@centos7 ~]$ ping -c 3 192.168.11.1
PING 192.168.11.1 (192.168.11.1) 56(84) bytes of data.
64 bytes from 192.168.11.1: icmp_seq=1 ttl=64 time=0.352 ms
64 bytes from 192.168.11.1: icmp_seq=2 ttl=64 time=0.480 ms
64 bytes from 192.168.11.1: icmp_seq=3 ttl=64 time=0.600 ms
--- 192.168.11.1 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2000ms
rtt min/avg/max/mdev = 0.352/0.477/0.600/0.102 ms
=======================================================================
Reference : How to add network bridge with nmcli (NetworkManager) on Linux
留言列表