1. 程式人生 > >基於RHEL8/CentOS8的網路基礎配置

基於RHEL8/CentOS8的網路基礎配置

  在rhel7上,同時支援network.service和NetworkManager.service(簡稱NM)。預設情況下,這2個服務都有開啟,但許多人都會將NM禁用掉。而在rhel8上,已廢棄network.service,因此只能通過NM進行網路配置,包括動態ip和靜態ip。換言之,在rhel8上,必須開啟NM,否則無法使用網路。至於什麼是NM?這裡就不詳述,對於NM的常用命令附如下:

# 檢視ip(類似於ifconfig、ip addr)
nmcli

# 建立connection,配置靜態ip(等同於配置ifcfg,其中BOOTPROTO=none,並ifup啟動)
nmcli c add type ethernet con-name ethX ifname ethX ipv4.addr 192.168.1.100/24 ipv4.gateway 192.168.1.1 ipv4.method manual

# 建立connection,配置動態ip(等同於配置ifcfg,其中BOOTPROTO=dhcp,並ifup啟動)
nmcli c add type ethernet con-name ethX ifname ethX ipv4.method auto

# 修改ip(非互動式)
nmcli c modify ethX ipv4.addr '192.168.1.200/24'
nmcli c up ethX

# 修改ip(互動式)
nmcli c edit ethX
nmcli> goto ipv4.addresses
nmcli ipv4.addresses> change
Edit 'addresses' value: 192.168.1.200/24
Do you also want to set 'ipv4.method' to 'manual'? [yes]: yes
nmcli ipv4> save
nmcli ipv4> activate
nmcli ipv4> quit

# 啟用connection(相當於ifup)
nmcli c up ethX

# 停止connection(相當於ifdown)
nmcli c down

# 刪除connection(類似於ifdown並刪除ifcfg)
nmcli c delete ethX

# 檢視connection列表
nmcli c show

# 檢視connection詳細資訊
nmcli c show ethX

# 過載所有ifcfg或route到connection(不會立即生效)
nmcli c reload

# 過載指定ifcfg或route到connection(不會立即生效)
nmcli c load /etc/sysconfig/network-scripts/ifcfg-ethX
nmcli c load /etc/sysconfig/network-scripts/route-ethX

# 立即生效connection,有3種方法
nmcli c up ethX
nmcli d reapply ethX
nmcli d connect ethX

# 檢視device列表
nmcli d

# 檢視所有device詳細資訊
nmcli d show

# 檢視指定device的詳細資訊
nmcli d show ethX

# 啟用網絡卡
nmcli d connect ethX

# 關閉無線網路(NM預設啟用無線網路)
nmcli r all off

# 檢視NM納管狀態
nmcli n

# 開啟NM納管
nmcli n on

# 關閉NM納管(謹慎執行)
nmcli n off

# 監聽事件
nmcli m

# 檢視NM本身狀態
nmcli

# 檢測NM是否線上可用
nm-online

 

一、固定IP的修改

  1、由於這裡硬體資源有限,僅以VM的方式進行演示。首先,你要擁有一臺已經安裝好的CentOS8虛擬機器系統,同時,在安裝的過程中設定了網路連線狀態開啟。登入系統後,切換root使用者,因為普通使用者在網路連線設定或者配置檔案vi修改方面,許可權存在弱容忍現象。這時候切換到“/etc/sysconfig/network-scripts”路徑下:

cd /etc/sysconfig/network-scripts

  

  2、我們先看一下,剛開始時候系統動態獲取的IP地址:

