CentOS8网络配置

CentOS8网络配置
CentOS8已无法正常使用network服务。

[root@localhost ~]# systemctl status network
Unit network.service could not be found.
[root@localhost ~]#
1
2
3
一、CentOS8配置网络三种方法
1、配置ifcfg文件,使用nmcli来生效新的网络配置
[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
NAME=ens33
UUID=4a0c3fda-c0c4-4b84-af1f-257817c3592e
DEVICE=ens33
ONBOOT=no
IPADDR=192.168.10.20
PREFIX=24
GATEWAY=192.168.10.1
[root@localhost ~]#

[root@localhost ~]# nmcli c reload

[root@localhost ~]# nmcli c up nes33
1
2
3
4`Last login: Wed May 11 17:18:37 2022 from 192.168.20.1

node status: OK
See nodectl check for more information



Admin Console: https://192.168.20.100:9090/

[root@node ~]# yum install network-scripts
Failed to set locale, defaulting to C.UTF-8
CentOS-8-stream - Ceph Pacific                  290 kB/s | 405 kB     00:01
oVirt Node Optional packages from CentOS Stream 2.7 MB/s |  22 MB     00:08
oVirt Node Optional packages from CentOS Stream 868 kB/s |  22 MB     00:25
Latest oVirt 4.4 Release                        9.4 kB/s | 2.7 MB     04:58
Extra Packages for Enterprise Linux 8 - x86_64  3.8 MB/s |  11 MB     00:02
CentOS-8-stream - Gluster 8                      49 kB/s |  42 kB     00:00
virtio-win builds roughly matching what will be  55 kB/s | 153 kB     00:02
Copr repo for EL8_collection owned by sbonazzo  104 kB/s | 246 kB     00:02
Copr repo for gluster-ansible owned by sac      4.1 kB/s | 7.3 kB     00:01
CentOS-8 - Advanced Virtualization              161 kB/s | 207 kB     00:01
CentOS-8 - oVirt 4.4                            944 kB/s | 1.2 MB     00:01
CentOS-8 - OpsTools - collectd                   61 kB/s |  41 kB     00:00
CentOS-8 - OpsTools - collectd - vault           83 kB/s | 149 kB     00:01
CentOS-8 - NFV OpenvSwitch                      126 kB/s | 133 kB     00:01
CentOS-8 - OpenStack victoria                   748 kB/s | 3.2 MB     00:04
All matches were filtered out by exclude filtering for argument: network-scripts
Error: Unable to find a match: network-scripts
`
5
6

9
10
11
12
13
14
15
16
23
24
2、使用nmcli管理网络

添加IP

nmcli connection modity ens33 ipv4.address 192.168.10.20

添加掩码

nmcli connection modity ens33 ipv4.address 192.168.10.20/24

添加网关

nmcli connection modity ens33 ipv4.gateway 192.168.10.1

设置IP获取方式为手动/自动

nmcli connection modity ens33 ipv4.method manual

添加DNS

nmcli connection modity ipv4.dns 114.114.114.114

查看网卡信息

nmcli connection

显示具体的网络接口信息

nmcli connection ens33

显示所有活动连接

nmcli connection show --active

删除一个网卡

nmcli connection delete ens33

删除DNS

nmcli connection modity ens33 -ipv4.dns 114.114.114.114
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
3、安装network服务
可通过yum install network-scripts来安装传统的network服务。

二、CentOS8修改网卡名称
1、删除网卡
[root@localhost ~]# nmcli connection delete ens33
1
2、修改内核参数配置文件
[root@localhost ~]# cp /etc/default/grub /etc/default/grub.bak
[root@localhost ~]# sed -i ‘s/rhgb/net.ifnames=0 &/’ /etc/default/grub
1
2
3、植入内核
[root@localhost ~]# grub2-mkconfig -o /boot/grub2/grub.cfg
1
4、修改网卡命名规则

不修改命名规则device名称无法生效

[root@localhost ~]# echo ‘ACTION==“add”, SUBSYSTEM==“net”, DRIVERS==“?*”, ATTR{address}==“00:0c:29:15:f5:64”, NAME=“eth0”’ >>/usr/lib/udev/rules.d/60-net.rules
1
2
5、重启
[root@localhost ~]# reboot
1
6、修改网卡
[root@localhost ~]# nmcli connection modity eth0 ipv4.address 192.168.10.20/24 ipv4.gateway 192.168.10.1 ipv4.method manual
[root@localhost ~]# nmcli c reload
[root@localhost ~]# nmcli c up eth0
————————————————
版权声明:本文为CSDN博主「无痕有静」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/qq_41112887/article/details/121490732

你可能感兴趣的:(网络,linux,centos)