Posts tagged with “linux”

Fixing wakeonlan on DietPi: Missing Protocol Database

Fixing Wake-on-LAN on DietPi: Missing Protocol Database

Problem

When running wakeonlan on DietPi, you may see these errors:

Use of uninitialized value $proto in socket at /usr/bin/wakeonlan line 121.
send : Invalid argument at /usr/bin/wakeonlan line 126.

The root cause is Perl's getprotobyname("udp") failing with "No such file or directory" because the protocol database is missing.

Diagnosis

Check if Perl can access protocol information:

perl -e 'print getprotobyname("udp") || die "getprotobyname failed: $!";'

If it fails with "No such file or directory", proceed to the next step.

Verify if /etc/protocols exists:

ls -l /etc/protocols

If the file doesn't exist, you need to install netbase.

If the file exists, check if it contains UDP protocol information:

grep udp /etc/protocols

You should see a line like:

udp 17 UDP # user datagram protocol

Solution

If /etc/protocols is missing, install the netbase package:

sudo apt-get update
sudo apt-get install netbase

Why It Works

  • wakeonlan uses Perl's getprotobyname() to get the UDP protocol number.
  • This function requires /etc/protocols to map protocol names to numbers.
  • DietPi, being a minimal distribution, doesn't include netbase by default.
  • The UDP protocol is assigned number 17 in the protocols file.

After installing netbase, wakeonlan works correctly because it can now look up the UDP protocol number required for creating the socket.