ubuntu 18.04可以连接内网,无法连接外网

可以ping通内网,同时可以ping通8.8.8.8,114.114.114.114, 但是ping外网失败,以下是手动增加网关的一个解决方法,如果还不行就需要查看其它方法了。

10.219.91.1要填你的网关

1. 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. route或netstat -rn,获取网关10.219.91.1

$ route
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default 10.219.91.1 0.0.0.0 UG 0 0 0 ens33
10.219.91.0 * 255.255.255.0 U 0 0 0 ens33
link-local * 255.255.0.0 U 1000 0 0 ens33

 

3. 修改/etc/resolvconf/resolv.conf.d/head, 增加如下3行

nameserver 10.219.91.1
nameserver 114.114.114.114
nameserver 8.8.8.8

 

4. 执行/etc/init.d/networking restart

5. 查看/etc/resolv.conf 

$ 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
nameserver 10.219.91.1
nameserver 114.114.114.114
nameserver 8.8.8.8

 

6. ping Bing,显示成功

$ ping cn.bing.com
PING cn-0001.cn-msedge.net (202.89.233.100) 56(84) bytes of data.
64 bytes from 202.89.233.100: icmp_seq=1 ttl=115 time=40.9 ms
64 bytes from 202.89.233.100: icmp_seq=2 ttl=115 time=40.6 ms
64 bytes from 202.89.233.100: icmp_seq=3 ttl=115 time=51.4 ms
64 bytes from 202.89.233.100: icmp_seq=4 ttl=115 time=49.2 ms

 

上一篇:Ubuntu18.04修改dns


下一篇:ubuntu18.4安装和配置的大致流程