最近安装新一代的redhat看看整体的变化,对于系统安装来说,第一步的网卡配置也发生了变化。基本上大家原来都习惯于通过/etc/sysconfig/network-scripts/目录进行网卡配置的管理,新一代的系统使用nmcli进行管理。

这个工具还蛮好用,实话而言。

首先看看本机有什么网卡:

nmcli device show

确定网卡之后就可以进行基础的ip地址的手动配置

nmcli connection edit ens160 

===| nmcli interactive connection editor |=== Editing existing '802-3-ethernet' connection: 'ens160' Type 'help' or '?' for available commands. Type 'print' to show all the connection properties. Type 'describe [<setting>.<prop>]' for detailed property description. You may edit the following settings: connection, 802-3-ethernet (ethernet), 802-1x, dcb, sriov, ethtool, match, ipv4, ipv6, hostname, tc, proxy 

nmcli> set ipv4.addresses 192.168.100.99/24 

Do you also want to set 'ipv4.method' to 'manual'? [yes]: yes 

nmcli> set ipv4.gateway 192.168.100.2 

nmcli> save Connection 'ens160' (4d698bde-391b-3883-b2de-398cbb7e092b) successfully updated. 
nmcli> quit

退出之后,让配置生效:
nmcli connection up ens160
查看连接状态:
nmcli connection show

DNS的配置,还是和上边一样:
nmcli connection edit ens160 
nmcli> set ipv4.dns 223.5.5.5
nmcli> save
Connection 'ens160' (4d698bde-391b-3883-b2de-398cbb7e092b) successfully updated.
nmcli> quit
nmcli connection up ens160

最后修改日期: 2023年11月7日

留言

撰写回覆或留言

发布留言必须填写的电子邮件地址不会公开。