Skip to content

Instantly share code, notes, and snippets.

@KrazyIvan-
Forked from ruzickap/openwrt_dhcp.sh
Created November 21, 2017 02:50
Show Gist options
  • Save KrazyIvan-/ef8cb27d0c2dbfc724e8f9528b52e23b to your computer and use it in GitHub Desktop.
Save KrazyIvan-/ef8cb27d0c2dbfc724e8f9528b52e23b to your computer and use it in GitHub Desktop.
OpenWrt DHCP modifications
uci set dhcp.lan.start=200
uci set dhcp.lan.limit=54
uci set dhcp.@dnsmasq[0].domain=xvx.cz
uci set dhcp.@dnsmasq[0].leasefile=/etc/dnsmasq-dhcp.leases
#Send email for new connections:
echo "dhcp-script=/etc/dnsmasq-script.sh" >> /etc/dnsmasq.conf
cat > /etc/dnsmasq-script.sh << \EOF
#!/bin/sh
/bin/echo `/bin/date +"%F %T"` $* >> /etc/dnsmasq.script.log
if [ "$1" == "add" ] && ! grep -iq $2 /etc/config/dhcp; then
echo -e "Subject: New MAC on `uci get system.@system[0].hostname`.`uci get dhcp.@dnsmasq[0].domain`\\n\\n`/bin/date +"%F %T"` $*" | sendmail [email protected]
fi
EOF
chmod a+x /etc/dnsmasq-script.sh
# WiFi
uci add dhcp host
uci set dhcp.@host[-1].name=peru-nb-work-wifi
uci set dhcp.@host[-1].ip=192.168.1.2
uci set dhcp.@host[-1].mac=5c:51:4f:7e:e0:d2
uci add dhcp host
uci set dhcp.@host[-1].name=andy-nb-wifi
uci set dhcp.@host[-1].ip=192.168.1.3
uci set dhcp.@host[-1].mac=74:f0:6d:93:c7:3a
uci add dhcp host
uci set dhcp.@host[-1].name=peru-nb-old-wifi
uci set dhcp.@host[-1].ip=192.168.1.4
uci set dhcp.@host[-1].mac=00:15:00:11:48:5A
uci add dhcp host
uci set dhcp.@host[-1].name=andy-android-wifi
uci set dhcp.@host[-1].ip=192.168.1.5
uci set dhcp.@host[-1].mac=00:23:76:D6:42:C7
uci add dhcp host
uci set dhcp.@host[-1].name=peru-android-work-wifi
uci set dhcp.@host[-1].ip=192.168.1.6
uci set dhcp.@host[-1].mac=a4:eb:d3:44:7a:23
uci add dhcp host
uci set dhcp.@host[-1].name=peru-palm-wifi
uci set dhcp.@host[-1].ip=192.168.1.7
uci set dhcp.@host[-1].mac=00:0b:6c:57:da:9a
uci add dhcp host
uci set dhcp.@host[-1].name=RTL8187-wifi
uci set dhcp.@host[-1].ip=192.168.1.8
uci set dhcp.@host[-1].mac=00:C0:CA:54:F5:BA
uci add dhcp host
uci set dhcp.@host[-1].name=peru-tablet-wifi
uci set dhcp.@host[-1].ip=192.168.1.9
uci set dhcp.@host[-1].mac=00:22:f4:f6:f3:0b
# NIC
uci add dhcp host
uci set dhcp.@host[-1].name=peru-nb-work-nic
uci set dhcp.@host[-1].ip=192.168.1.130
uci set dhcp.@host[-1].mac=28:d2:44:31:31:90
uci add dhcp host
uci set dhcp.@host[-1].name=andy-nb-nic
uci set dhcp.@host[-1].ip=192.168.1.131
uci set dhcp.@host[-1].mac=20:cf:30:31:da:b3
uci add dhcp host
uci set dhcp.@host[-1].name=peru-nb-old-nic
uci set dhcp.@host[-1].ip=192.168.1.132
uci set dhcp.@host[-1].mac=00:13:D4:D1:03:57
uci add dhcp host
uci set dhcp.@host[-1].name=peru-tv-nic
uci set dhcp.@host[-1].ip=192.168.1.133
uci set dhcp.@host[-1].mac=00:12:FB:94:1B:9A
uci add dhcp host
uci set dhcp.@host[-1].name=raspberrypi-nic
uci set dhcp.@host[-1].ip=192.168.1.134
uci set dhcp.@host[-1].mac=b8:27:eb:8c:97:9e
uci add dhcp host
uci set dhcp.@host[-1].name=server-nic
uci set dhcp.@host[-1].ip=192.168.1.135
uci set dhcp.@host[-1].mac=00:1f:c6:e9:f5:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment