Symptom:
Ping Intranet
Ping the Internet IP address. The domain name cannot be normal. The error "connect: Network is unreachable" is returned.
The command for adding a gateway to the Linux network configuration is displayed inadvertently later:
Route add default gw 192.168.128.2 dev eth0
Follow the steps above to add the default gateway. Accessing the Internet again is normal.
The GATEWAY is not configured in the configuration file, but it is confirmed that the GATEWAY address is configured in/etc/sysconfig/network, and the GATEWAY address is correct, after you restart the network multiple times, you cannot access the Internet without manually adding a gateway.
After carefully checking each NETWORK configuration file, it is found that there is a NETWORK configuration item in the NIC configuration file (ifcfg-eth0), for this configuration item, the role is not very clear, so I checked the instructions on the official website:
NETWORK = <address>
Where <address> is the network address. This directive is deprecated, as the value is calculated automatically with ifcalc.
This rhythm tells us not to set this parameter (deprecate). This value will be automatically calculated by ifcalc. Since you do not need to set it, remove it naturally.
After the removal, after the network service is restarted, the Internet can be accessed magically. You can use route to view the route table and find that the default information can be automatically added. However, the original information does not exist:
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.128.0*255.255.255.0 U 0 0 0 eth0
Link-local * 255.255.0.0 U 1002 0 0 eth0
Default 192.168.128.2 0.0.0.0 UG 0 0 0 eth0
It seems that the problem is caused by this NETWORK parameter setting. As for the specific reason, it is not clear what impact this setting will have.
TIPs: For simplicity, you can also set IPADDR, GATEWAY, and so on to the ifcfg-eth * file, without setting the GATEWAY in the network separately.