Note: All red font labels are Linux operation commands!
1. Log in to the system using the root account
2, you can first use ifconfig : Check the network card information eth0 as the default first network card, if there is a second will be displayed as eth1.
You can then see that the eth0 and Lo network cards lo are loopback address IP is 127.0.0.1 (this is also available on Windows). There will be an IP address and other information
If there is no command to execute
dhclient #获取IP
dhclient-r #释放IP
After acquiring the IP in the execution ifconfig This time you will see inet addr: ... Some IP addresses and other information
3, then enter the vi edit mode edit eth0 network card IP address and other information eth0 location:/etc/sysconfig/network-scripts/ifcfg-eth0
Execute command: vi/etc/sysconfig/network-scripts/ifcfg-eth0
At this point, press I for edit mode to change "Onboot=on" to "Onboot=yes" to "bootproto=dhcp" to "bootproto=static" and add the following lines of configuration:
ipaddr=192.168.31.19 ----> This address can open the network and Sharing Center and then view the network details of the current PC connection to view
metmask=255.255.255.0
gateway=192.168.31.1 ----> The gateway address can also be viewed in the network and Sharing Center as
dns1=8.8.8.8
When you are finished editing, press ESC to enter: WQ Exit and SAVE!
4, and then restart the Network Service Execution command: service network restart
This is the IP address you just configured when you enter the ifconfig command.
Now, after the network is set up, you can try to ping it if the ping pass proves that the configuration was successful. Enter Ping www.baidu.com directly on the command line
Linux Configuration static IP address