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

当我尝试ping谷歌的DNS或网络外的任何东西时,我得到connect: Network is unreachable

我无法更新我所说的内容

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

 $ ip a 1: lo:  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:  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:  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. 

以下行错了:

 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 

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

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

  gateway  

因此,假设您的路由器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 

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

1)带终端

2)sudo su

3)输入

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

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

5)去’nano /etc/resolv.conf’

6)加入

7)nameserver 8.8.8.8

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

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

您可能需要添加默认网关。 以root用户身份执行此命令。

例如

 root@localhost:~# route add default gw 172.23.5.1 

您可以从eth0 / eoM获得前3个八位字节,172.23.5

然后ping一个IP以查看连接是否有效。

 root@localhost:~# ping 10.56.94.81 PING 10.56.94.81 (10.56.94.81) 56(84) bytes of data. 64 bytes from 10.56.94.81: icmp_seq=1 ttl=62 time=0.203 ms 64 bytes from 10.56.94.81: icmp_seq=2 ttl=62 time=0.197 ms 64 bytes from 10.56.94.81: icmp_seq=3 ttl=62 time=0.210 ms ^C --- 10.56.94.81 ping statistics --- 3 packets transmitted, 3 received, 0% packet loss, time 2033ms rtt min/avg/max/mdev = 0.197/0.203/0.210/0.012 ms 

就我而言,如果您的系统位于防火墙后面,则无法与Internet进行交互。 除非您为HTTP / HTTPS / FTP指定代理服务器,否则无法访问。

试试这个:

 export http_proxy=http://yourcompanyproxy.company.com:1234 export ftp_proxy=ftp://yourcompanyproxy.company.com:1234 export https_proxy=https://yourcompanyproxy.company.com:1234