This is a simple Kotlin program to send a Wake-on-LAN (WOL) magic packet to wake up computers on a network.
- Send WOL packets by specifying the MAC address, broadcast address, and port.
- Easy to use command line interface.
- Written in Kotlin for simplicity and portability.
- Java Runtime Environment (JRE) 11 or higher
- Kotlin Runtime
To run the program, use the following syntax:
java -jar WakeOnLan.jar <MAC Address> <Broadcast Address> <Port>
<MAC Address>
: The target device's MAC address in the formatXX:XX:XX:XX:XX:XX
.<Broadcast Address>
: The broadcast address of the target network (e.g.,192.168.1.255
).<Port>
: The port number (usually9
for Wake-on-LAN).
java -jar WakeOnLan.jar 01:23:45:67:89:AB 192.168.1.255 9
This command sends a WOL magic packet to the device with the MAC address 01:23:45:67:89:AB
on the broadcast address 192.168.1.255
using port 9
.
- If an invalid MAC address, broadcast address, or port is provided, the program will output an error message.
- Example of invalid input:
Output:
java -jar WakeOnLan.jar 01:23:ZZ:67:89:AB 192.168.1.255 9
Failed to send WOL Packet: Invalid MAC Address
- The MAC address is parsed into bytes.
- A magic packet is constructed by prepending six
0xFF
bytes followed by the MAC address repeated 16 times. - The magic packet is sent as a UDP packet to the specified broadcast address and port.
- Ensure that your device and network support Wake-on-LAN.
- The program requires network permissions to send UDP packets.
To build the program:
- Clone the repository.
- Run using the usage instructions above.