使用ip link 命令找到网络接口名称
[student@workstation ~]$ ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP mode DEFAULT group default qlen 1000
link/ether 52:54:00:00:fa:09 brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
link/ether 52:54:00:b5:99:cf brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc fq_codel master virbr0 state DOWN mode DEFAULT group default qlen 1000
link/ether 52:54:00:b5:99:cf brd ff:ff:ff:ff:ff:ff
显示eth0设备的设置
为eth0增加新连接
sudo nmcli con add con-name "new-connection" ifname eth0 type ethernet
为“new-connection”设置网络
ip地址:172.25.0.25/24
默认网关:172.25.0.254
DNS服务器:172.25.0.254
nmcli con mod "new-connection" ipv4.method manual ipv4.address 172.25.0.25/24 \
ipv4.gateway 172.25.0.254 ipv4.dns 172.25.0.254
激活连接
nmcli con up "new-connection"