[手動解決]:
找出目前所有網卡
# dmesg | grep -in eth 387:[ 2.074571] e1000 0000:00:03.0 eth0: (PCI:33MHz:32-bit) 08:00:27:37:d5:5a 388:[ 2.074587] e1000 0000:00:03.0 eth0: Intel(R) PRO/1000 Network Connection 412:[ 2.571363] e1000 0000:00:08.0 eth1: (PCI:33MHz:32-bit) 08:00:27:03:28:44 413:[ 2.571371] e1000 0000:00:08.0 eth1: Intel(R) PRO/1000 Network Connection 417:[ 2.588359] systemd-udevd[244]: renamed network interface eth1 to enp0s8 420:[ 2.597290] systemd-udevd[241]: renamed network interface eth0 to enp0s3
找出新網卡名稱
對照 ifconfig 的訊息,可判斷出新網卡的名稱為 enp0s8
# ifconfig enp0s3: flags=4163 mtu 1500 inet 192.168.56.101 netmask 255.255.255.0 broadcast 192.168.56.255 inet6 fe80::a00:27ff:fe37:d55a prefixlen 64 scopeid 0x20 ether 08:00:27:37:d5:5a txqueuelen 1000 (Ethernet) RX packets 6911 bytes 3960745 (3.7 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 6048 bytes 1263062 (1.2 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
其他(目前系統上的網卡名稱):
# cat /proc/net/dev Inter-| Receive | Transmit face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed enp0s3: 3448 25 0 0 0 0 0 0 5770 64 0 0 0 0 0 0 enp0s8: 26607 173 0 0 0 0 0 0 27360 154 0 0 0 0 0 0 lo: 656 8 0 0 0 0 0 0 656 8 0 0 0 0 0 0
產生新網卡的 UUID
# uuidgen enp0s8 297daa1e-a83d-471e-b70d-83eafb2f2470
找出新網卡 mac address
可由第1步驟輸出訊息可找出為 08:00:27:03:28:44
建立新網卡設定檔
複製舊的修改
# cd /etc/sysconfig/network-scripts/ # cp ifcfg-enp0s3 ifcfg-enp0s8NAME、UUID、DEVICE、HWADDR修改為新網卡資料
# vi ifcfg-enp0s8 TYPE=Ethernet BOOTPROTO=dhcp DEFROUTE=yes IPV4_FAILURE_FATAL=no IPV6INIT=yes IPV6_AUTOCONF=yes IPV6_DEFROUTE=yes IPV6_FAILURE_FATAL=no NAME=enp0s8 UUID=297daa1e-a83d-471e-b70d-83eafb2f2470 DEVICE=enp0s8 HWADDR=08:00:27:03:28:44 ONBOOT=yes PEERDNS=yes PEERROUTES=yes IPV6_PEERDNS=yes IPV6_PEERROUTES=yes
啟動新網卡
# ifup enp0s8
# ifconfig enp0s3: flags=4163 mtu 1500 inet 192.168.56.101 netmask 255.255.255.0 broadcast 192.168.56.255 inet6 fe80::a00:27ff:fe37:d55a prefixlen 64 scopeid 0x20 ether 08:00:27:37:d5:5a txqueuelen 1000 (Ethernet) RX packets 9110 bytes 5349053 (5.1 MiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 7662 bytes 1562108 (1.4 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0 enp0s8: flags=4163 mtu 1500 inet 192.168.0.124 netmask 255.255.255.0 broadcast 192.168.0.255 inet6 fe80::a00:27ff:fe03:2844 prefixlen 64 scopeid 0x20 ether 08:00:27:03:28:44 txqueuelen 1000 (Ethernet) RX packets 441 bytes 43254 (42.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 63 bytes 10391 (10.1 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
其他:指定固定IP設定
TYPE="Ethernet" #可略 BOOTPROTO="static" #可略 DEFROUTE="yes" #可略 IPV4_FAILURE_FATAL="no" #可略 IPV6INIT="yes" #可略 IPV6_AUTOCONF="yes" #可略 IPV6_DEFROUTE="yes" #可略 IPV6_FAILURE_FATAL="no" #可略 NAME="enp0s8" UUID="297daa1e-a83d-471e-b70d-83eafb2f2470" DEVICE="enp0s8" ONBOOT="yes" IPADDR="192.168.56.102" PREFIX="24" #GATEWAY="192.168.56.1" #VirtualBox Host-only Adapter(另用NAT訪問internet) DNS1="8.8.8.8" #可略 IPV6_PEERDNS="yes" #可略 IPV6_PEERROUTES="yes" #可略 IPV6_PRIVACY="no" #可略
參考:
生活點點滴滴: VirtualBox CentOS 新增網卡
CentOS virtualbox no icfg-eth1 when adding secondary network interface
How to change configuration of eth0 without restarting other interface (CentOS, Redhat)
沒有留言:
張貼留言