问题描述
提示:这里描述具体问题:
同一根网线,在windows上可以访问外网,在ubuntu18.04上不能访问外网,访问内网是可以。正常也可以ping通内网的网关。
在ubuntu18.04右上角显示网络是问号,正常不能访问外网。
ping 内网网关是可以的
PING 10.23.56.254 (10.23.56.254) 56(84) bytes of data.
64 bytes from 10.23.56.254: icmp_seq=1 ttl=254 time=0.497 ms
64 bytes from 10.23.56.254: icmp_seq=2 ttl=254 time=0.553 ms
64 bytes from 10.23.56.254: icmp_seq=3 ttl=254 time=0.491 ms
64 bytes from 10.23.56.254: icmp_seq=4 ttl=254 time=0.558 ms
64 bytes from 10.23.56.254: icmp_seq=5 ttl=254 time=0.456 ms
64 bytes from 10.23.56.254: icmp_seq=6 ttl=254 time=0.524 ms
64 bytes from 10.23.56.254: icmp_seq=7 ttl=254 time=0.541 ms
64 bytes from 10.23.56.254: icmp_seq=8 ttl=254 time=0.540 ms
64 bytes from 10.23.56.254: icmp_seq=9 ttl=254 time=0.456 ms
64 bytes from 10.23.56.254: icmp_seq=10 ttl=254 time=0.486 ms
64 bytes from 10.23.56.254: icmp_seq=11 ttl=254 time=0.439 ms
64 bytes from 10.23.56.254: icmp_seq=12 ttl=254 time=0.454 ms
64 bytes from 10.23.56.254: icmp_seq=13 ttl=254 time=0.504 ms
64 bytes from 10.23.56.254: icmp_seq=14 ttl=254 time=0.563 ms
但是ping www.baidu.com 不通
ping: www.baidu.com: Temporary failure in name resolution
ping 8.8.8.8 不通
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
From 10.23.56.254 icmp_seq=1 Destination Net Unreachable
^C
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 0 received, +1 errors, 100% packet loss, time 2035ms
修改/etc/resolv.conf文件中增加网关即可。
$ sudo vim /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "resolvectl status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.
nameserver 127.0.0.53
nameserver 114.114.114.114
nameserver 8.8.8.8
nameserver 自己的网关
options edns0 trust-ad
本机网关查询route命令或netstat -rn命令
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
default bogon 0.0.0.0 UG 20100 0 0 enp4s0
10.23.56.0 0.0.0.0 255.255.255.0 U 100 0 0 enp4s0
link-local 0.0.0.0 255.255.0.0 U 1000 0 0 docker0
189.15.0.0 0.0.0.0 255.255.0.0 U 0 0 0 docker0
把10.23.56.0填到/etc/resolv.conf 文件中即可。
在ping就可以了。
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=20 ttl=114 time=42.4 ms
64 bytes from 8.8.8.8: icmp_seq=21 ttl=114 time=42.5 ms
64 bytes from 8.8.8.8: icmp_seq=22 ttl=114 time=43.4 ms
64 bytes from 8.8.8.8: icmp_seq=23 ttl=114 time=42.5 ms
64 bytes from 8.8.8.8: icmp_seq=31 ttl=114 time=42.1 ms
64 bytes from 8.8.8.8: icmp_seq=32 ttl=114 time=42.3 ms
64 bytes from 8.8.8.8: icmp_seq=33 ttl=114 time=42.0 ms
64 bytes from 8.8.8.8: icmp_seq=34 ttl=114 time=42.9 ms
64 bytes from 8.8.8.8: icmp_seq=35 ttl=114 time=42.0 ms
64 bytes from 8.8.8.8: icmp_seq=36 ttl=114 time=42.1 ms
原因分析:
提示:这里填写问题的分析:由与网络中网关不能识别导致的。
解决方案:
提示:这里填写该问题的具体解决方案:如上。
欢迎评论:
提示:欢迎大家在评论区讨论相关问题。
可以关注博主,我会持续更新工作中遇到的技术小砖头,供大家使用。
也可以在评论区告知好的小砖头或技术,我会收录。
还可以指出本博文错误,希望大家不吝赐教。