Last active
August 23, 2019 21:34
-
-
Save tonykwon/ae5dcadf82ad4e3372cb3e73779a5b75 to your computer and use it in GitHub Desktop.
tinydns and dnscache setup on OS X
This file contains hidden or 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
/* | |
$ cat /Library/LaunchDaemons/com.tonykwon.alias.plist | |
$ launchctl load -w /Library/LaunchDaemons/com.tonykwon.alias.plist | |
$ reboot | |
*/ | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>com.tonykwon.alias</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/sbin/ifconfig</string> | |
<string>lo0</string> | |
<string>alias</string> | |
<string>127.0.0.2</string> | |
<string>netmask</string> | |
<string>0xff000000</string> | |
</array> | |
<key>RunAtLoad</key> | |
<true/> | |
</dict> | |
</plist> |
This file contains hidden or 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
# Taken from https://gist.githubusercontent.com/zomo/2468712/raw/c017a56ca65d091cce248ff523b5aaf0d2cde8a5/djbdns-osx-dscl.sh | |
#!/bin/sh | |
# taken from http://qmail.jms1.net/djbdns/osx.shtml | |
# find appropriate uid/gids by $ dscl . -list /Users UniqueID | sort -n -k2 | |
# if you are working with a directory services path other than the | |
# local machine, put the correct path here. | |
DSPATH="." | |
# if you need different numeric UID/GID values, set them here | |
NGID="300" # for group djbdns | |
RUID="300" # for user dnsrun | |
LUID="301" # for user dnslog | |
echo dscl "$DSPATH" create /Groups/djbdns PrimaryGroupID $NGID | |
echo dscl "$DSPATH" create /Users/dnsrun UniqueID $RUID | |
echo dscl "$DSPATH" create /Users/dnsrun PrimaryGroupID $NGID | |
echo dscl "$DSPATH" create /Users/dnsrun UserShell /bin/false | |
echo dscl "$DSPATH" create /Users/dnsrun NFSHomeDirectory /nohome | |
echo dscl "$DSPATH" create /Users/dnsrun RealName dnsrun | |
echo dscl "$DSPATH" create /Users/dnslog UniqueID $LUID | |
echo dscl "$DSPATH" create /Users/dnslog PrimaryGroupID $NGID | |
echo dscl "$DSPATH" create /Users/dnslog UserShell /bin/false | |
echo dscl "$DSPATH" create /Users/dnslog NFSHomeDirectory /nohome | |
echo dscl "$DSPATH" create /Users/dnslog RealName dnslog | |
echo dscl "$DSPATH" create /Groups/djbdns GroupMembership dnsrun dnslog |
This file contains hidden or 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
0. create users then hide dnsrun and dnslog users from the login window | |
$ sh create-user-group.sh | |
$ sudo defaults write /Library/Preferences/com.apple.loginwindow HiddenUsersList -array-add dnsrun dnslog | |
1. Install daemontools -> http://cr.yp.to/daemontools.html | |
$ mkdir /package | |
$ cd /package | |
$ curl http://cr.yp.to/daemontools/daemontools-0.76.tar.gz -o daemontools-0.76.tar.gz | |
$ tar -xvzf daemontools-0.76.tar.gz | |
$ cd admin/daemontools-0.76 | |
$ package/install | |
remove "csh -cf '/command/svscanboot &'" from /etc/rc.local as OS X does not use /etc/rc.local | |
2. Install ucspi-tcp -> http://cr.yp.to/ucspi-tcp.html | |
$ cd /package | |
$ curl http://cr.yp.to/ucspi-tcp/ucspi-tcp-0.88.tar.gz -o ucspi-tcp-0.88.tar.gz | |
$ tar -xvzf ucspi-tcp-0.88.tar.gz | |
$ cd ucspi-tcp-0.88 | |
$ make | |
$ make setup check | |
3. Install djbdns -> http://cr.yp.to/djbdns.html | |
$ cd /package | |
$ curl http://cr.yp.to/djbdns/djbdns-1.05.tar.gz -o djbdns-1.05.tar.gz | |
$ tar -xvzf djbdns-1.05.tar.gz | |
$ cd djbdns-1.05 | |
$ make | |
$ make setup check | |
4. Setup tinydns | |
$ sudo tinydns-conf dnsrun dnslog /usr/local/tinydns 127.0.0.1 | |
$ sudo echo '127.0.0.2' > /user/local/tinydns/env/IP | |
add .dev entries to /usr/local/tinydns/root/data | |
.dev::600:: | |
+*.dev:127.0.0.1 | |
$ make | |
5. Setup dnscache | |
$ sudo dnscache-conf dnsrun dnslog /usr/local/dnscache 127.0.0.1 | |
$ sudo echo '127.0.0.2' > /usr/local/dnscache/root/servers/dev | |
6. | |
$ ln -s /usr/local/tinydns /service | |
$ ln -s /usr/local/dnscache /service | |
7. Test | |
$ env DNSCACHEIP=127.0.0.1 dnsqr a php.dev | |
$ env DNSCACHEIP=127.0.0.1 dnsqr a www.google.com | |
Adjust cache size | |
$ echo 100000000 > /service/dnscache/env/CACHESIZE | |
$ echo 104857600 > /service/dnscache/env/DATALIMIT | |
$ svc -t /service/dnscache | |
Adjust concurrent connections ( /service/dnscache/run ) | |
softlimit -o1500 |
This file contains hidden or 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
/* | |
$ cat /Library/LaunchDaemons/to.yp.cr.daemontools.plist | |
$ launchctl load -w /Library/LaunchDaemons/to.yp.cr.daemontools.plist | |
$ reboot | |
*/ | |
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>Label</key> | |
<string>to.yp.cr.daemontools</string> | |
<key>ProgramArguments</key> | |
<array> | |
<string>/command/svscanboot</string> | |
<string>&</string> | |
</array> | |
<key>RunAtLoad</key> | |
<true/> | |
</dict> | |
</plist> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment