This post is a follow-up to Dynamic DNS
When last I left you, we had basic updateable DNS running and could update it from OS X. I’ve been a bit busy since then, but thanks to some prodding from @Loredo, I got back in and started looking at. What follows is the exciting story of how I got things up and running — by the end of this post, you’ll have access to a working copy of dnsextd for linux, and a client application that updates SRV and IP (A/AAAA) leases. Woo.
dnsextd
If you remember from Part 1, we’d gotten DNS UPDATE running on a Linux machine, but didn’t yet have support for Apple’s DNS extensions which make wide-area Bonjour so cool, because dnsextd is a pain in the ass and doesn’t really work except on Linux. Well, now it does.
So, we’ll be basing our adventure on mDNSResponder-215, which is the latest copy. I initially wrote against -214, but don’t worry, my code also works against -215 (and trunk, for that matter). You have a couple of options here. If you’d like to check out my actual code that I’m working on, I have a git tree that I work in. It’s based off of mDNSResponder-214 because it’s a pita to switch over to -215 or -trunk and there are no (0) changes to mDNSPosix or dnsextd.c in -215. You should be able to clone my get repo with the following code:
git clone http://files.roguelazer.com/projects/mDNSResponder-214.git mDNSResponder-214
cd mDNSResponder-214
Alternatively, if you would prefer to work off of -215:
svn co http://svn.macosforge.org/repository/mDNSResponder/tags/mDNSResponder-215
cd mDNSResponder-215
wget http://files.roguelazer.com/projects/dnsextd_posix-215.patch
patch -p1 < dnsextd_posix-215.patch
Some notes about this code: Apple seems to have tried pretty hard to “do the right thing” on a lot of platforms. To that end, they wrote a big network abstraction library. Except they only implemented it for OS X and Windows. So I implemented parts of it for Posix. I did not implement the stuff I didn’t need, including the callback system for TCP events, or any TLS support. I don’t think anything in mDNSResponder other than dnsextd will work with this code. But who cares about that stuff? If you want a real mDNS responder on Linux, I suggest looking at Avahi.
Also, the usual disclaimer applies: I am not responsible if using this code causes your computer to explode or God to kill a kitten. Liek, for reals. I’m going to see what I can do about getting this code merged in, so maybe there’ll be more good stuff in the future.
Oh, also, this probably won’t do the right thing if your zone is private. But the existing code also wouldn’t, so *shrug*.
Once you’ve downloaded the code, and cd‘d into the root directory, the following sequence of code will build dnsextd
cd mDNSPosix make os=linux dnsextd sudo cp ../mDNSShared/dnsextd.conf /etc/dnsextd.conf
Now it’s configuration time. First, you’ll need to edit the dnsextd.conf file that you just installed (/etc/dnsextd.conf). Change the zone name to be your dynamic zone, but DO NOT CHANGE ANYTHING ELSE. Most of the configuration parsing is extremely brittle and has a tendency to mysteriously die if you specify an option slightly differently than it expects. In fact, just uncommenting the example code will make things break. Woo.
Also, I didn’t yet fix the bug which causes dnsextd to segfault if the configuration file isn’t found. So, uh, make sure it’s in the right place.
You’ll also have to edit your DNS configuration. I’m not going to explain BIND to you, because you really do need to know how BIND9 works before you can even have a hope of getting this to work. In short, you just need to configure BIND to listen on port 5030 and accept updates from
127.0.0.1
(and
::1
if you’re doing the ipv6 thing). dnsext really wants to listen on port 53, so I would advise against trying to change that.
Once you’ve restarted BIND, you should be able to launch dnsextd with the following command (still in the
mDNSPosix
directory):
sudo ./build/prod/dnsextd -v -d
A small security note: dnsextd needs to open port 53 to do listening, but doesn’t seem to be smart enough to drop privs after that, so it needs to be run as root the whole time, which is a giant security hole. Anybody who feels like writing up some cross-platform permission-dropping code should send me a message.
Congratulations, you are now running dnsextd on Linux and can support long-lived queries and UPDATE-LEASE. You can’t support DNS-over-TLS, but why would you want to?
wamupd
The other thing that I worked on is what I’m tentatively calling wamupd. It will eventually be a daemon for updating wide-area mDNS information. Currently, it supports loading Avahi
.service
files and setting SRV/PTR/TXT records for them, as well as setting system A and AAAA records. I’d eventually like to support listening on Avahi’s D-BUS interface so that this daemon could act like a wide-area Avahi and publish all services, but I haven’t gotten that far. I also have to make the daemon automatically renew leases (right now, I have it in a cron job to run every few minutes and re-up my leases).
wamupd uses Dnsruby (rdoc), which is a really great DNS library for Ruby. Unfortunately, while it’s great, it’s not perfect, so I had to implement some patches to get it working properly. They let Dnsruby support OPT correctly and not die when receiving a non-signed response to a signed request (because dnsextd doesn’t sign lease confirmations). Make sure that you apply them to your Dnsruby before trying to run wamupd.
wamupd is a pretty big hack, mostly done because the Avahi codebase is nasty and I didn’t want to work on it. With any luck, somebody will finish the long-promised wide-area Bonjour update for Avahi, and it won’t be necessary. Yup.
For more detailed information, check out the wamupd Code page on this site.







