How do I troubleshoot networking on Debian
Solution 1
connect: Network is unreachable
points to a missing route to that network (the default route in this case).
Use:
route -n
To display the current routing table. There must be a route that looks like this:
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 <gateway-ip> 0.0.0.0 UG 0 0 0 eth0
Notice that, <gateway-ip>
is the ip address of your router/gateway. And Iface
may also be different, when you have multiple network interfaces in your system.
However, add the default route manually with this command:
route add default gw <gateway-ip>
Solution 2
I would (all this commands as root) ifconfig -a
to check if the interface has an IP address, if it doesn't you have found your problem, if it does, then I would netstat -rn
to check if the routes are right. If they are, I would iptables -L
to check if there is a firewall rule that is not letting me out. If they are all OK then maybe your IP address doesn't belong to the router network.
Solution 3
The issue here is that your wired interface (eth0) does not have an IPv4 address. You have manually added an IPv4 route but, without having an IPv4 address, traffic cannot get routed as it cannot assign an IP address for (your system's) source IP.
Without knowing more information of your environment (Are you using a DSL connection? Are you in an corporate network? Who should be providing you an IP address?) I would guess that before the reboot you either have a staticly configured IP address or a working DHCP server. If you had a staticly configured address (which your configuration does not show) it was lost after the reboot.
You see an IPv6 address because that address is "auto-configured". Since you have not configured it the wired interface just creates one that can be used to communicate with the local network.
From the ifconfig information you provided it seems that your network card is receiving Ethernet packets, but not sending any. Strangely, it is also showing many dropped packets.
For starters, I would suggest you do the following:
-
Get information of your network IP addressing scheme. Ask your network administrator, or check the information provided by your ISP. Alternatively, (if you are bold) you can listen to the network traffic on the network by running
tcpdump -ni eth0
and try to guess your internal network addressing based on the packets your system receives.From now on lets assume that your network is in a private IP address range, since this is quite common. Many networks nowadays are pre-configured in the 192.168.1.0/24 space range which means that the IP addresses start in 192.168.1.1 and end in 192.168.1.254
-
Configure your network interface with a static IP address and a gateway using either Network Manager (i.e. through the desktop) or configuring
/etc/network/interfaces
properly. This is described fully here in the Debian Wiki.Note: You can also configure it manually running
ip addr add 192.168.1.15 dev eth0; ip route add default via 192.168.1.1
. But this will not survive a system reboot. -
Try to see if you reach the gateway by sending it packets. This can be done simply, assuming your gateway is 192.168.1.1 by running
ping -c 10 192.168.1.1
. If the command returns that all 10 tests worked OK then you can see your gateway. -
Then try to access a well known public IP address. For example a Google DNS server, doing
ping -c 10 8.8.8.8
. If this does not work then try to run a tracing test usingtraceroute -n 8.8.8.8
to see where your packets are being dropped. -
Finally, ensure that you can do DNS resolution properly by running
host www.google.com
orping -c 10 www.google.com
If all goes well up to step 5 I would suggest that, in order to diagnose future problems, you install the ifupdown-extra package. This installs the network-test tool which does many of the network tests listed above (and more) in order to diagnose if there is a network problem or misconfiguration.
Once you can connect using a static IP address. Try to go back with what you previously had which probably was a dynamic IP configuration using DHCP.
To do this:
-
Reconfigure the interface to use a dynamic IP address.
-
Wait for Network Manager to do its job. You will see in your Desktop environment if it fails (or not) but you can also get detailed information in the System logs. More specifically /var/log/syslog . Filtering for Network Manager logs will tell you quite a lot of information, just run
grep NetworkManager /var/log/syslog
and review the output. -
Run
network-test
to see if you are properly connected -
If you are not connected to the network try to manually ask for an IP address running
dhclient eth0
and see if that provides you with an IP address.
Based on the above tests you should have a better knowledge of what broke and what works in your network and configure your system accordingly.
Related videos on Youtube
dinosaur
Updated on September 18, 2022Comments
-
dinosaur over 1 year
Today I restarted my linux box, and following the restart, my linux box has no network connection.
Here's what I've tried so far:
Use an different ethernet cable that works on my other computer. No change.
In NetworkManager (KDE) remove and re-create the wired network connection. Didn't work. I'm still getting system notifications in the lower right corner of the screen saying
Network Interface Connection New Wired Connection failed
> sudo /etc/init.d/networking restart
It seemed to restart successfully but still no network connection.Checked
/etc/network/interfaces
. The only code in there is what the internet says it's supposed to be:auto lo iface lo inet loopback
Made sure it's not just a DNS issue by trying to ping one of google's public DNS servers
$ ping 8.8.8.8 connect: Network is unreachable
Doesn't appear to be a DNS issue.
NEW Fix routing. I used the
route
command to add a default gateway pointing to my router's IP address (thanks @chaos).$ /sbin/route -n Kernel IP routing table Destination Gateway Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
NEW See if I have an IP address
$ /sbin/ifconfig -a eth0 Link encap:Ethernet HWaddr 74:d4:35:5f:0b:09 inet6 addr: fe80::76d4:35ff:fe5f:b09/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2999 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:1711 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:365026 (356.4 KiB) TX bytes:0 (0.0 B) Interrupt:73 Base address:0xc000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 inet6 addr: ::1/128 Scope:Host UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:4913 errors:0 dropped:0 overruns:0 frame:0 TX packets:4913 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:1559718 (1.4 MiB) TX bytes:1559718 (1.4 MiB)
It looks like I have an IPv6 address but not an IPv4 address? I would expect
eth0
to have a line starting withinet addr:
, but it doesn't.So how do I obtain an IP address?
Here's some more information that may (or may not) be helpful:
System info
$ uname -a Linux mocha 3.2.0-4-amd64 #1 SMP Debian 3.2.65-1 x86_64 GNU_Linux
Ethernet controller
$ lspci | grep -i eth 03:00.0 Ethernet controller: Realtek Semiconductor Co., Ltd. RTL8111/8168B PCI Express Gigabit Ethernet controller (rev 06)
What should I do next?
-
Anthon about 9 yearsI would try booting from a CD and see if it connects, to make sure this is the Debian configuration that is at fault.
-
dinosaur about 9 yearsThe Debian configuration is not at fault. I've been running it for months with networking. Networking just broke after a recent restart.
-
dinosaur about 9 yearsCould you please indicate how to fix the problems, e.g. if the interface has no IP address or if the routes are wrong.
-
YoMismo about 9 yearsIf you have no IP you can either assign one manually, in which case you should know the network segment where the router is and use a free IP from that range (
ifconfig eth0 192.168.1.15/24
replacing eth0 for your interface and 192.168.1.15/24 for your address and networkmask) if you want to try to get an IP from the DCHP serverdhclient
should get an address for you. But it would be better to specify what you want in /etc/network/interfaces and you will have your network connection up and running whenever you start your machine.route add
command will allow you to set routes. -
GisMofx over 7 yearsMy setup has no routes and when I tried to add a default route, I get an error
SIOCADDRT: No such process
-
Douglas Gaskell over 3 yearsWhat happens if you assign one manually and it still has no network access? (No cabling issues, ports work on other booted OSs)
-
Vincent Alex about 2 yearsifconfig is not Part of default debian11 install, no internet to get it.