Skip to content

pthevenet/layer2-wol

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

layer2-wol

Go Report Card

layer2-wol is a CLI tool and a library to send and create layer-2 (Ethernet) Wake-on-Lan "magic" packets.
This is used to start a (Wake-on-Lan activated) computer on the same Local Area Network.
Wake-on-Lan is a Data Link Layer standard.

Usage

CLI Tool

to build the tool binary:

go build
./layer2-wol -h
Usage of ./layer2-wol:
  -iface string
    	interface (default "*")
  -mac string
    	target MAC address (Required)

Example

send a wol packet to aa:aa:aa:aa:aa:aa on interface eth0

./layer2-wol -iface eth0 -mac "aa:aa:aa:aa:aa:aa"

GO Library

package main

import (
	"fmt"
	"log"
	"net"

	"github.com/pthevenet/layer2-wol/wol"
)

func main() {
	target_mac := "aa:aa:aa:aa:aa:aa"
	target_addr, err := net.ParseMAC(target_mac)
	if err != nil {
		log.Fatalf("could not parse mac %s: %v", target_mac, err)
	}

	magic_pkt := wol.NewMagicPacket(target_addr)

	fmt.Println(magic_pkt)
}

Notes

go-wol uses UDP sockets (layer-4) for sending WOL packets, however we recommend using it over this library.

Releases

No releases published

Packages

No packages published

Languages