import socket
import struct
ip = '192.168.0.255'
mac = '00-11-22-33-44-55'
mac_split = mac.split('-')
address = struct.pack(
'BBBBBB',
int(mac_split[0], 16),
int(mac_split[1], 16),
int(mac_split[2], 16),
int(mac_split[3], 16),
int(mac_split[4], 16),
int(mac_split[5], 16),
)
magic = b'\xFF' * 6 + address * 16
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
sock.setsockopt(socket.SOL_SOCKET, socket.SO_BROADCAST, 1)
sock.sendto(magic, (ip, 9))
sock.close()
출처 : https://sjblog1.tistory.com/35