ubuntu server18.04配置好ip却不能接通外网

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu server18.04配置好ip却不能接通外网相关的知识,希望对你有一定的参考价值。

参考技术A 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", ENVDEVTYPE=="usb_device", MODE="0666"
SUBSYSTEM=="usb",ATTRSidVendor=="1bc7",MODE="0666"
SUBSYSTEM=="usb",ATTRSidVendor=="2c7c",MODE="0666"

ubuntu18.04server设置静态IP

16.04以后的版本配置静态IP是类似这样的文件 /etc/netplan/50-cloud-init.yaml

1.查询网卡名称

技术分享图片

2.修改配置文件/etc/netplan/50-cloud-init.yaml??为如下

技术分享图片

3.执行如下命令让配置生效,静态IP就配置好了
netplan apply


以上是关于ubuntu server18.04配置好ip却不能接通外网的主要内容,如果未能解决你的问题,请参考以下文章

Ubuntu18.04 IP配置问题

VMware下Ubuntu 18.04Server设置静态IP图文教程

VMware下Ubuntu 18.04Server设置静态IP图文教程

ubuntu18.04_server配置静态IPv4

ubuntu18.04_TLS_server安装

ubuntu server 14.04和18.04挂载vmware共享文件夹