1. Configure static ip
Edit the vi /etc/sysconfig/network-scripts/ifcfg-enp0s3 file (other files are also acceptable) , and configure the following parameters ( red is new items , others are modified items )
BOOTPROTO= static #Indicates obtaining static ip
IPADDR=192.168.1.199 #Assigned static ip
NETMASK=255.255.255.0 #Subnet mask
GATEWAY=172.16.0.254
#Gateway DNS=159.226.39.1 # DNS
ONBOOT= yes #The system will open the interface at startup
After configuration
- TYPE=Ethernet
- BOOTPROTO=static
- IPADDR=172.16.25.3
- NETMASK=255.255.0.0
- GATEWAY=172.16.0.254
- DNS=159.226.39.1
- 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
- NAME=enp1s0f0
- UUID=8b9786a7-7959-4c4b-bfc3-644db984d702
- DEVICE=enp1s0f0
- ONBOOT=yes
Only configure ONBOOT=yes to ssh remote access.
Save the changes and restart the network service with the following command:
service network restart
2. Modify dns
Manually modify /etc/resolv.conf
# systemctl restart NetworkManager.service
§ Manually modify vim /etc/resolv.conf
Add the following code:
nameserver 114.114.114.114
nameserver 8.8.8.8