hey great howto, will look into it, just one question to your comment
….If you want a real mDNS responder on Linux, I suggest looking at Avahi……..
Avahi, does not support WAB and never did….
cheers from germany
First of all: thanks for bringing the long awaited patch!
(in part I) you mentioned you made /etc/bind bind writable
Try pointing (from your zone file in /etc/bind) to a db file in /var/lib/bind/ (which bind will happily write to)
[...] you need more setup help, Dynamic DNS: Part Two contains all the gory details. If you decide to use mDNSResponder-215 and want to apply the [...]
FYI, dnsruby-1.44 has now been released, which should contain these changes.
Hi, first thank for your work
I tried to apply the patch but I have a compilation erreur: mDNSUNP.c: In function ‘recvfrom_flags’:
mDNSUNP.c.574:4: warning: dereferencing type-punned pointer will break strict-aliasing rules
make *** [objects/prod/dnsextd_parser.y.o] erreur 127.
I did exactly the commandes above:
svn co http://svn.macosforge.org/repository/mDNSResponder/tags/mDNSResponder-215
cd mDNSResponder-215
wget http://files.roguelazer.com/projects/dnsextd_posix-215.patch
patch -p1 < dnsextd_posix-215.patch
and
cd mDNSPosix
make os=linux dnsextd
Thank for your help.
Bro tip: don’t forget to install bison and flex on your fresh isntalled machine…
Hi.
Thanks for your guide.
I’m having a problem that I was hoping someone can help me with. I am trying to setup dnsextd on Ubuntu 12.04 Server.
After compiling and setting BIND to listen on 5030, i get the n following error when trying to run dnsextd -vd
ConnectToServer – Success
UpdateSRV: ConnectToServer – failed
main: SetUpdateSRV – Success
in the /var/log/syslog i get the following output if it helps
dnsextd: dnsextd starting
dnsextd: main: setrlimit – Operation not permitted
dnsextd: Using default file descriptor resource limit
any help would be greatly appreciated. Let me know if you need any additional information.
Is bind configured to allow updates from 127.0.0.1 and ::1 without a key?
Hi. I should have mentioned that I tried the latest version from Darwin CVS. I used the mDNSResponder-214 on this site and dnsextd started up just fine.
My next problem however is that I am unable to dynamically add dns records using the nsupdate command. I get a “update failed: REFUSED” error.
my bind is configured to allow-update from 127.0.0.1. I do not have ::1 as i’m not using ipv6 and it is currently configured without encryption key.
Just for kicks, I’ve also tried to allow-update { any; }; but still get the REFUSED option.
I’ve tried this on two setups. On one setup, nothing information comes out from /var/log/syslog. In my other setup however, i get something along the lines of “dnsextd: Attempting to use unimplemented update”… something along those lines.
Oh just fyi. If i remove dnsextd and revert back to my previous named configuration, i am able to do nsupdate just fine.
Hey all.
I narrowed down my problem. I’m getting the output error in dnsextd when attempting to dyamically add a record with nsupdate
“Rejecting Update Request with 1 additions but no lease”.
Looking at the code, it seems like a lease time is not defined when doing dynamic updating. Have you run into this issue before? Is there additional settings for bind/dnsextd that I need to set some default lease time? Or is there another parameter I need to specify when doing the dynamic updating?
I’ll continue to investigate but if anyone has come across this before, let me know.
thanks!