Solve the problem that ubuntu 16.04, 18.04, etc. can connect to the internal network, but cannot connect to the external network

Today, I connected two network cables to the Ubuntu server machine, and suddenly found that the network delay is very high, and the network is basically disconnected, but the internal network access is normal, and the external network is basically paralyzed. Use the ping command to test whether the network is smooth. The result is that the internal network can be pinged, but the external network cannot be pinged. At the same time, 8.8.8.8 and 114.114.114.114 can be pinged.
The following is a solution to manually increase the gateway. If it still doesn’t work, you need to check other methods:

1. View the configuration file

  • Execute the command:
    cat /etc/resolv.conf
  • 结果如下:
    #Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    #DO NOT EDIT THIS FILE BY HAND – YOUR CHANGES WILL BE OVERWRITTEN

2. Check the gateway

  • Execute the command:
    route or netstat -rn
  • Execution result:
    insert image description here
    You can see that the gateway is: 10.214.43.1

3. Modify the /etc/resolvconf/resolv.conf.d/head file

  • Execute the command:
    vim /etc/resolvconf/resolv.conf.d/head
  • Add the following:
    nameserver 10.214.43.1
    nameserver 114.114.114.114
    nameserver 8.8.8.8
  • save and exit

4. Modify the /etc/resolv.conf file

  • Execute the command:
    vim /etc/resolv.conf
  • Add the following:
    nameserver 10.214.43.1
    nameserver 114.114.114.114
    nameserver 8.8.8.8
  • save and exit

5. Restart the network configuration

  • Execute the command:
    /etc/init.d/networking restart
  • Execution result:
    output "ok" means the execution is successful

6. Test ping pass

  • Execute the command:
    ping cn.bing.com
  • Execution result:
    insert image description here
    After testing, the external network can be pinged, and the network connection is normal.

Guess you like

Origin blog.csdn.net/qq_43522889/article/details/129502980