Solve connect: network is unreachable Problems
Some netizens found that the ping command encountered the "connect: network is unreachable" problem.
This is usually because the IP address is not set correctly.
Solution:
Check whether the NIC Driver is complete and the NIC Driver is compiled into the kernel.
Ls/etc/sysconfig/network-script/ifcfg-eth0
1. Check whether the ifcfg-eth0 file exists in the above directory, if there is, follow the steps below:
1. manually configure the ip address to see if it can be configured
Ifconfig eth0 172.18.128.143 netmask 255.255.255.0 broadcast 172.18.128.255
Route add default gw 172.18.128.1 (the same network segment may not be used)
Or
Directly edit vi/etc/sysconfig/network-scripts/ifcfg-eth0
2. service network restart
2. If there is no ifcfg-eth0, this file does not even exist under the/etc/sysconfig Directory network-script directory, then you need to create this directory and create ifcfg-eth0
The ifcfg-eth0 file content is as follows:
You only need to modify the device hwaddr netmask ipaddr items as needed.
Then the service network restart
Ping it and try again.
If you ping a WAN instead of a LAN, make sure that the gateway and DNS settings are correct.
You can set the gateway according to the following steps.
This command can be done.
Route add defaultgw 192.168.1.1
That is your gateway.
Now route
Kernel IP routing table
Destination Gateway Genmask Flags Metric RefUse Iface
192.168.1.0*255.255.255.0 U 000 eth0
Default my. router 0.0.0.0 UG000 eth0
If it is not added before, only the first one is shown above. The second is newly added.
If you still cannot access it, your situation may be a bit special.
In this way, it will be unavailable after restart.
Modify
Edit/etc/network/interfaces
Add gateway192.168.1.1
DNS records are in the resolv. conf file under/etc. You can modify DNS in the format of resolv. conf. Create one without resolv. conf.
Then the service network restart
Ping.