Skip to content

Instantly share code, notes, and snippets.

@latsku
Created November 17, 2025 12:18
Show Gist options
  • Select an option

  • Save latsku/f88f4a81b5095c5b0faa46359414af22 to your computer and use it in GitHub Desktop.

Select an option

Save latsku/f88f4a81b5095c5b0faa46359414af22 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python3
from scapy.all import DHCP_am
from scapy.base_classes import Net
import subprocess
interface = "eth0"
own_ip = "192.168.10.1"
dhcp_server = DHCP_am(iface=interface, domain='example.com',
pool=Net('192.168.10.0/24'),
network='192.168.10.0/24',
gw=own_ip,
renewal_time=600, lease_time=3600)
subprocess.run(["ip addr add local " + own_ip +"/24 broadcast 192.168.10.255 dev " + interface], shell=True)
print(f"IP set to {own_ip}")
print("Starting DHCP server...")
dhcp_server()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment