Last active
December 11, 2015 18:58
-
-
Save SinisterMinister/4645297 to your computer and use it in GitHub Desktop.
dnsmasq setup for osx
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
# put in /usr/local/etc/dnsmasq.d/ | |
address=/dev/10.1.1.10 |
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 | |
# DnsChanger | |
# | |
# Automatically change dnsmasq's forward lookup to the dhcp provided dns server. | |
# Based off of Onne Gorter's LocationChanger which can be found at | |
# http://tech.inhelsinki.nl/locationchanger/. | |
# | |
# author: Codey Whitt <codey.whitt@gmail.com> | |
# version: 0.1 | |
# redirect all IO to /dev/null (comment this out if you want to debug) | |
exec 1>/dev/null 2>/dev/null | |
# get a little breather before we get data for things to settle down | |
sleep 5 | |
# Clear the file and set the DNS | |
echo '# Setting DNS from DHCP' > /usr/local/etc/resolv.dnsmasq.conf | |
# Get the DNS from the DHCP | |
DNS=`ipconfig getpacket en1 | grep domain_name_server | egrep -o '\{(.*)\}?' | cut -d '{' -f 2 | cut -d '}' -f 1` | |
OLD_IFS=$IFS; | |
IFS=', ' read -a servers <<< "$DNS" | |
IFS="$OLD_IFS" | |
for ns in "${servers[@]}" | |
do | |
echo "nameserver $ns" >> /usr/local/etc/resolv.dnsmasq.conf | |
done | |
echo `date` "DNS set to: $DNS" >> /var/log/dnsupdater.log | |
# Sleep some more so your system won't think your crashing | |
sleep 5 |
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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" | |
"http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>visualguruz.dnsmasq-osx.dnsupdater</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/usr/local/bin/dnsupdater.sh</string> | |
</array> | |
<key>WatchPaths</key> | |
<array> | |
<string>/Library/Preferences/SystemConfiguration</string> | |
</array> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment