- root用户执行
dhclient
会自动分配一个ip,假如是192.268.31.100
sudo vi /etc/sysconfig/network-scripts/ifcfg-ens*
修改网卡配置BOOTPROTO
=static
(默认是dhcp)ONBOOT
=yes
(默认是no)
- 增加字段
IPADDR
=192.268.31.100
(ip地址)NETMASK
=255.255.255.0
(子网掩码)GATEWAY
=192.268.31.1
(网关)DNS1
=119.29.29.29
(DNS)
- 保存,重启网络
systemctl restart network.service
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=static
IPADDR=172.16.4.90
NETMASK=255.255.255.0
GATEWAY=172.16.4.254
DNS1=172.16.10.22
DNS2=172.16.10.13