![如果不使用 VPN,Ubuntu 16.04 LTS 就无法连接到互联网](https://linux22.com/image/1146242/%E5%A6%82%E6%9E%9C%E4%B8%8D%E4%BD%BF%E7%94%A8%20VPN%EF%BC%8CUbuntu%2016.04%20LTS%20%E5%B0%B1%E6%97%A0%E6%B3%95%E8%BF%9E%E6%8E%A5%E5%88%B0%E4%BA%92%E8%81%94%E7%BD%91%20.png)
我是 Linux 新手。我一直以为是 wifi 驱动程序出了问题,直到我发现使用 VPN 时可以连接到网络。直到今天我的互联网都运行良好。我需要能够在不使用 VPN 的情况下连接到网络。
我收到的消息如下:
Firefox can’t find the server at www.google.com.
在终端上:
$ uname -a
Linux MisterX 4.4.0-66-generic #87-Ubuntu SMP Fri Mar 3 15:29:05 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
$ ping google.com
ping: unknown host google.com
$ dig google.com
; <<>> DiG 9.10.3-P4-Ubuntu <<>> google.com
;; global options: +cmd
;; connection timed out; no servers could be reached
$ ping ping 216.58.208.78
PING 216.58.208.78 (216.58.208.78) 56(84) bytes of data.
64 bytes from 216.58.208.78: icmp_seq=1 ttl=48 time=230 ms
64 bytes from 216.58.208.78: icmp_seq=2 ttl=48 time=226 ms
64 bytes from 216.58.208.78: icmp_seq=3 ttl=48 time=249 ms
64 bytes from 216.58.208.78: icmp_seq=4 ttl=48 time=224 ms
^C
--- 216.58.208.78 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3002ms
rtt min/avg/max/mdev = 224.005/232.736/249.737/10.094 ms
$ dig 216.58.208.78
; <<>> DiG 9.10.3-P4-Ubuntu <<>> 216.58.208.78
;; global options: +cmd
;; connection timed out; no servers could be reached
$ sudo nano /etc/nsswitch.conf
passwd: compat
group: compat
shadow: compat
gshadow: files
hosts: files mdns4_minimal [NOTFOUND=return] dns
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
我努力了:
$ sudo /etc/init.d/network-manager restart
[ ok ] Restarting network-manager (via systemctl): network-manager.service.
答案1
最后,它适用于以下两者:
第一的 (https://askubuntu.com/a/164351/664380)
$ sudo mv /etc/resolv.conf /etc/backup.resolv.conf
然后,运行(https://askubuntu.com/a/835198/664380)
$ ifconfig
并查看网络适配器的名称。我的是:enp0s31f6
现在运行这个命令
$ sudo nano /etc/network/interfaces
你应该在里面得到一些东西....删除所有内容并粘贴这个(但更改 enp0s31f6 所在的网络适配器名称):
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
# The primary network interface
auto enp0s31f6
iface enp0s31f6 inet dhcp
保存文档并重新启动...
就我而言,我仅在 /etc/network/interfaces 中有以下三行
# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback
我必须补充一下
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
source /etc/network/interfaces.d/*
及以下:
# The primary network interface
auto enp0s31f6
iface enp0s31f6 inet dhcp