-
-
Save meeuw/7697261 to your computer and use it in GitHub Desktop.
Hookscript for dhclient (place in /etc/dhcp/dhclient.d) to configure dnsmasq (using dbus) with the supplied nameserver. Add enable-dbus to dnsmasq
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function inet_aton () { | |
local count=3 | |
local int=0 | |
for num in $(echo $1 | sed -e 's/\./ /g'); do | |
let "int+=$num*256**$count" | |
let "count-=1" | |
done | |
echo $int | |
} | |
if [ "$new_domain_name_servers" ] ; then | |
SetServers=$new_domain_name_servers | |
elif [ "$DHCP4_DOMAIN_NAME_SERVERS" ] ; then | |
SetServers=$DHCP4_DOMAIN_NAME_SERVERS | |
else | |
SetServers="8.8.8.8 8.8.4.4" | |
fi | |
dnsmasq_config() { | |
echo uint32:$(inet_aton $SetServers) > /var/lib/dnsmasq/SetServers | |
dbus-send --system --dest='uk.org.thekelleys.dnsmasq' /uk/org/thekelleys/dnsmasq uk.org.thekelleys.SetServers $(< /var/lib/dnsmasq/SetServers) | |
} | |
: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment