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
wakeonlanuses Perl'sgetprotobyname()to get the UDP protocol number.- This function requires
/etc/protocolsto map protocol names to numbers. - DietPi, being a minimal distribution, doesn't include
netbaseby default. - The UDP protocol is assigned number
17in theprotocolsfile.
After installing netbase, wakeonlan works correctly because it can now look up the UDP protocol number required for creating the socket.