Raspberry Pi is an amazing piece of hardware that is absolute joy for all kinds of tech projects, from setting up IoT controllers, to building local Kubernetes cluster, to just using it as an affordable Unix Desktop. However, there seems to be a problem with Ethernet (wired internet) connection, at least with some configurations.

My setup is Raspberry Pi 4 Model B, with both WiFi and Ethernet (LAN) modules, running Ubuntu Server 22.04 LTS from Raspberry Pi Imager. When I set it up, only WiFi (WLan) was showing up in active/available network connections:

❯ ifconfig
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 115  bytes 10120 (10.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 115  bytes 10120 (10.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.xxx.x.xxx  netmask 255.255.255.0  broadcast 192.xxx.x.xxx
        inet6 xxxx::xxxx:xxxx:xxxx:xxxx  prefixlen 64  scopeid 0x20<link>
        ether xx:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 2086  bytes 420357 (420.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 538  bytes 126622 (126.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

Fortunately, there is an easy fix. Or at least there was, in my case, and hopefully something that will help you, as well. The culprit, for me, was that there was no startup script authenticating with DHCP server to enable LAN.

To test if the fix will work for you, please run the following command in shell (terminal) of your RPi:

sudo dhclient -v

If everything goes well, you should see eth0 show up:

❯ ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.xxx.x.xxx  netmask 255.255.255.0  broadcast 192.xxx.x.xxx
        inet6 xxxx::xxxx:xxxx:xxxx:xxxx  prefixlen 64  scopeid 0x20<link>
        ether xx:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 14549  bytes 2319637 (2.3 MB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 801  bytes 168254 (168.2 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
		loop  txqueuelen 1000  (Local Loopback)
        RX packets 115  bytes 10120 (10.1 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 115  bytes 10120 (10.1 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.xxx.x.xxx  netmask 255.255.255.0  broadcast 192.xxx.x.xxx
        inet6 xxxx::xxxx:xxxx:xxxx:xxxx  prefixlen 64  scopeid 0x20<link>
        ether xx:xx:xx:xx:xx:xx  txqueuelen 1000  (Ethernet)
        RX packets 2086  bytes 420357 (420.3 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 538  bytes 126622 (126.6 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

That is great! Because, usually RPi’s LAN is much faster than the WiFi module. However, just by running the above command, you cannot get a permanent solution. Indeed, your network will still be gone, after a restart.

To make sure your network is always available, we need to run the command on the machine boot. There are multiple ways to do this on Ubuntu, but I think the most straightforward is to use Cron.

Run following command to edit root cron:

sudo crontab -e

and on a new line, at the end, add the following line:

@reboot dhclient -v

After you save the file, you should be all set! The network should last even after a restart.