{"id":102,"date":"2012-04-20T11:25:59","date_gmt":"2012-04-19T22:25:59","guid":{"rendered":"http:\/\/www.templesoft.co.nz\/blog\/?p=102"},"modified":"2026-04-08T08:19:29","modified_gmt":"2026-04-07T20:19:29","slug":"adding-support-for-active-directory-to-bind9-dns","status":"publish","type":"post","link":"https:\/\/templesoft.co.nz\/journal\/?p=102","title":{"rendered":"Adding support for Active Directory to BIND9 DNS."},"content":{"rendered":"<h2>Taking DNS a step further<\/h2>\n<p style=\"text-align: justify;\">Back in September 2010 I posted an article on creating your own DNS server (using BIND9) and linked to DHCP. There was probably one element of that setup that was missing &#8211; Microsoft&#8217;s Active Directory.<\/p>\n<p style=\"text-align: justify;\">Active Directory uses DNS as its domain controller location mechanism and leverages the namespace design of DNS in the design of Active Directory domain names. As a result, DNS is positioned within the discoverability and logical structure components of Active Directory technology components. If you&#8217;re running your own AD server, it&#8217;s a fair bet that the install wanted you to install DNS as well (you&#8217;re actively prompted by the 2008 R2 install).<\/p>\n<p style=\"text-align: justify;\">So what do you do if you don&#8217;t want a proliferation of DNS servers across your network &#8211; or (like me) you prefer to farm out processes like DNS and DHCP to &#8220;helper&#8221; servers without having to blow your budget on Microsoft licences?<\/p>\n<p style=\"text-align: justify;\">Simple: Add the AD DNS functionality into your BIND9 server by utilising the SRV record type.<\/p>\n<p style=\"text-align: justify;\">A Service record (<a href=\"http:\/\/en.wikipedia.org\/wiki\/SRV_record\" target=\"_blank\">SRV record<\/a>) is a specification of data in the Domain Name System defining the location, i.e. the hostname and port number, of servers for specified services. We leverage off this to provide the relevant answer to a client or servers quering for AD service, protocol and location information.<\/p>\n<p style=\"text-align: justify;\">For more information on how DNS Support for Active Directory works, you can read this <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/cc759550(v=WS.10).aspx\" target=\"_blank\">Microsoft Technet article<\/a>.<\/p>\n<h2 style=\"text-align: justify;\">An alias by any other name&#8230;<\/h2>\n<h3 style=\"text-align: justify;\">Finding the DNS Alias for your AD server<\/h3>\n<p style=\"text-align: justify;\">Some of the <strong>SRV<\/strong> records will refer to this value so it&#8217;s a good opportunity to note it down. I&#8217;m still using Windows Server 2003 R2 in my environment, so these instructions my vary dependant on build and version.<\/p>\n<p style=\"text-align: justify;\">From the &#8220;<strong>Administrative Tools<\/strong>&#8220;, launch &#8220;<strong>Active Directory Sites and Services<\/strong>&#8220;. Once the MMC (Microsoft Management Console) has started up, expand the following items:<\/p>\n<pre>\u2192 Sites\r\n    \u2192 Default-First-Site-Name\r\n        \u2192 Servers\r\n            \u2192 <strong><em>[server name]<\/em><\/strong> <span style=\"color: #c0c0c0;\">(this will be the name of your AD server)<\/span>\r\n                \u2192 NTDS Settings<\/pre>\n<p style=\"text-align: justify;\">Right click on &#8220;<strong>NTDS Settings<\/strong>&#8221; and select &#8220;<strong>Properties<\/strong>&#8220;. Under the &#8220;<strong>General<\/strong>&#8221; tab look for the value next to <em>DNS alias<\/em>. The alpha-numeric <strong>GUID<\/strong> that preceeds the <strong><em>._msdcs.[<\/em><\/strong><span style=\"color: #c0c0c0;\"><em>dnsDomainName<\/em><\/span><strong><em>]<\/em><\/strong> is the value you need to note down.<\/p>\n<h3 style=\"text-align: justify;\">Freeze the zone record<\/h3>\n<p style=\"text-align: justify;\">Next we&#8217;ll need to freeze the zone file of our primary name server so we can make changes to it.<\/p>\n<pre style=\"text-align: justify;\">cd \/var\/lib\/bind\r\nsudo rndc freeze <span style=\"color: #ff0000;\"><em><strong>zone<\/strong><\/em><\/span><\/pre>\n<p style=\"text-align: justify;\">&#8230; where <span style=\"color: #ff0000;\"><em><strong>zone<\/strong> <\/em><\/span>is the name of the DNS zone you&#8217;re editing. This will disable dynamic updates to the zone while you&#8217;re editing it. Now we add the records to the zone file.<\/p>\n<h3 style=\"text-align: justify;\">Adding the relevent SRV records<\/h3>\n<p style=\"text-align: justify;\">For the purposes of this HOWTO we&#8217;ll assume the following values:<\/p>\n<ul>\n<li>DNS Domain: <strong>example.com<\/strong><\/li>\n<li>AD Host: <strong>adserver<\/strong><\/li>\n<li>GUID: <strong>dc41138f-f32e-22ff-9e10-9893dc599536<\/strong><\/li>\n<\/ul>\n<blockquote>\n<p style=\"text-align: justify;\"><span style=\"color: #ff6600;\"><strong>Remember<\/strong>:<\/span><\/p>\n<p style=\"text-align: justify;\"><span style=\"color: #ff6600;\">Take note to be carefull to include the trailing &#8220;<strong>.<\/strong>&#8221; on the FQDN when adding\/editing records in the zone file!<\/span><\/p>\n<\/blockquote>\n<p style=\"text-align: justify;\">First add an <strong>A<\/strong> record for the AD server&#8217;s hostname, as well a <strong>CNAME<\/strong> for the AD server&#8217;s <strong>GUID<\/strong> &#8211; this will be used for RPC lookups&#8230;<\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #339966;\">$ORIGIN <strong>example.com.<\/strong><\/span>\r\n<span style=\"color: #339966;\"><strong>adserver<\/strong> A 192.168.1.1<\/span>\r\n<span style=\"color: #339966;\">$ORIGIN _msdcs.<strong>example.com.<\/strong><\/span>\r\n<span style=\"color: #339966;\"><strong>dc41138f-f32e-22ff-9e10-9893dc599536<\/strong> CNAME <strong>adserver.example.com.<\/strong><\/span><\/pre>\n<blockquote><p><span style=\"color: #ff6600;\"><strong>Note<\/strong>:<\/span><\/p>\n<p><span style=\"color: #ff6600;\"><strong> _msdcs<\/strong> is the Microsoft-specific subdomain that enables the location of domain controllers that have specific roles in the Active Directory domain or forest.<\/span><\/p><\/blockquote>\n<p style=\"text-align: justify;\">To facilitate locating Windows Server 2003+ based domain controllers, in addition to the standard <em>_Service._Protocol.DnsDomainName<\/em> format, the Net Logon service registers <strong>SRV<\/strong> records that identify the well-known server-type pseudonyms &#8220;<strong>dc<\/strong>&#8221; (domain controller), &#8220;<strong>gc<\/strong>&#8221; (global catalog), &#8220;<strong>pdc<\/strong>&#8221; (primary domain controller), and &#8220;<strong>domains<\/strong>&#8221; (globally unique identifier, or <strong>GUID<\/strong>) as prefixes in the <strong>_msdcs<\/strong> subdomain.<\/p>\n<p style=\"text-align: justify;\">To accommodate locating domain controllers by server type or by <strong>GUID<\/strong> (abbreviated &#8220;<strong>dctype<\/strong>&#8220;), Windows Server 2003 and later based domain controllers register <strong>SRV<\/strong> records in the following form:<\/p>\n<pre style=\"text-align: justify;\"><span style=\"color: #339966;\">_Service._Protocol.DcType.<strong>_msdcs<\/strong>.DnsDomainName<\/span><\/pre>\n<p style=\"text-align: justify;\">For a complete list of definitions of the names associated with registered SRV records, refer to the &#8220;SRV Records Registered by Net Logon&#8221; in this <a href=\"http:\/\/technet.microsoft.com\/en-us\/library\/cc759550(v=WS.10).aspx\" target=\"_blank\">Technet article<\/a>.<\/p>\n<p style=\"text-align: justify;\">Rather than showing the entries bit-by-bit, with an explaination of each, I&#8217;ve opted to display all of them with the relevant values that you need to change to suit your organisation (<span style=\"color: #ff00ff;\"><strong>highlighted<\/strong><\/span>). If you want to know what each one does, refer to the article above.<\/p>\n<pre><span style=\"color: #339966;\">$ORIGIN _tcp.dc._msdcs.<span style=\"color: #ff00ff;\"><strong>example.com.<\/strong><\/span>\r\n_kerberos               SRV     0 0 88 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_ldap                   SRV     0 0 389 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n\r\n$ORIGIN _udp.<span style=\"color: #ff00ff;\"><strong>example.com.<\/strong><\/span>\r\n_kerberos               SRV     0 0 88 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_kpasswd                SRV     0 0 464 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n\r\n$ORIGIN _tcp.Default-First-Site-Name._sites.<span style=\"color: #ff00ff;\"><strong>example.com.<\/strong><\/span>\r\n_kerberos               SRV     0 0 88 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_ldap                   SRV     0 0 389 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_gc                     SRV     0 0 3268 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n\r\n$ORIGIN _tcp.Default-First-Site-Name._sites.dc._msdcs.<span style=\"color: #ff00ff;\"><strong>example.com.<\/strong><\/span>\r\n_kerberos               SRV     0 0 88 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_ldap                   SRV     0 0 389 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n\r\n$ORIGIN _tcp.Default-First-Site-Name._sites.<strong><span style=\"color: #ff00ff;\">adserver.example.com.<\/span><\/strong>\r\n_ldap                   SRV     0 0 389 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_gc                     SRV     0 0 3268 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n\r\n$ORIGIN _tcp.<span style=\"color: #ff00ff;\"><strong>example.com.<\/strong><\/span>\r\n_kerberos               SRV     0 0 88 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_ldap                   SRV     0 0 389 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_kpasswd                SRV     0 0 464 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_gc                     SRV     0 0 3268 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_ldap._tcp.gc._msdcs    SRV     0 0 3268 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_ldap._tcp.pdc._msdcs   SRV     0 0 389 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_ldap._tcp.<span style=\"color: #ff00ff;\"><strong>adserver.example.com<\/strong><\/span>     SRV     0 0 389 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_ldap._tcp.Default-First-Site-Name._sites.gc._msdcs     SRV     0 0 3268 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_ldap._tcp.dc41138f-f32e-22ff-9e10-9893dc599536.domains._msdcs  SRV     0 0 389 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span>\r\n_ldap._tcp.Default-First-Site-Name._sites.<span style=\"color: #ff00ff;\"><strong>adserver.example.com<\/strong><\/span>      SRV     0 0 389 <span style=\"color: #ff00ff;\"><strong>adserver.example.com.<\/strong><\/span><\/span><\/pre>\n<p style=\"text-align: justify;\">Once you&#8217;ve added the records to the zone file, you can unfreeze it, then restart the relevent services&#8230;<\/p>\n<pre style=\"text-align: justify;\">sudo rndc unfreeze zone\r\nsudo \/etc\/init.d\/bind9 restart\r\nsudo \/etc\/init.d\/dhcp3-server restart<\/pre>\n<h2 style=\"text-align: justify;\">Testing the changes<\/h2>\n<p style=\"text-align: justify;\"><strong>SRV<\/strong> records may be queried with standard network administration tools, such as the <strong>DIG<\/strong> or <strong>nslookup<\/strong>.<\/p>\n<pre style=\"text-align: justify;\">dig SRV _ldap._tcp.dc._msdcs.<span style=\"color: #ff0000;\"><em><strong>Domain_Name<\/strong><\/em><\/span>\r\nhost -t SRV _ldap._tcp.dc._msdcs.<span style=\"color: #ff0000;\"><em><strong>Domain_Name<\/strong><\/em><\/span>\r\nnslookup -type=SRV _ldap._tcp.dc._msdcs.<span style=\"color: #ff0000;\"><em><strong>Domain_Name<\/strong><\/em><\/span>\r\nnslookup\r\n\r\n<span style=\"color: #0000ff;\">&gt; <strong>set type=all<\/strong><\/span>\r\n<span style=\"color: #0000ff;\">&gt; <strong>_ldap._tcp.dc._msdcs.<span style=\"color: #ff0000;\"><em>Domain_Name<\/em><\/span><\/strong><\/span><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Taking DNS a step further Back in September 2010 I posted an article on creating your own DNS server (using BIND9) and linked to DHCP. There was probably one element of that setup that was missing &#8211; Microsoft&#8217;s Active Directory. Active Directory uses DNS as its domain controller location mechanism and leverages the namespace design&#8230;  <a class=\"excerpt-read-more\" href=\"https:\/\/templesoft.co.nz\/journal\/?p=102\" title=\"Read Adding support for Active Directory to BIND9 DNS.\">Read more &raquo;<\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[91,96,94,90,92,100,99,98,93,97,89,95],"class_list":["post-102","post","type-post","status-publish","format-standard","hentry","category-technical-resource","tag-_msdcs","tag-active-directory","tag-bind9","tag-cname","tag-dig","tag-domain","tag-guid","tag-ntds","tag-rndc","tag-server","tag-srv","tag-windows"],"_links":{"self":[{"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=\/wp\/v2\/posts\/102","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=102"}],"version-history":[{"count":6,"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions"}],"predecessor-version":[{"id":171,"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=\/wp\/v2\/posts\/102\/revisions\/171"}],"wp:attachment":[{"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=102"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=102"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/templesoft.co.nz\/journal\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=102"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}