查看机器网卡配置文件列表

  • 这里假设设置机器的网卡配置是enp0s0
1
$ ls /etc/sysconfig/network-scripts/ifcfg-*

命令行中设置静态IP

1
2
3
4
5
6
$ vi /etc/sysconfig/network-scripts/ifcfg-enp0s0
BOOTPROTO="static"
IPADDR="1.1.1.2"
NETMASK="255.255.255.0"
GATEWAY="1.1.1.1"
$ systemctl restart network.service

使用网络管理器

1
2
3
$ yum install NetworkManager-tui
$ nmtui edit enp0s0
$ systemctl restart network.service

修改DNS设置

1
2
3
$ vi /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
  • 或者
1
2
3
$ vi /etc/sysconfig/network-scripts/ifcfg-enp0s0
DNS1="8.8.8.8"
DNS2="8.8.4.4"