基于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

依据如图方式,进行修改:

基于RHEL8/CentOS8的网络基础配置_第1张图片

 

  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

 

基于RHEL8/CentOS8的网络基础配置_第2张图片

 

 

  虽然,直接将NAME="mlx4_ib3"修改成NAME="eth0" 也能达到第二章中的效果(修改网卡名),但是不推荐在此文件中修改!因为此文件在centos6.4时一般应用于:解决克隆主机MAC地址冲突的现象。在解决克隆主机MAC地址冲突时,记得字母大写小写的区别!

 

你可能感兴趣的:(基于RHEL8/CentOS8的网络基础配置)