Skip to content

Instantly share code, notes, and snippets.

@ndunks
Last active June 15, 2020 03:13
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save ndunks/0afc779e126b99d1a3321c0fcfbbe273 to your computer and use it in GitHub Desktop.
dnsmasq DHCP Server Example and logging
#!/bin/bash
if [ -z "$1" ]; then
IFACE=`ip l | grep ^2: | cut -d ' ' -f2`
# remove last ':'
IFACE=${IFACE::-1}
else
IFACE="$1"
fi
echo "Setup dnsmasq on $IFACE"
# enable inet access
echo 1 | sudo tee /proc/sys/net/ipv4/ip_forward
sudo iptables -t nat -A POSTROUTING -j MASQUERADE
# Ip and Up
sudo ifconfig $IFACE up 192.168.2.1
sudo dnsmasq --no-daemon --log-queries --log-dhcp \
--bind-interfaces --conf-file= --conf-dir= \
--interface=$IFACE --except-interface=lo \
--dhcp-range=192.168.2.100,192.168.2.200,12h \
--listen-address=192.168.2.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment