您好,登錄后才能下訂單哦!
這期內容當中小編將會給大家帶來有關VM與VBOX中CentOS 7是怎么配置網卡,文章內容豐富且以專業的角度為大家分析和敘述,閱讀完這篇文章希望大家可以有所收獲。
我們經常需要復制VM和VBOX的虛擬機,繞不開的一個步驟是網卡的重新配置。
有時候這個東西特別繁瑣。
這里記錄一個稍微簡單的操作,沒有udev的設備綁定各種騷操作。。。
1、 新復制的虛擬機,請選擇重新生成MAC地址,這個步驟在復制(克隆,WHATEVER)的時候,或者在復制完成,又或者完成后點配置,網卡屬性,高級屬性(各種平臺各不相同,找到重新生成MAC地址,勾上或者刷新)。記錄下這個MAC地址
2、新虛擬機啟動以后,無論網絡是否正常,停掉NetworkManager.Service...真的沒有那么好用。
systemctl stop NetworkManager
systemctl disable NetworkManager
3、運行ifconfig -a, 得到新網卡的網卡名稱,(也是設備名稱,結合剛才記錄下的MAC地址,很容易對上)
4、到/etc/sysconfig/network-scripts文件夾修改ifcfg-enxxx網卡啟動配置文件
4.1、 強烈建議刪除ifcfg-profile1類似這個腳本,這個是NetManager遺留。
4.2、 用uuidgen enxxx這樣的格式得到uuid寫入配置檔。
4.3、 寫完配置檔,重啟網卡設備systemctl restart network。如果沒有報錯就完成了。
####舉例:
###配置一個網卡最終要三個要素,設備名,MAC地址,UUID
eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.201 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::20c:29ff:fe4a:b12c prefixlen 64 scopeid 0x20<link> ether 00:0c:29:4a:b1:2c txqueuelen 1000 (Ethernet) RX packets 3647 bytes 3417904 (3.2 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 142 bytes 18249 (17.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 eno33554992: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.199.241 netmask 255.255.255.0 broadcast 192.168.199.255 inet6 fe80::20c:29ff:fe4a:b136 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:4a:b1:36 txqueuelen 1000 (Ethernet) RX packets 5605 bytes 3465915 (3.3 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 1400 bytes 322360 (314.8 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
###uuidgen (注意,UUID每次生成都不同,但是每個生成的ID都是可以用的)
[root@mysql01 dev]# uuidgen eno16777736 fd32246b-c655-45c6-ab6a-7a6aa84faa72 [root@mysql01 network-scripts]# uuidgen eno33554992 44e70d2f-4bf1-4753-865b-8fb042ecc8d6
設備名 | MAC地址 | UUID |
---|---|---|
eno16777736 | 00:0c:29:4a:b1:2c | fd32246b-c655-45c6-ab6a-7a6aa84faa72 |
eno33554992 | 00:0c:29:4a:b1:36 | 44e70d2f-4bf1-4753-865b-8fb042ecc8d6 |
###停止NetworkManager
[root@mysql01 network-scripts]# systemctl stop NetworkManager [root@mysql01 network-scripts]# systemctl disable NetworkManager Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service. Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service. Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service. [root@mysql01 network-scripts]# systemctl status NetworkManager * NetworkManager.service - Network Manager Loaded: loaded (/usr/lib/systemd/system/NetworkManager.service; disabled; vendor preset: enabled) Active: inactive (dead) since 日 2020-01-26 14:22:15 CST; 36s ago Main PID: 8417 (code=exited, status=0/SUCCESS) 1月 26 14:22:07 mysql01 NetworkManager[8417]: <info> (eno16777736): Activation: successful, device activated. 1月 26 14:22:07 mysql01 NetworkManager[8417]: <info> wpa_supplicant running 1月 26 14:22:07 mysql01 NetworkManager[8417]: <info> (virbr0): device state change: secondaries -> activated (reason 'none...100 0] 1月 26 14:22:07 mysql01 NetworkManager[8417]: <info> (virbr0): Activation: successful, device activated. 1月 26 14:22:15 mysql01 NetworkManager[8417]: <info> caught SIGTERM, shutting down normally. 1月 26 14:22:15 mysql01 NetworkManager[8417]: <info> (virbr0): bridge port virbr0-nic was detached 1月 26 14:22:15 mysql01 NetworkManager[8417]: <info> (virbr0-nic): released from master virbr0 1月 26 14:22:15 mysql01 systemd[1]: Stopping Network Manager... 1月 26 14:22:15 mysql01 NetworkManager[8417]: <info> exiting (success) 1月 26 14:22:15 mysql01 systemd[1]: Stopped Network Manager. Hint: Some lines were ellipsized, use -l to show in full. [root@mysql01 network-scripts]# ifconfig
###寫配置檔:(這里的UUID可能和我上面獲得的不同,因為配置檔是之前就寫好的.)
-rw-r--r--. 1 root root 292 1月 24 14:52 ifcfg-eno16777736
-rw-r--r--. 1 root root 367 1月 26 13:29 ifcfg-eno33554992
[root@mysql01 network-scripts]# cat ifcfg-eno16777736 TYPE=Ethernet BOOTPROTO=none DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no NAME=eno16777736 UUID=a808b074-580f-4ff7-b70a-e307769e8d96 DEVICE=eno16777736 ONBOOT=yes IPADDR=192.168.1.201 PREFIX=24 IPV6_PEERDNS=yes IPV6_PEERROUTES=yes [root@mysql01 network-scripts]# cat ifcfg-eno33554992 TYPE=Ethernet BOOTPROTO=static IPADDR0=192.168.199.241 PREFIXO0=24 GATEWAY=192.168.199.1 DNS1=192.168.199.1 DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no NAME=eno33554992 UUID=9c7d8550-2d46-45c1-9c40-ef09570e1608 DEVICE=eno33554992 ONBOOT=yes PEERDNS=yes PEERROUTES=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes
###重啟網絡服務:
[root@mysql01 network-scripts]# systemctl restart network.service [root@mysql01 network-scripts]#
###沒有報錯
[root@mysql01 network-scripts]# systemctl status network.service * network.service - LSB: Bring up/down networking Loaded: loaded (/etc/rc.d/init.d/network) Active: active (exited) since 日 2020-01-26 14:27:22 CST; 18s ago Docs: man:systemd-sysv-generator(8) Process: 8612 ExecStop=/etc/rc.d/init.d/network stop (code=exited, status=0/SUCCESS) Process: 8839 ExecStart=/etc/rc.d/init.d/network start (code=exited, status=0/SUCCESS) 1月 26 14:27:17 mysql01 systemd[1]: Starting LSB: Bring up/down networking... 1月 26 14:27:17 mysql01 network[8839]: [29B blob data] 1月 26 14:27:19 mysql01 network[8839]: [37B blob data] 1月 26 14:27:22 mysql01 network[8839]: [37B blob data] 1月 26 14:27:22 mysql01 systemd[1]: Started LSB: Bring up/down networking. [root@mysql01 network-scripts]#
###嘗試ifup/ifdown腳本:
[root@mysql01 network-scripts]# ifdown eno16777736 [root@mysql01 network-scripts]# ifconfig eno16777736 eno16777736: flags=4098<BROADCAST,MULTICAST> mtu 1500 ether 00:0c:29:4a:b1:2c txqueuelen 1000 (Ethernet) RX packets 4359 bytes 4215191 (4.0 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 169 bytes 22144 (21.6 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@mysql01 network-scripts]# ifup eno16777736 [root@mysql01 network-scripts]# ifconfig eno16777736 eno16777736: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.1.201 netmask 255.255.255.0 broadcast 192.168.1.255 inet6 fe80::20c:29ff:fe4a:b12c prefixlen 64 scopeid 0x20<link> ether 00:0c:29:4a:b1:2c txqueuelen 1000 (Ethernet) RX packets 4362 bytes 4218484 (4.0 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 187 bytes 25011 (24.4 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@mysql01 network-scripts]# [root@mysql01 network-scripts]# ifdown eno33554992 [root@mysql01 Desktop]# ifconfig eno33554992 eno33554992: flags=4098<BROADCAST,MULTICAST> mtu 1500 ether 00:0c:29:4a:b1:36 txqueuelen 1000 (Ethernet) RX packets 7980 bytes 4516864 (4.3 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2422 bytes 504771 (492.9 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@mysql01 Desktop]# ifup eno33554992 [root@mysql01 Desktop]# ifconfig eno33554992 eno33554992: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 192.168.199.241 netmask 255.255.255.0 broadcast 192.168.199.255 inet6 fe80::20c:29ff:fe4a:b136 prefixlen 64 scopeid 0x20<link> ether 00:0c:29:4a:b1:36 txqueuelen 1000 (Ethernet) RX packets 7982 bytes 4519567 (4.3 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 2440 bytes 507648 (495.7 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 [root@mysql01 Desktop]#
上述就是小編為大家分享的VM與VBOX中CentOS 7是怎么配置網卡了,如果剛好有類似的疑惑,不妨參照上述分析進行理解。如果想知道更多相關知識,歡迎關注億速云行業資訊頻道。
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。