Configure Linux network
Use to enter the configuration file:
vi /etc/sysconfig/network-scripts/ifcfg-eth0
The file opened now is the configuration file of the network card. To change the IP address, you must edit this file.
We want to modify the contents of the file, press the letter i key:
Change ONBOOT=no to ONBOOT=yes
Change BOOTPROTO=dhcp Change to BOOTPROTO=static
and add the following lines of characters
IPADDR=192.168.188.128
NETMASK=255.255.255.0
GATEWAY=192.168.47.2
DNS1=119.29.29.29
Note:
ONBOOT is set to yes, which means that the network card will follow the system Start together
BOOTPROTO is used to set the startup type of the network card. dhcp means automatically obtaining the IP address, static means manually setting the static IP address
IPADDR specifies the IP address (depending on the previously automatically obtained Address)
NETMASK specifies the subnet mask
GATEWAY specifies the gateway
DNS1 specifies the DNS IP address for Internet access
119.29.29.29 is a domestic DNSpod company Provide a public DNS
After completing the above changes, press the Esc key, then enter ":wq" and press Enter to exit the document just now.
Restart the Internet
Restart the network service
View the IP address (same as seen before)
Test network connectivity
Network setup completed!
The above is the detailed content of How to configure the network in linux. For more information, please follow other related articles on the PHP Chinese website!