centos7 network configuration

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

[java]  view plain copy  
 
  View code snippets on CODE Derive to my code slice
  1. TYPE=Ethernet  
  2. BOOTPROTO=static  
  3. IPADDR=172.16.25.3  
  4. NETMASK=255.255.0.0  
  5. GATEWAY=172.16.0.254  
  6. DNS=159.226.39.1  
  7. DEFROUTE = yes  
  8. PEERDNS=yes  
  9. PEERROUTES=yes  
  10. IPV4_FAILURE_FATAL=no  
  11. IPV6INIT=yes  
  12. IPV6_AUTOCONF=yes  
  13. IPV6_DEFROUTE = yes  
  14. IPV6_PEERDNS=yes  
  15. IPV6_PEERROUTES=yes  
  16. IPV6_FAILURE_FATAL=no  
  17. NAME=enp1s0f0  
  18. UUID=8b9786a7-7959-4c4b-bfc3-644db984d702  
  19. DEVICE=enp1s0f0  
  20. 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

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326226370&siteId=291194637
Recommended