Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Install and setup bind (named) on Mac OS X 10.10.1 with brew 0.9.5
#!/bin/bash
# Run as root or sudo the commands that need it as you go.
# brew version 0.9.5
# Mac OS X 10.10.1
# A little bit changed version of this:
# http://stackoverflow.com/questions/19538118/osx-mavericks-bind-no-longer-installed-how-to-get-local-dns-server-working
# 1) USE HOMEBREW TO INSTALL BIND
brew install bind
# 2) CONFIGURE BIND
# Create a custom launch key for BIND
/usr/local/sbin/rndc-confgen > /etc/rndc.conf
head -n 6 /etc/rndc.conf > /etc/rndc.key
# Set up a basic named.conf file.
# Brew directory could be slightly different mine is this /usr/local/Cellar/bind/9.10.1-P1/
cd /usr/local/Cellar/bind/*/etc
cat > named.conf <<END
//
// Include keys file
//
include "/etc/rndc.key";
// Declares control channels to be used by the rndc utility.
//
// It is recommended that 127.0.0.1 be the only address used.
// This also allows non-privileged users on the local host to manage
// your name server.
//
// Default controls
//
controls {
inet 127.0.0.1 port 54 allow {any;}
keys { "rndc-key"; };
};
options {
directory "/var/named";
};
//
// a caching only nameserver config
//
zone "." IN {
type hint;
file "named.ca";
};
zone "localhost" IN {
type master;
file "localhost.zone";
allow-update { none; };
};
zone "0.0.127.in-addr.arpa" IN {
type master;
file "named.local";
allow-update { none; };
};
logging {
category default {
_default_log;
};
channel _default_log {
file "/Library/Logs/named.log";
severity info;
print-time yes;
};
};
END
# Symlink Homebrew's named.conf to the typical /etc/ location.
ln -s /usr/local/Cellar/bind/*/etc/named.conf /etc/named.conf
# Create directory that bind expects to store zone files
mkdir /var/named
curl http://www.internic.net/domain/named.root > /var/named/named.ca
# If you are using some third party DNS you should add: nameserver 127.0.0.1 in /etc/resolv.conf
# If your resolv.conf file is automaticaly generated you should change it on startup in order to work properly
# Start bind
sudo /usr/local/sbin/named
# Check if it is working
dig google.com
@cyril-bouthors
Copy link

cyril-bouthors commented Dec 4, 2015

Thanks for sharing the script, it really helped.

I made a few improvements required to make it work with the current Brew version and any latest.

I hope you can apply the 2 line patch at https://gist.github.com/cyril-bouthors/d62ecb9baba23f400e81

Regards,

@mpaskalev
Copy link
Author

mpaskalev commented Dec 27, 2015

Thanks @cyril-bouthors,

Just applied your changes. Glad to know it helped someone else, too.

Regards

@alisade
Copy link

alisade commented Jun 22, 2016

Thanks for the script.

All this is lacking is an automatic startup script like this;
https://gist.github.com/alisade/33355dcfb8a5264d77444f1b035d6554

AND to load it
launchctl load -wF /System/Library/LaunchDaemons/org.isc.named.plist

@coreyroach
Copy link

coreyroach commented Jul 9, 2019

Thanks for the script.

All this is lacking is an automatic startup script like this;
https://gist.github.com/alisade/33355dcfb8a5264d77444f1b035d6554

AND to load it
launchctl load -wF /System/Library/LaunchDaemons/org.isc.named.plist

Just to update @alisade's comment, /System/Library/LaunchDaemons/ is now a private directory; even as root.

Use: /Library/LaunchDaemons/org.isc.named.plist

@irfanalii
Copy link

irfanalii commented Jul 2, 2020

Thanks for sharing this.

I have Mac OS Catalina 10.15.5 and do see that dig/bind is installed on this version of macos. What I would like to do is to experiment with creating dns zone files and experimenting (creating naptr records etc) with those using dig, but I do not see any /var/named or /etc/named.config. How to create and use dns zone files in macos catalina 10.15.5. Do I need to brew install bind as you have in this post (if so will there any conflict with the bind that comes with macos 10.15.5)? Thank you.

@nojkepop
Copy link

nojkepop commented Jul 6, 2020

I would love to see this updated for the latest Catalina as well.

@gumoz
Copy link

gumoz commented Jan 22, 2021

I used this shit in Big Sur, and is working, because this is just a bind server running locally, and you are pointing this to that bind server, so it should work and be very straightforward.

@nojkepop
Copy link

nojkepop commented Jan 22, 2021

Any tips on getting this working then?

@Ikkyusan1
Copy link

Ikkyusan1 commented Jan 29, 2022

A version for MacOs 11 Big Sur, based on a Debian standard configuration:
https://gist.github.com/Ikkyusan1/4e79e1ac844a2073223c2c4690931e77

@macuserguru
Copy link

macuserguru commented Mar 13, 2022

How work this under Monterey an an M1 Mac?
And his security?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment