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

时间:2023-03-09 18:45:16
ubuntu 18.04可以连接内网,无法连接外网

手动增加网关后,又重新sudo apt-get upgrade,  提示/etc/resolvconf/resolv.conf.d更新时,选Y后,不用手动修改网关也可以连接外网了。

一切默认更新后,18.04LTS的图标问题也修复了。

得到的配置如下

$ 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
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53
search v01.net
options edns0

可以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

/etc/udev/rules.d/
-rwxr-xr-x 1 root root 164 March 19 11:33 51-android.rules

SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", MODE="0666"
SUBSYSTEM=="usb",ATTRS{idVendor}=="1bc7",MODE="0666"
SUBSYSTEM=="usb",ATTRS{idVendor}=="2c7c",MODE="0666"