[root@localhost network-scripts]# ifconfig
ens33: 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::5f41:9d04:e548:874a  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:c4:36:8d  txqueuelen 1000  (Ethernet)
        RX packets 30433  bytes 2139129 (2.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 41776  bytes 33082603 (31.5 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 331  bytes 36750 (35.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 331  bytes 36750 (35.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 52:54:00:a5:84:87  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
返回資訊

  

 ** 3、這裡還要進行多餘的一步,就是進行ifcfg-ens33檔案的備份,便於日後的恢復操作:

[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens33.bak
[root@localhost network-scripts]# ll
總用量 4
-rw-r--r--. 1 root root 280 9月  29 19:21 ifcfg-ens33
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-ens33.bak
[root@localhost network-scripts]# ll
總用量 8
-rw-r--r--. 1 root root 280 9月  29 19:21 ifcfg-ens33
-rw-r--r--. 1 root root 280 9月  29 19:27 ifcfg-ens33.bak
操作過程

 

  4、使用vi編輯 ifcfg-ens33 檔案,將 “ BOOTPROTO=dhcp ”修改為“ BOOTPROTO=static ” ,其它先不必修改,儲存並退出。下面是我修改後的樣子:

[root@localhost network-scripts]# more ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=0b897d67-bab3-4354-99cb-0cb3678a7036
DEVICE=ens33
ONBOOT=yes
檢視修改後內容

 

     5、 利用附加輸出重定向原理,對ifcfg-ens33檔案追加如下內容:(也可以在上一步中,直接追加!  這裡為了再練習一下今天學習的內容!)

    輸入命令: 

[root@localhost network-scripts]# cat >>ifcfg-ens33

            輸入如下追加內容,並按“ Ctrl + D ”,結束並完成內容的輸入:

IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=223.5.5.5
PREFIX=24
[root@localhost network-scripts]# cat >>ifcfg-ens33
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=223.5.5.5
PREFIX=24
[root@localhost network-scripts]# cat ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=0b897d67-bab3-4354-99cb-0cb3678a7036
DEVICE=ens33
ONBOOT=yes
IPADDR=192.168.1.100
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=223.5.5.5
PREFIX=24
操作過程

 

  6、對修改的內容進行NM載入,如下:

[root@localhost network-scripts]# nmcli c reload




[root@localhost network-scripts]# ifconfig
ens33: 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::5f41:9d04:e548:874a  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:c4:36:8d  txqueuelen 1000  (Ethernet)
        RX packets 31416  bytes 2236251 (2.1 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 42243  bytes 33136317 (31.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 331  bytes 36750 (35.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 331  bytes 36750 (35.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 52:54:00:a5:84:87  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0







[root@localhost network-scripts]# nmcli c down ens33
[root@localhost network-scripts]# nmcli c up ens33




[root@localhost network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.100  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::5f41:9d04:e548:874a  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:c4:36:8d  txqueuelen 1000  (Ethernet)
        RX packets 32245  bytes 2427805 (2.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 42474  bytes 33182687 (31.6 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 359  bytes 39566 (38.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 359  bytes 39566 (38.6 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 52:54:00:a5:84:87  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

    注意:在進行完nmcli c down ens33 和nmcli c up ens33 ,即網絡卡重啟操作,需要等待兩分鐘,如果期間使用Windows的cmd進行登入會出現“Connection reset by 192.168.1.100 port 22”現象。出現這種現象不必慌張,繼續等待一分鐘即可。具體如下:

[root@localhost network-scripts]# nmcli c down ens33
Connection reset by 192.168.1.201 port 22

C:\Users\Raodi>ssh 192.168.1.100
Connection reset by 192.168.1.100 port 22

C:\Users\Raodi>ssh 192.168.1.100
ssh_exchange_identification: read: Connection reset

C:\Users\Raodi>ssh 192.168.1.100
The authenticity of host '192.168.1.100 (192.168.1.100)' can't be established.
ECDSA key fingerprint is SHA256:DW5Z0SLNckIiIIqJNorcH2mo8VrIFu1tCXbHrhTSMTk.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.100' (ECDSA) to the list of known hosts.
[email protected]'s password:
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Sun Sep 29 18:59:20 2019 from 192.168.1.108
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Sun Sep 29 18:59:20 2019 from 192.168.1.108
[raodi@localhost ~]$
外設登入意外和重登成功

 

 

糟糕:

 我等了兩分鐘,剛開始還能ping通www.baidu.com  ,可第三分鐘之後,不管是系統內部終端還是Windows的cmd都報錯了,如下:

[root@localhost network-scripts]# ping www.baidu.com
PING www.a.shifen.com (183.232.231.174) 56(84) bytes of data.
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=1 ttl=55 time=25.8 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=2 ttl=55 time=15.3 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=3 ttl=55 time=16.3 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=4 ttl=55 time=15.6 ms
^C
--- www.a.shifen.com ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 7ms
rtt min/avg/max/mdev = 15.313/18.252/25.779/4.362 ms
[root@localhost network-scripts]# ping www.baidu.com
ping: www.baidu.com: 未知的名稱或服務
[root@localhost network-scripts]# ping www.baidu.com
ping: www.baidu.com: 未知的名稱或服務
[root@localhost network-scripts]# ping www.baidu.com
ping: www.baidu.com: 未知的名稱或服務











C:\Users\Raodi>ssh 192.168.1.100
ssh_exchange_identification: read: Connection reset

C:\Users\Raodi>ssh 192.168.1.100
write: Connection reset

C:\Users\Raodi>ssh 192.168.1.100
ssh_exchange_identification: read: Connection reset

C:\Users\Raodi>ssh 192.168.1.100
write: Connection reset

C:\Users\Raodi>ssh 192.168.1.100
ssh_exchange_identification: read: Connection reset

C:\Users\Raodi>ssh 192.168.1.100
write: Connection reset

C:\Users\Raodi>ssh 192.168.1.100
ssh_exchange_identification: read: Connection reset
失敗配置的惡性現象

配置靜態ip的要求:

  • 在區域網或者片網區域內,存在已有IP終端的IP不能使用!
  • 各自的DNS有所區別。看似DNS都可以使用,如“114.114.114.114”或者“223.5.5.5”。但是,這裡不建議使用通配的方法,如果你的虛擬系統是直接橋接無線路由器的,DNS通常使用“192.168.1.1” ,不具實地的DNS配置,很可能會拖慢我們主機與外網的互相通訊能力!

  (正因為,我上述的配置過程和配置內容,均違反了配置要求條件,所以出現這種現象也不足為怪了)

 

 

 

二、修改網絡卡名

  有時候,我們甚至一度習慣於eth0,而對於ens33很難做到情有獨鍾,看到都表示難以接受。修改前的ifconfig返回資訊:

[root@localhost network-scripts]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.230  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::5f41:9d04:e548:874a  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:c4:36:8d  txqueuelen 1000  (Ethernet)
        RX packets 37056  bytes 3463136 (3.3 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 44001  bytes 33507729 (31.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 415  bytes 45198 (44.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 415  bytes 45198 (44.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        ether 52:54:00:a5:84:87  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
修改前ifconfig返回資訊

 

  我們這裡將ens33改回eth0的網絡卡裝置型別,如下:

  1、首先,將ifcfg-ens33備份出一個ifcfg-eth0檔案

[root@localhost network-scripts]# ll
總用量 8
-rw-r--r--. 1 root root 372 9月  29 20:12 ifcfg-ens33
-rw-r--r--. 1 root root 280 9月  29 19:27 ifcfg-ens33.bak
[root@localhost network-scripts]# cp ifcfg-ens33 ifcfg-eth0
[root@localhost network-scripts]# ll
總用量 12
-rw-r--r--. 1 root root 372 9月  29 20:12 ifcfg-ens33
-rw-r--r--. 1 root root 280 9月  29 19:27 ifcfg-ens33.bak
-rw-r--r--. 1 root root 372 9月  29 20:48 ifcfg-eth0
操作過程

 

  2、修改ifcfg-eth0檔案中的“ NAME=ens33 ” 和“ DEVICE=ens33 ”,變成“  NAME=eth0 ”和“ DEVICE=eth0 ”。具體修改資訊如下:

[root@localhost network-scripts]# cat ifcfg-eth0
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=static
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=eth0
UUID=0b897d67-bab3-4354-99cb-0cb3678a7036
DEVICE=eth0
ONBOOT=yes
IPADDR=192.168.1.250
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=192.168.1.1
PREFIX=24
修改後的ifcfg-eth0檔案內容

 

  3、禁用可預測名稱空間屬性。可以在啟動時傳遞“net.ifnames=0 biosdevname=0 ”的核心引數。這是通過編輯/etc/default/grub並加入“net.ifnames=0 biosdevname=0 ”到GRUBCMDLINELINUX變數來實現的。

[root@localhost network-scripts]# vi /etc/default/grub

依據如圖方式,進行修改:

 

  4、更新核心引數。重新生成GRUB配置並更新核心引數。

[root@localhost network-scripts]# grub2-mkconfig -o /boot/grub2/grub.cfg
Generating grub configuration file ...
done

 

  5、重啟系統。進行系統核心引數的載入。

[root@localhost network-scripts]# reboot
Connection to 192.168.1.230 closed by remote host.
Connection to 192.168.1.230 closed.

 

  6、驗證修改完成。開機後,重新登入系統,我使用cmd登入也沒有問題。

[raodi@localhost ~]$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.250  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::36f1:291f:dbae:d020  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:c4:36:8d  txqueuelen 1000  (Ethernet)
        RX packets 15  bytes 1264 (1.2 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 45  bytes 4998 (4.8 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 48  bytes 5616 (5.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 48  bytes 5616 (5.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:a5:84:87  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[raodi@localhost ~]$ ping www.baidu.com
PING www.a.shifen.com (183.232.231.172) 56(84) bytes of data.
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=1 ttl=55 time=15.4 ms
64 bytes from 183.232.231.172 (183.232.231.172): icmp_seq=2 ttl=55 time=15.9 ms
^C
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 3ms
rtt min/avg/max/mdev = 15.436/15.677/15.918/0.241 ms
[raodi@localhost ~]$ 
主機終端
C:\Users\Raodi>ssh 192.168.1.250
The authenticity of host '192.168.1.250 (192.168.1.250)' can't be established.
ECDSA key fingerprint is SHA256:DW5Z0SLNckIiIIqJNorcH2mo8VrIFu1tCXbHrhTSMTk.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.1.250' (ECDSA) to the list of known hosts.
[email protected]'s password:
Activate the web console with: systemctl enable --now cockpit.socket

Last login: Sun Sep 29 21:07:38 2019
[raodi@localhost ~]$ ll
總用量 0
drwxr-xr-x. 2 raodi raodi 6 9月  27 13:44 公共
drwxr-xr-x. 2 raodi raodi 6 9月  27 13:44 模板
drwxr-xr-x. 2 raodi raodi 6 9月  27 13:44 視訊
drwxr-xr-x. 2 raodi raodi 6 9月  27 13:44 圖片
drwxr-xr-x. 2 raodi raodi 6 9月  27 13:44 文件
drwxr-xr-x. 2 raodi raodi 6 9月  27 13:44 下載
drwxr-xr-x. 2 raodi raodi 6 9月  27 13:44 音樂
drwxr-xr-x. 2 raodi raodi 6 9月  27 13:44 桌面
[raodi@localhost ~]$ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.250  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::36f1:291f:dbae:d020  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:c4:36:8d  txqueuelen 1000  (Ethernet)
        RX packets 119  bytes 12048 (11.7 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 89  bytes 11411 (11.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 48  bytes 5616 (5.4 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 48  bytes 5616 (5.4 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

virbr0: flags=4099<UP,BROADCAST,MULTICAST>  mtu 1500
        inet 192.168.122.1  netmask 255.255.255.0  broadcast 192.168.122.255
        ether 52:54:00:a5:84:87  txqueuelen 1000  (Ethernet)
        RX packets 0  bytes 0 (0.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 0  bytes 0 (0.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[raodi@localhost ~]$ ping www.baidu.com
PING www.a.shifen.com (183.232.231.174) 56(84) bytes of data.
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=1 ttl=55 time=15.5 ms
64 bytes from 183.232.231.174 (183.232.231.174): icmp_seq=2 ttl=55 time=15.2 ms
^C
--- www.a.shifen.com ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 3ms
rtt min/avg/max/mdev = 15.198/15.373/15.549/0.214 ms
[raodi@localhost ~]$
cmd連線

 

 

三、70-persistent-ipoib.rules檔案規則

[raodi@localhost rules.d]$ vi /etc/udev/rules.d/70-persistent-ipoib.rules

 

 

 

  雖然,直接將NAME="mlx4_ib3"修改成NAME="eth0"  ,也能達到第二章中的效果(修改網絡卡名),但是不推薦在此檔案中修改!因為此檔案在centos6.4時一般應用於:解決克隆主機MAC地址衝突的現象。在解決克隆主機MAC地址衝突時,記得字母大寫小寫的區別!

&n