{"id":76,"date":"2008-08-13T15:20:43","date_gmt":"2008-08-13T23:20:43","guid":{"rendered":"http:\/\/blog.11h.net\/erich\/76"},"modified":"2008-08-13T15:20:43","modified_gmt":"2008-08-13T23:20:43","slug":"sending-dhcp-ip-based-on-clients-hostname","status":"publish","type":"post","link":"https:\/\/11h.net\/blog\/sending-dhcp-ip-based-on-clients-hostname\/","title":{"rendered":"Sending DHCP IP based on clients hostname"},"content":{"rendered":"<p>I&#8217;m working on a project where I need my DHCP server to send an IP address from a specific DHCP range if the hostname is a certain value otherwise it needs to send a normal IP address range.<\/p>\n<p>I&#8217;m using Internet Systems Consortium DHCP Server V3.0.3 (ISC-DHCP).<\/p>\n<p>To give a specific address range, we first need to detect if the DHCP client is sending the option 12 host-name and if so assign it to a class.<\/p>\n<blockquote><p>class &#8220;FooBar&#8221; { match if (option host-name = &#8220;foobar&#8221;); }<\/p><\/blockquote>\n<p>Once the client has a class associated to it we need to give it an address from a pool that doesn&#8217;t deny it.<\/p>\n<blockquote><p>subnet 192.168.0.0 netmask 255.255.255.0 {<\/p><\/blockquote>\n<p>Other DHCP settings here but make sure that the range is <strong>not<\/strong> specified; it overrides the pool settings.<\/p>\n<blockquote><p>pool {<br \/>\nallow members of &#8220;FooBar&#8221;;<br \/>\nrange 192.168.0.90 192.168.0.99;<br \/>\n}<\/p><\/blockquote>\n<p>Otherwise we want the systems that don&#8217;t specify a hostname to get an address from the normal IP address pool<\/p>\n<blockquote><p>pool {<br \/>\nrange 192.168.0.254 192.168.0.100;<br \/>\n}<\/p><\/blockquote>\n<p>Add more pools if needed<\/p>\n<blockquote><p>} # ending the subnet declaration<\/p><\/blockquote>\n<p>Pretty simple, hu?<\/p>\n<p>UPDATE:<\/p>\n<p>Thanks to a post I read by Bill Stephens of the PepsiCo Business Solutions Group, you can match a hostname using substr.\u00a0 If your DHCP clients are named foobar-xyz you can use substr to match for foobar:<\/p>\n<blockquote><p>class &#8220;FooBar&#8221; {<\/p>\n<p>match if ( substring(option host-name,0,6) = &#8220;foobar&#8221;);<\/p>\n<p>}<\/p><\/blockquote>\n<p>(This would match the first 6 characters of the option 12 host-name)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m working on a project where I need my DHCP server to send an IP address from a specific DHCP range if the hostname is a certain value otherwise it needs to send a normal IP address range.<\/p>\n<p>I&#8217;m using Internet Systems Consortium DHCP Server V3.0.3 (ISC-DHCP).<\/p>\n<p>To give a specific address range, we first need to detect if the DHCP client is sending the option 12 host-name and if so assign it to a class.<\/p>\n<p>class &#8220;FooBar&#8221; { match if (option host-name = &#8220;foobar&#8221;); }<\/p>\n<p>Once the client has a class associated to it we need to give it an address from a pool that doesn&#8217;t deny it.<\/p>\n<p>subnet <a href=\"https:\/\/11h.net\/blog\/sending-dhcp-ip-based-on-clients-hostname\/\">&#8230;<\/p>\n<p>[Continue reading]<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/posts\/76"}],"collection":[{"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/comments?post=76"}],"version-history":[{"count":0,"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/posts\/76\/revisions"}],"wp:attachment":[{"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/media?parent=76"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/categories?post=76"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/11h.net\/blog\/wp-json\/wp\/v2\/tags?post=76"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}