centos 7.x configure a static IP and enable
The origin of the problem 0
By querying the machine's IP, we found that the machine was not effective IP:
[pan@localhost ~]$ ip addr
So, we need to set a static IP of the machine, and enable the configuration.
How do we achieve this aim?
1 which file to modify the
Step by step we return to the query the local IP, and the results returned can learn a closer look:
Native network device name --ens33.
So we try to find the file with "ens33" in the system:
[pan@localhost ~]$ sudo find / -name *ens33*
We look carefully return the results, with particular attention to the results of the line in the / etc directory (the files in the / etc directory is a system configuration files):
……
/etc/sysconfig/network-scripts/ifcfg-ens33
The last line is the path we want to modify the target file.
2 How to Modify
Before modifying the target file, as usual, we carefully look at the file permissions information, and then make changes:
[pan@localhost ~]$ ls -l /etc/sysconfig/network-scripts/ifcfg-ens33
Return result:
-rw-------. 1 root root 392 10月 10 15:36 /etc/sysconfig/network-scripts/ifcfg-ens33
Modify the target file:
[pan@localhost ~]$ sudo vi /etc/sysconfig/network-scripts/ifcfg-ens33
These two lines modified as follows:
Original value :
BOOTPROTO=dhcp
ONBOOT=no
Modify the value :
BOOTPROTO=static
ONBOOT=yes
Increase follows the end:
IPADDR=192.168.219.149
GATEWAY=192.168.219.2
NETMASK=255.255.255.0
DNS1=192.168.219.146
DNS2=192.168.219.147
3 enable the configuration and verify network connectivity
After modifying the target file, we need to restart the system network services:
[pan@localhost ~]$ sudo systemctl restart network.service && ping -c 4 www.baidu.com
4 Conclusion
To tell the truth, the document also wrote accustomed to.