连接:网络无法访问?- 平

use*_*010 27 server network-manager networking dns

当我尝试 ping google 的 dns 或网络外的任何网络时,我得到了 connect: Network is unreachable什么?

我无法更新我放下的任何一个

我是网络新手……还有 Ubuntu。但这些是我认为可能有帮助的一些命令的结果

$ ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN 
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
    link/ether 00:0e:7f:a9:10:54 brd ff:ff:ff:ff:ff:ff
    inet 192.168.0.5/24 brd 192.168.0.255 scope global eth0
    inet6 fe80::20e:7fff:fea9:1054/64 scope link 
       valid_lft forever preferred_lft forever
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN 
    link/ether 86:0b:cb:43:63:a5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
mcserver@helloworld:~$ 

$ vi /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 192.168.0.5
nameserver 8.8.8.8

$ vi /etc/network/interfaces
# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static
        address 192.168.0.5
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.0.255
        post-up iptables-restore < /etc/iptables.up.rules
        dns-nameservers 192.168.0.5 8.8.8.
Run Code Online (Sandbox Code Playgroud)

GnP*_*GnP 18

以下行是错误的:

iface eth0 inet static
    address 192.168.0.5
    netmask 255.255.255.0
    network 192.168.1.0 <<<<<<<<<<<<<<<<<<<<<<<< It should be 192.168.0.0
    broadcast 192.168.0.255
    post-up iptables-restore < /etc/iptables.up.rules
    dns-nameservers 192.168.0.5 8.8.8.8
Run Code Online (Sandbox Code Playgroud)

此外,似乎没有任何默认网关设置。

没有关于您的网络的更多信息,我建议在最后添加以下行:

    gateway <YOUR.ROUTER.IP.ADDRESS>
Run Code Online (Sandbox Code Playgroud)

因此,假设您的路由器 IP 地址是 192.168.0.1,这将是整个条目:

iface eth0 inet static
    address 192.168.0.5
    netmask 255.255.255.0
    network 192.168.0.0
    broadcast 192.168.0.255
    post-up iptables-restore < /etc/iptables.up.rules
    gateway 192.168.0.1
    dns-nameservers 192.168.0.5 8.8.8.8
Run Code Online (Sandbox Code Playgroud)


小智 6

问题是,您需要设置默认网关

1)取终端

2)须藤

3) 输入

$ route 添加默认 gw (eg:192.168.136.1) eth0

4)有时你可以ping(ping 8.8.8.8)但浏览器中没有互联网连接,然后

5)去'纳米/etc/resolv.conf'

6)添加

7) 名称服务器 8.8.8.8

8)名称服务器 192.168.136.0(网关)或名称服务器 127.0.1.1

9)sudo /etc/init.d/networking restart 或 service network restart

  • 欢迎使用 askubuntu。两点说明: 1. 除非你真的提出了不同的东西,否则不要用公认的答案来回答问题。2. 永远不要建议`sudo su`,因为出于多种原因,这在这里被认为是不好的做法。 (2认同)