Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Wake On Lan All dhcp leases via shell

    Scheduled Pinned Locked Moved General pfSense Questions
    1 Posts 1 Posters 627 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • J Offline
      javcasta
      last edited by

      Hi.

      Wake On Lan All dhcp leases via shell:

      wol-dhcpleases.sh : a shell script for wake on lan (wol) all dhcp leases

      The code:

      #!/bin/sh
      # wol-dhcpleases.sh
      # wol all dhcp leases via all interfaces
      # by javcasta - 2016 - https://javcasta.com
      
      BROADCAST=$(ifconfig | grep broadcast | cut -d' ' -f 6)
      DHCPLEASES=$(cat /var/dhcpd/var/db/dhcpd.leases | grep "hardware ethernet" | cut -d ' ' -f 5 | sort -u | sed "s|;||")
      for LAMAC in $DHCPLEASES; do
         echo "wake on lan:  ${LAMAC}"
         for ELBROADCAST in $BROADCAST; do
             /usr/local/bin/wol -i ${ELBROADCAST} ${LAMAC}
         done
      done
      

      Tested in pfSense 2.3.2_1

      Regards.

      Javier Castañón
      Técnico de comunicaciones, soporte y sistemas.

      Mi web: https://javcasta.com/

      Soporte scripting/pfSense https://javcasta.com/soporte/

      1 Reply Last reply Reply Quote 0
      • First post
        Last post
      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.