When I attempt to ping google’s dns or any outside the network I get
connect: Network is unreachable
?
I can’t update either which I put down to this
I am new to networking… And Ubuntu. But these are results of some commands I thought might help
$ 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.
chaos
26.9k12 gold badges73 silver badges77 bronze badges
asked Feb 3, 2014 at 21:28
11
The following line is wrong:
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
Also, there doesn’t seem to be any default gateway setup.
Not having more info about your network, I would suggest adding the following line at the end:
gateway <YOUR.ROUTER.IP.ADDRESS>
So, assuming your router ip address is 192.168.0.1, this would be the whole entry:
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
answered Feb 3, 2014 at 22:06
GnPGnP
3672 silver badges7 bronze badges
The problem is that you need to set your default gateway
-
Take terminal
-
Type in
sudo ip route add default via <your gateway>(eg:192.168.136.1) dev eth0
-
Sometimes you will be able to ping (
ping 8.8.8.8
) but no internet connection in the browser, then: -
Go to
sudo nano /etc/resolv.conf
-
Add
nameserver 8.8.8.8
-
Add
nameserver <your gateway>
ornameserver 127.0.1.1
-
sudo /etc/init.d/networking restart
orsudo service networking restart
cocomac
2,8783 gold badges15 silver badges44 bronze badges
answered Nov 28, 2017 at 10:45
1
You may need to add a default gateway. As a root user, execute this command.
E.g.
root@localhost:~# route add default gw 172.23.5.1
You can get the first 3 octets, 172.23.5 from eth0/eoM
Then ping an IP to see if connection works.
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
answered Jun 28, 2018 at 0:04
In my case, if your system is behind a firewall, that can’t interact with internet. Unless you specify a proxy server for HTTP/HTTPS/FTP, it is not reachable.
Try this:
export http_proxy=http://yourcompanyproxy.company.com:1234
export ftp_proxy=ftp://yourcompanyproxy.company.com:1234
export https_proxy=https://yourcompanyproxy.company.com:1234
answered Sep 8, 2017 at 15:51
- Печать
Страницы: [1] Вниз
Тема: Network is unreachable (Прочитано 3447 раз)
0 Пользователей и 1 Гость просматривают эту тему.
Dolores
ОС ubuntu-16.04.2-server-amd64
Стоит задача присвоить серверу статический IP
sudo nano /etc/network/interfaces
исправляем вот так:
=====================================================
source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
# The primary network interface
#auto enp3s0 # комментируем, если сеть не работает - разкомм
#iface enp3s0 inet dhcp # не будет работать - убрать "#"
auto enp3s0
iface enp3s0 inet static
address 192.168.3.200
geteway 192.168.3.1
netmask 255.255.255.0
network 192.168.3.0
broadcast 192.168.3.255
dns-nameservers 192.168.3.1
===============================================================
ping ya.ru
получаем
Network is unreachable
ЧТО НЕ ТАК? где что исправить, чтоб заработало?
P.S. с динамическим IP пингуется.
« Последнее редактирование: 28 Июля 2017, 18:01:08 от Azure »
fisher74
geteway 192.168.3.1[/quote]
Dolores
koshev
Обратиться к тому, кто выдает серверу адрес, чтобы он его закрепил за сервером? Ну, как вариант.
А вообще покажите ситуацию при DHCP и статике? А то урывки какие-то, нет целой картины.
ip -s link show dev enp3s0
ip -4 route show dev enp3s0
ip -4 neigh show dev enp3s0
ну и traceroute до хоста в интернете.
во всех случаях.
И уберите пожалуйста
network 192.168.3.0
В них нет никакой необходимости при правильно построенной сети, ядро давно (как бы с 2.Х версии) само назначетет ШВ-адрес и адрес сети.
broadcast 192.168.3.255
Dolores
lora@ic-db:~$ ip -s link show dev enp3s0
Вот эта команда решает проблему до перезагрузки:
2: enp3s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 60:a4:4c:3e:15:b2 brd ff:ff:ff:ff:ff:ff
RX: bytes packets errors dropped overrun mcast
20625 119 0 0 0 23
TX: bytes packets errors dropped carrier collsns
21214 127 0 0 0 0
lora@ic-db:~$ ip -4 route show dev enp3s0
192.168.3.0/24 proto kernel scope link src 192.168.3.200
lora@ic-db:~$ ip -4 neigh show dev enp3s0
192.168.3.34 lladdr 6c:f0:49:e3:5d:9d REACHABLE
192.168.3.40 lladdr 00:1b:fc:8b:2f:1e STALE
192.168.3.1 lladdr ec:43:f6:e2:16:a0 DELAY
lora@ic-db:~$ traceroute ya.ru
traceroute to ya.ru (87.250.250.242), 30 hops max, 60 byte packets
connect: Сеть недоступна
sudo route add –net 0.0.0.0 netmask 0.0.0.0 gw 192.168.3.1
но так быть не должно.
Azure
geteway 192.168.3.1
Исправили?
« Последнее редактирование: 31 Июля 2017, 09:45:33 от Azure »
В Линукс можно сделать ВСЁ что угодно, достаточно знать КАК !
- Печать
Страницы: [1] Вверх
Kontext
articleArticles 81
codeCode 46
imageDiagrams 20
descriptionNotebooks 0
chat_bubble_outlineThreads 1
commentComments 7
loyaltyKontext Points 1152
account_circle Profile
visibility 11,768
event 2022-06-13
access_time 12 months ago
language English
more_vert
When upgrading from WSL1 to WSL2 for my Ubuntu 20.04 distro, the virtual machine cannot connect to network. The error messages include: Network is unreachable; Temporary failure resolving; Temporary failure in name resolution, etc. There are many articles on the websites and many of them didn’t resolve the problem. This page summarizes the solution for these issues and hopefully it will save you much time.
Issue context
After installing WSL 2 Ubuntu distro following Install Windows Subsystem for Linux on a Non-System Drive, the following error shows up when trying to update apt:
Err:1 http://archive.ubuntu.com/ubuntu focal InRelease Temporary failure resolving 'archive.ubuntu.com' Err:2 http://security.ubuntu.com/ubuntu focal-security InRelease Temporary failure resolving 'security.ubuntu.com' Err:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease Temporary failure resolving 'archive.ubuntu.com' Err:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease Temporary failure resolving 'archive.ubuntu.com' Reading package lists... Done Building dependency tree Reading state information... Done All packages are up to date. W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-updates/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://archive.ubuntu.com/ubuntu/dists/focal-backports/InRelease Temporary failure resolving 'archive.ubuntu.com' W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/focal-security/InRelease Temporary failure resolving 'security.ubuntu.com' W: Some index files failed to download. They have been ignored, or old ones used instead.
Similarly, when ping 8.8.8.8 or any other IP addresses, the following error shows up:
ping: connect: Network is unreachable
When ping any domain name, it shows a different error:
ping: google.com: Temporary failure in name resolution
The environment details are:
- OS: Windows 10 (10.0.19044)
- WSL version: 2
- Distro: Ubuntu 20.04 x64 version or OpenSUSE 42 or any other distros.
When downgrade to WSL 1, these issues are automatically resolved:
wsl --set-verison Ubuntu 1
However when change it back to version 2, the above issues still exist:
wsl --set-verison Ubuntu 2
General fixes
warning Warning – The following approaches probably don’t work for you. Please read through the whole article first before you decide to take any actions. For my scenario, it only works after disable compression for Packages folder. Refer to the last section for more details.
WSL 2 official documentation and many other websites have suggested the following fix:
- Backup and delete auto-generated files in WSL:
# Backup and delete auto-generated files sudo cp /etc/wsl.conf /etc/wsl.conf.bk sudo cp /etc/resolv.conf /etc/resolv.conf.bk sudo rm /etc/resolv.conf || true sudo rm /etc/wsl.conf || true
If wsl.conf doesn’t exist in your distro, you can ignore it.
- Recreate
/etc/wsl.conf
using the following command:sudo bash -c 'cat <<EOF > /etc/wsl.conf [network] generateResolvConf = false EOF'
- Recreate
/etc/resolv.conf
using the following command:sudo bash -c 'cat <<EOF > /etc/resolv.conf nameserver 8.8.8.8 nameserver 8.8.4.4 nameserver 192.168.1.254 EOF'
The above commands use Google DNS and also my WIFI network default gateway as DNS server. You can change it accordingly. You can get it from ipconfig command in your Windows Command Prompt:
ipconfig Wireless LAN adapter Wi-Fi: Connection-specific DNS Suffix . : IPv4 Address. . . . . . . . . . . : 192.168.1.135 Subnet Mask . . . . . . . . . . . : 255.255.255.0 Default Gateway . . . . . . . . . : 192.168.1.254
- Exist WSL.
- Run Command Prompt as Administrator in Windows and execute the following commands:
wsl --shutdown netsh winsock reset netsh int ip reset all netsh winhttp reset proxy ipconfig /flushdns
- Use Windows Search for Network reset. As described by itself, it will reinstall your network adapters. Please be aware of this before you take any actions.
- Restart Windows.
Usually after restart, your WSL network should now work. But unfortunately this approach doesn’t work for me. Thus I keep exploring the others options.
Run ip addr
Run the following command in WSL:
$ ip addr 1: lo: <LOOPBACK> mtu 65536 qdisc noop state DOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 2: bond0: <BROADCAST,MULTICAST,MASTER> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether ba:bc:6f:b0:f3:8b brd ff:ff:ff:ff:ff:ff 3: dummy0: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 36:6f:82:06:6f:9a brd ff:ff:ff:ff:ff:ff 4: tunl0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000 link/ipip 0.0.0.0 brd 0.0.0.0 5: sit0@NONE: <NOARP> mtu 1480 qdisc noop state DOWN group default qlen 1000 link/sit 0.0.0.0 brd 0.0.0.0 6: eth0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000 link/ether 00:15:5d:c2:ee:f9 brd ff:ff:ff:ff:ff:ff
The above texts were printed out in my WSL distro. The problem is that eth0 status is DOWN.
As mentioned earlier, for WSL 1 version, this issue does not exist as the way WSL2 works is different from WSL1:
10: eth0: <> mtu 1500 group default qlen 1
link/ether 9c:b6:d0:15:31:74
inet 169.254.143.197/16 brd 169.254.255.255 scope global dynamic
valid_lft forever preferred_lft forever
Final solution
After I tried all the above steps, none of them worked for me. Finally, I found the solution after tremendous searching on the internet: disable compression for C:Users<your user id>AppDataLocalPackages
.
Detailed steps
- Navigate to
C:Users<your user id>AppDataLocalPackages
. Replace the placeholder with your own user ID. - Right click and choose Properties and then click Advanced button.
- Uncheck ‘Compress contents to save disk space‘.
- Click OK button.
- Apply the changes to the child items and folders too.
- Shutdown WSL by running command in Windows Terminal or Command Prompt:
wsl --shutdown
- Restart the computer.
The issue should be gone after restart:
Enjoy developing with Ubuntu via WSL 2!
No comments yet.
0
0
Нет сети! Ubuntu 6.06 (консоль) При любом пинге 127.0.0.1, localhost, 192.168.0.1 (свой ip) пишет: connect: Network is unreachable ifconfig вообще ничего не дает. etc/network/interfaces: auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 192.168.0.1 netmask 255.255.255.0 network 192.168.0.0 broadcast 192.168.0.255 etc/host: 127.0.0.1 localhost 192.168.0.1 user ::1 ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters ff02::3 ip6-allhosts При lspci, карту видит прекрасно. Причина: Поставил винт с ситсемой на другой комп. Не хочу переустанавливать. Что может быть?
Загрузка…