The following notes are intended to help with a number of typical Raspberry Pi network problems.
- Network interface “eth0” is missing
- Network connection is extinguished
- Delay at boot
- The file “/etc/resolv.conf” is overwritten
- Duplicate IPv4 addresses
- Missing IPv4 configuration
- Error messages on the command line because of the hostname
- No internet connection anymore
Raspberry pi eth0 link is down
Problem: Network interface “eth0” is missing
When configuring the network, you notice that the internal network interface “eth0” is missing. Instead, there is an interface called “enx …”.
Since Raspbian Jessie, for USB adapters, the network interfaces “eth0” etc., as well as “wlan0”, etc. are replaced by “enx …” or “wlx …” plus MAC address. This binds the interface name to the hardware interface and avoids confusion. Unfortunately, this has the disadvantage that the usual shortcuts no longer work.
One solution would be to first determine the individual name and make the network configuration based on the individual name. Another solution would be to change the naming process to the old one.
Raspberry pi ethernet not working
Problems: Network connection is lost
The problem descriptions are as follows:
- Raspberry Pi connects to the network after booting without any problems. However, the connection leaves after some time and will not be restored.
- After some time, remote access will stop working. Then just pull the plug.
90% of all network problems related to connection problems are related to the power supply.
- A too long or unsuitable USB cable between power supply and Raspberry Pi.
- The power supply is too weak or unsuitable for operation on Raspberry Pi with heavily fluctuating power consumption from additional USB devices.
Often network issues with Raspberry Pi are related to an unstable power supply. So it can happen that at a low operating voltage, below 5 volts, Raspberry Pi for stabilization, reduces the power consumption by switching off individual components. For example, the USB. Not only the usual peripheral devices are connected to them, but also the Ethernet port internally. If the internal USB goes out of order, then this also affects the network connection. The goes back to operation at stable operating voltage. But that does not mean that after that everything will work again as desired.
For sporadic failures and network problems, you should first swap the power supply. Especially if the network configuration has worked before, and then suddenly not more. Often then the power supply is guilty.
- Best Raspberry Pi power supply
- Basics of Raspberry Pi Power Supply
- Measure Raspberry Pi power consumption
Problem: Delay at boot
When booting, the boot process stops with the error message “A start Job is running for dhcpcd on all interfaces”. In addition to this error message, red colored stars appear. Behind it runs a counter that counts about 1 minute and 30 seconds down. Nothing happens until then, which increases the total boot time of the Raspberry Pi by this time.
It is about the service “dhcpcd”. This is the DHCP Client Daemon (DHCPCD), which is responsible for ensuring that all network interfaces get an IP configuration. The reason why this does not continue here is that one of the network interfaces still has no connection to the network. It may be that the network cable is not yet plugged in and / or that a WLAN adapter is not configured for a WLAN connection or that the configured WLAN network is unreachable.
The problem also occurs when there is a network configuration but there is no network connection.
Solution 1: Shorten boot delay with DHCPCD
To do this, make a change in the following file:
sudo nano /etc/dhcpcd.conf
Enter the following line there (in seconds):
Solution 2: Connect to the network
There is only one real solution. You have to connect Raspberry Pi to the network. Either by cable or WiFi. The fastest way is by cable, because the interface is then ready at boot time. For wifi, it can take longer, because the interface must first authenticate against the wifi access point.
Problem: The file “/etc/resolv.conf” is overwritten after the reboot
After rebooting the system, the file “/etc/resolv.conf” always contains an incorrect IP address. If the correct DNS server is then entered manually, the file is overwritten after a reboot.
How can I ensure that the correct DNS server is automatically entered in the file “/etc/resolv.conf”?
Basically, the file “/etc/resolv.conf” is generated automatically. Making manual changes has only temporary effects. Most of the changes are gone after a reboot. Sometimes they also last for hours or days. Which is the exception.
There are services that configure this file. And that’s good in principle. The question now is, what do you do when you do a static configuration? Then such services are counterproductive.
The first thing to do is find out which service spits you into the soup. There are multiple possibilities. You can choose between various DHCP clients and network managers. For example, “dhcpcd”. Both have the task of providing the network interfaces with an IP configuration. For IPv4 via DHCP and for IPv6 via SLAAC or DHCPv6.
That’s why we’re interested in which DHCP client is running:
sudo netstat -tulps | grep -i dhc
Solution 1: Turn off the DHCP service
Basically, you solve the problem by turning off these services or completely removed (conditionally recommended).
Is the “dhcpcd” installed? If yes, then disable. After that, a reboot is recommended.
sudo service dhcpcd status sudo service dhcpcd stop sudo systemctl disable dhcpcd
Solution 2: Write protection for /etc/resolv.conf
A quick & dirty solution would be to set the file “/etc/resolv.conf” to readonly. Before you have to enter the DNS server manually.
But that does not fix the basic configuration error. This solution should be chosen only in exceptional cases.
sudo chattr + i /etc/resolv.conf
Solution 3: Turn off resolvconf (not recommended)
An alternative would be to uninstall “resolvconf” and then maintain the file “/etc/resolv.conf” manually. If the system is not mobile, that would not be a big disadvantage.
Raspberry pi Duplicate IP
Problem: Duplicate IPv4 addresses
A popular bug is that Raspberry Pi has two IPv4 addresses on a network interface. An effect may be that an interface has two IP addresses or an IP configuration that was not intended.
Sometimes you do not notice it. And it does not necessarily have any effect. Nevertheless, one must expect network problems.
This is because one unknowingly runs two different types of IPv4 configuration in parallel. Despite or even because of a static IP configuration, Raspberry Pi has two IP addresses. One you forgave yourself and a second, which was somehow allocated via DHCP. Both can be pinged and connected via SSH (sometimes not).
It’s important to note that since Raspbian Wheezy of 2015-05-05 and Raspbian Jessie, the network configuration has been done via the DHCP client Deamon (DHCPCD) and not in the file “/etc/network/interfaces”. If you do it anyway, the DHCPCD has a habit of replacing or adding the network configuration that is listed in the /etc/network/interfaces file (depending on the configuration).
To determine if the problem really exists, we check to see if a DHCP client is installed and running.
sudo service dhcpcd status
Solution 1: Disable DHCPCD (not recommended)
If you still want to or have to do the network configuration in the file “/etc/network/interfaces”, then it is recommended to deactivate the DHCPCD.
Note: This solution is not recommended. However, there are network configurations that can only be made in the file “/etc/network/interfaces”. You then have to live with the advantages and disadvantages.
Solution 2: Network configuration via DHCPCD
The basic recommendation is to leave the configuration in the file “/etc/network/interfaces” in the original and to do it in the file “/etc/dhcpcd.conf” in the future. It must be remembered that the syntax differs from each other.
Solution 3: Coexistence of DHCPCD and the / etc / network / interfaces file
An alternative to the previous one-or-two solutions would be an as-well as solution. In which the network configuration of DHCPCD and the file “/etc/ network/interfaces” can coexist. If you do not want to deactivate the DHCPCD because you need it for an interface, you can also exclude or explicitly release the configuration for an interface. Note: That would be the best of all solutions.
Solution 4: Uninstall other DHCP clientsIt may happen that the DHCPCD is already uninstalled. And yet Raspberry Pi gets an IP address from somewhere via DHCP. In that case, one should prophylactically uninstall all possible DHCP clients.
sudo apt-get remove isc-dhcp-client sudo apt-get remove udhcpd
Contents of the original file “/ etc / network / interfaces” (for solution 2)
Occasionally it happens that you have completely destroyed your network configuration and just want to restore the original file.
The contents of the file “/ etc / network / interfaces” looks like this in the original state (before Raspbian Wheezy from 2015-05-05):
car lo iface lo inet loopback iface eth0 inet dhcp allow-hotplug wlan0 iface wlan0 inet manual wpa-roam /etc/wpa_supplicant/wpa_supplicant.conf iface default inet dhcp
The contents of the file “/etc/network/interfaces” looks in the original state as follows (from Raspbian Jessie):
For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf' # Include files from /etc/network/interfaces.d: source-directory /etc/network/interfaces.d car lo iface lo inet loopback iface eth0 inet manual allow-hotplug wlan0 iface wlan0 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1 iface wlan1 inet manual wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
Problem: Missing IPv4 configuration
For some reason, a DHCP request does not seem to occur at boot time. The commands “ip a” and “ifconfig” showed that no IPv4 configuration was done.
Analysis: Check formatting
A missing IP configuration can result from having a format error in one of the configuration files, so they could not be processed correctly. Thus, invisible control characters may have been inserted by editing with an inappropriate editor.
cat -A /etc/dhcpcd.conf cat -A /etc/network/interfaces
You can see nicely if there is a sign somewhere where none belong.
Analysis: Check the DHCP client
Assuming there is a network connection at all, you can check which DHCP client is running.
sudo netstat -tulps | grep -i dhc
If so, then you can try the following solutions.
There is no “auto eth0” or “allow-hotplug eth0” in the / etc / network / interfaces file.
Solution 2 (temporary)
Commission the network interface:
sudo ifup eth0
sudo dhclient -v eth0
Then the interface should get the IP configuration via DHCP.
If you want to quickly make an IPv4 configuration without editing files, you can do that with a few commands on the command line. The settings are then gone but after a restart.
The IPv4 addresses of the following examples are to be adapted to the respective requirements.
IP address and subnet mask:
sudo ip addr add 192.168.1.5/24 dev eth0
sudo ip route add default via 192.168.1.1
sudo route add default gw 192.168.1.1 eth0
The DNS server must be permanently entered in the file “/etc/resolv.conf”:
sudo echo "nameserver 192.168.0.1" >> /etc/resolv.conf
Note: This configuration will be lost after a reboot.
Problem: Error messages on the command line because of the hostname
The following or similar error messages appear continuously on the command line:
sudo: hostname raspberrypi can not be resolved sudo: unable to resolve host raspberrypi
Why is this and what should be done?
The reason is that the host name has changed. And the error message states that the hostname could not be resolved. That’s because somewhere else a wrong hostname is entered.
There are a total of three clues as to where to look for the mistake.
cat /etc/hostname cat /etc/hosts cat /etc/resolv.conf
One of these files contains an incorrect host name.
Basically, it is recommended to use the tool “raspi-config” to change the host name and then to reboot.
Change hostname of a Raspberry Pi
Problem: No internet connection
The default gateway is in a network the transition to the Internet or the next higher part of the network that leads to the Internet. As a rule, this is the access network of your own Internet provider. The connection to the Internet is only possible if a host knows the IP address of the standard gateway. Without this IP address, only connections in the local network are possible.
Analysis: Check standard gateway
The output should be something like this:
Kernel IP routing table
Target Router Genmask Flags Metric Ref Use Iface 0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0 192.168.1.1 0.0.0.0 255.255.255.0 U 0 0 0 eth0 netstat -r
The output should be something like this:
Kernel IP routing table
Target router Genmask Flags MMS window irtt Iface
default 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
192.168.1.0 * 255.255.255.0 U 0 0 0 eth0
The first line in both tables is important. It starts with “0.0.0.0” or “default”. This is the default or default route, ie the destination that always applies if the host does not know the route to the destination address. The default gateway is then responsible for the data packet. But, the IP address of the default gateway must be known to the host. This is the case if the IP address is entered here. In the case exemplarily “192.168.1.1”.
If there is no line with “0.0.0.0” or “default”, or an incorrect IP address is entered here, then usually no connection to the Internet will be possible.
The reason for the absence of the default gateway is an incomplete manual IP configuration or the DHCP server has submitted an incomplete IP configuration. Or there was no IP configuration.
If the table has a default route and the IP address is the same as the default gateway, and you still can not connect to the Internet, the default gateway may be disconnected from the Internet or turned off. This can be clarified with a ping on the default gateway.
ping -c 5 192.168.1.1
If the default gateway is reachable then the configuration regarding the standard gateway is correct.
If still no Internet connection is possible, then it may be due to a non-working name resolution.
Analysis: Check name resolution
The name resolution ensures that a domain name such as http://www.elektronik-kompendium.de/ becomes an IP address. Because Internet connections are only possible on the basis of an IP address. Name resolution is the responsibility of a DNS server whose IP address must be specified in the IP configuration.
First of all, we check the name resolution:
The output should be an IP address. If that does not work, local name resolution will not work. So we check if the name resolution works via an external name server.
host www.kalitut.com 220.127.116.11
If that does not work, then you should check the internet connection. So in the case the Internet access router and the Internet connection.
If the name resolution works only through the external name server, the entry for the name server may be missing in the IP configuration.
As a rule, the output should also result in a line with “nameserver” and an IP address. This IP address is usually the same as the IP address of the default gateway. In small local networks, the default gateway is also the DNS server or name server.
It often happens that an old IP address or none is entered from previous IP configurations. In such a case you should check the IP configuration (manually or via DHCP).
Note: It often happens that Raspberry Pi suddenly no longer gets an internet connection. The reason is, at the initial installation, Raspberry Pi pulls the IP configuration via DHCP. The DNS server is written to the file “/etc/resolv.conf”. At some point later, the DHCP client will be disabled and the IP configuration will be manually created. The information for the name server is forgotten. The entry in the file “/etc/resolv.conf” is still preserved. At some point, the file will be overwritten for some reason. And suddenly, no internet connection is possible because the name resolution no longer works.
Solution: Make correct network configuration
What if all that did not help?
Sometimes there are very complicated constellations in whose processes one simply can not look. This means that you can not find a bug, but still have a network problem. Then it is recommended to really use another power supply. Even if that does not help, you have to resort to unusual means.
The following tips for resolving network issues with Raspberry Pi are just a last straw. It may well be that it helps in one way or another, but it does not have to. So there is no guarantee of success.
Sometimes it just helped to do an update.
sudo apt-get update sudo apt-get upgrade sudo reboot
Basically, one should not rule out that the problem is not s.Raspberry Pi, but perhaps in the local network to look for, even if there are no problems with other devices.
You should also take a look at your own internet router. Maybe this will help restart or something is wrongly configured. Many internet routers have already played crazy.
Overview: Network configuration of Raspberry Pi
- Determine the network and IP configuration of Raspberry Pi
- Static IPv4 address for Raspbian Jessie (Raspberry Pi)
- Change hostname of Raspberry Pi
- Turn on and configure IPv6 on Raspberry Pi
- Enable IPv6 Privacy Extensions for Raspbian Jessie (Raspberry Pi)
- Enable IPv6 Privacy Extensions for Raspbian Wheezy (Raspberry Pi)
- Set up a fixed IPv6 address for Raspberry Pi
- Set up WiFi adapter on Raspberry Pi