The simplest one is described in one sentence, ifconfig checks the current system's IP, subnet mask and gateway.
Ping, for example, ping www.baidu.com, but it doesn’t work.
Here are two solutions: First, check the network card configuration Second, configure DNS (Recommended learning: linux operation and maintenance)
View Network card settings, the configuration file of the network card under Linux is in /etc/sysconfig/network-scripts/
Use ls to view and then use vi or vim to edit ifcfg-eth0
Here DEVICE is the network card name, BOOTPROTO is static or dynamic, IPADDR is the IP address, MASK is the subnet mask, GATEWAY is the gateway, and ONBOOT is the network card switch status
If there are other hosts in the LAN When you can access the Internet but cannot access the Internet, unless the gateway or server has made relevant access restrictions, it may only be a configuration problem on the machine. Check DNS
Enter the Baidu URL, but no relevant information is output, so it is said that the parsing was not successful.
You can see the prompt that the connection has timed out, so there is still a problem with DNS parsing. Then edit the DNS configuration file and configure In the file, the two lines of commands are preceded by #, so they become comments. After deleting the #, save and exit
The above is the detailed content of Solution to Linux unable to access the Internet. For more information, please follow other related articles on the PHP Chinese website!