Centos Linux7 sets an instance of static IP
- 2020-06-03 09:05:52
- OfStack
Centos Linux7 sets an instance of static IP
Go to the location of the configuration file:
cd /etc/sysconfig/network-scripts/
Check which file the current network card is using
ip add
Filter out the list of configuration files
ll | grep ifcfg
Edit the configuration file
vi ifcfg-ens160
BOOTPROTO IPADDR NETMASK NM_CONTROLLED ONBOOT These fields, other unchanged
TYPE=Ethernet
BOOTPROTO=static
IPADDR=192.168.1.251
NETMASK=255.255.255.0
DNS1=8.8.8.8
DNS2=8.8.4.4
NM_CONTROLLED=no
DEFROUTE=yes
PEERDNS=yes
PEERROUTES=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_PEERDNS=yes
IPV6_PEERROUTES=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens160
UUID=23a77b70-a6e3-4399-a5bd-4ca312a0f123
DEVICE=ens160
ONBOOT=yes
Modify the gateway configuration file:
vi /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=localhost.localdomain
GATEWAY=192.168.1.1
Restart the network service
systemctl restart network.service
Thank you for reading, I hope to help you, thank you for your support to this site!