When CentOS starts the Network, the following error occurs: connect: Network is unreachable.

Source: Internet
Author: User

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.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.