summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan Huwald <jh@sotun.de>2012-04-27 20:44:18 (GMT)
committerJan Huwald <jh@sotun.de>2012-04-27 20:44:18 (GMT)
commitc90d4f95dcb8b98210b87dade1fd0a4cfe9368cb (patch)
treebf4c3fc1a903cf404c05909093c7706d1d544835
parentc3797238329c40150a308bb3a76bf90f9eb1b499 (diff)
ccfg: sync dnsmasq dhcp config with ccfg p2ptbl
-rw-r--r--files/common/etc/dnsmasq.conf5
-rwxr-xr-xfiles/common/sbin/sync_dhcp21
2 files changed, 26 insertions, 0 deletions
diff --git a/files/common/etc/dnsmasq.conf b/files/common/etc/dnsmasq.conf
new file mode 100644
index 0000000..85547e5
--- /dev/null
+++ b/files/common/etc/dnsmasq.conf
@@ -0,0 +1,5 @@
+dhcp-hostsfile=/tmp/dhcp.hostconfig
+
+tag-if=set:wrong-if,tag:br-lan,tag:only-wifi
+tag-if=set:wrong-if,tag:br-mesh,tag:only-wire
+dhcp-ignore=tag:wrong-if
diff --git a/files/common/sbin/sync_dhcp b/files/common/sbin/sync_dhcp
new file mode 100755
index 0000000..bb9b7ba
--- /dev/null
+++ b/files/common/sbin/sync_dhcp
@@ -0,0 +1,21 @@
+#!/bin/sh -e
+
+dst=/tmp/dhcp.hostconfig
+
+add_tbl() {
+ p2ptbl show /tmp/p2ptbl/ccfg_$1 \
+ | tr '\t' ',' \
+ | cut -f 1,2,5 -d, \
+ | while IFS=, read mac name ip; do
+ [ -z "$name$ip" ] && continue
+ echo "$mac,set:only-$1${ip:+,$ip}${name:+,$name}"
+ done >> $dst~
+}
+
+rm -f $dst~
+add_tbl wifi
+add_tbl wire
+mv $dst~ $dst
+
+# trigger reload of dhcp-hosts-file
+killall -SIGHUP dnsmasq \ No newline at end of file
contact: Jan Huwald // Impressum