CentOS 8/9 nmcli 设置IP

分类:笔记 297浏览

CentOS 8/9手动设置IPv4

1、查看目前网卡UP情况

nmcli connection


2、手动设置IP

nmcli connection
nmcli connection modify "ens2f1" ipv4.addresses "172.20.10.3/24" ##地址及掩码
nmcli connection modify "ens2f1" ipv4.gateway "172.20.10.1" #网关
nmcli connection modify "ens2f1" ipv4.dns "114.114.114.114" ##域名DNS
nmcli connection modify "ens2f1" ipv4.method manual ##设置为手动
nmcli connection modify "ens2f1" connection.autoconnect yes ##开机启动
nmcli connection up "ens2f1" #开启接口

3、重启(如有必要)

systemctl restart NetworkManager