Wake on LAN (WOL) for Ubuntu 20
nano /etc/systemd/system/wol.service
[Unit] Description=Wake-on-LAN for <interface id> Requires=network.target After=network.target [Service] ExecStart=/sbin/ethtool -s <interface id> wol g ExecStop=/sbin/ethtool -s <interface id> wol g [Install] WantedBy=multi-user.target
systemctl start wol.service systemctl enable wol.service systemctl is-enabled wol.service systemctl daemon-reload
Wake on LAN (WOL) for Ubuntu 18 (Bionic)
On a server without GUI = with “Netplan” and without “Network-manager”
https://askubuntu.com/questions/1053302/wake-on-lan-not-working-if-i-turn-of-with-ubuntu
Send a Magic Packet at startup for Ubuntu 20
Useful to wakeup a server when the client starts.
$ sudo nano /etc/systemd/system/wol-omv.service [Unit] After=network-online.target Wants=network-online.target [Service] ExecStart=/usr/local/bin/wol-omv.sh [Install] WantedBy=default.target
sudo nano /usr/local/bin/wol-omv.sh #!/bin/bash /usr/sbin/etherwake -i enp34s0 69:70:BC:AD:4B:A2 ///// use your correct interface name and the correct mac address!!
sudo chmod 744 /usr/local/bin/wol-omv.sh sudo chmod 664 /etc/systemd/system/wol-omv.service
sudo systemctl start wol-omv.service sudo systemctl enable wol-omv.service sudo systemctl daemon-reload
Script pour contrôler que la machine qui a recu le paquet magique s'est bien lancée - peut être ajouté au script de WOL:
# enter le suffixe de l'adresses de la machine à surveiller - sur réseau: 192.168.20.0 ip=(69) for i in `seq 1 10`; do echo "test ping sur IP 192.168.20."$ip":"; if $(ping -c 1 192.168.20.$ip &> /dev/null) ; then echo "machine 192.168.20."$ip" en ligne" beep -f 1000 -n -f 2000 -n -f 1500 exit else echo "machine 192.168.20."$ip" pas présente" sleep 10s; fi done echo "machine 192.168.20."$ip" pas présente" beep -f 300.7 -r 2 -d 100 -l 400