{"id":30861,"date":"2013-02-27T10:09:23","date_gmt":"2013-02-27T09:09:23","guid":{"rendered":"https:\/\/inlab.fib.upc.edu\/news\/advanced-dhcp-functionalities\/2013\/"},"modified":"2013-02-27T10:09:23","modified_gmt":"2013-02-27T09:09:23","slug":"advanced-dhcp-functionalities","status":"publish","type":"post","link":"https:\/\/inlab.fib.upc.edu\/en\/blog\/advanced-dhcp-functionalities","title":{"rendered":"Advanced DHCP functionalities"},"content":{"rendered":"<p>DHCP is a powerful tool to manage and configure our workstations. In this article, we will see some functionalities that go beyond the usual uses.<\/p>\n<p>All know the DHCP (Dynamic Host Configuration Protocol) service as the protocol that allows us to automatically configure the IP configuration of our equipment, forgetting about having to do it manually.<\/p>\n<p><!--more--><\/p>\n<p>All know the DHCP (Dynamic Host Configuration Protocol) service as the protocol that allows us to automatically configure the IP configuration of our equipment, forgetting about having to do it manually. This is especially useful nowadays, when we connect our laptops and smartphones everywhere. Can you imagine having to hand over the IP address of your iPhone?<\/p>\n<p>The basic functionality of DHCP is to dynamically assign an IP, a mask and a gateway to our equipment. What not everyone knows is that DHCP has a whole series of extensions that allow us to assign a multitude of interesting parameters at boot time.<\/p>\n<p>If, moreover, we have an advanced server, we can make our DHCP a powerful tool to manage our networks.<\/p>\n<p>At inLab FIB, we have been using the ISC (Internet Systems Consortium) DHCP server for a long time. This server is competent and stable, and has, moreover, a mini-programming language.<\/p>\n<p>We can use options for special parameters, such as:<\/p>\n<ul>\n<li>A boot fitxer (<strong>option filename<\/strong> \u201cBStrap\/X86pc\/BStrap.0\u201d;)<\/li>\n<li>The remote printer server (<strong>option lpr-servers<\/strong> <em> ip-address<\/em>)<\/li>\n<li>The time-server (<strong>option ntp-servers<\/strong> <em> ip-address<\/em>)<\/li>\n<li>The TFTP server (<strong>option <\/strong> <strong>next-server <\/strong> <em> ip-address<\/em>)<\/li>\n<\/ul>\n<p>You can consult the complete list of predefined options in <a href=\"https:\/\/tools.ietf.org\/html\/rfc2132\" target=\"_blank\" rel=\"noopener\"> RFC 2132<\/a>.<\/p>\n<p>In addition to the predefined options, we can create our own options, and even complex data structures, to store and pass on our own information.<\/p>\n<pre style=\"color: rgb(8, 41, 138);\">\n<em>option inLab-priv-sala  code 1 = text;\noption inLab-priv-hw    code 3 = text;\noption inLab-priv-es-pc code 2 = {boolean, integer 32, text };\noption inLab-priv-rutas code 4 = array of {ip-address,\n                                 ip-address,ip-address,integer 8};<\/em><\/pre>\n<p>Options 1 and 2 contain a single string. The 3 contained a tuple formed by a boolean, a single name and a string. The fourth option, defines an array of structures formed by 3 IP addresses and &nbsp;a single name.<\/p>\n<p>Thus, for example, we could tell a PC, from the DHCP, which room it is in or a description of its machine.<\/p>\n<pre style=\"color: rgb(8, 41, 138);\">\n<em>host  venus {<\/em>\n<em>fixed-address 10.10.43.196;\nhardware ethernet 24:BE:05:23:5E:F2;\noption netbios-name-servers 147.83.41.111;\noption domain-name \"fib.upc.es\";\noption domain-name-servers 147.83.41.104, 147.83.41.36;\noption inLab-priv-es-pc false 2011 \"portatil de prestec\";\noption inLab-priv-sala \"Campus Nord.B6.S104\";\noption inLab-priv-hw \"ASUS Eee PC 900\";\noption inLab-priv-rutas 147.83.200.0 255.255.255.0 10.10.43.2 8,\n                         88.20.34.0 255.255.0.0 10.10.43.45 8;<\/em>\n<em>}<\/em><\/pre>\n<p>Another interesting DHCP option is the \u201c<em>Vendor Space<\/em>\u201d. Did you know that the DHCP request includes a \u201c<em>Vendor Identifier<\/em>\u201d field that identifies the type of client? For example, PCs that boot from the network card have the PXE client as an identifier. The Windows client identifies itself as \u201cMSFT\u201d. Furthermore, Windows 98 was identified as \u201cMSFT 98\u201d, and Windows from W2K onwards as \u201cMSFT 5.0\u201d. Thus, manufacturers have been defining special fields and structures for their clients, such as, for example, the firmware version of the equipment or fields to identify the TCP\/IP ports of some protocols.<\/p>\n<p>Here you can see a couple of examples of predefined structures from some manufacturers.<\/p>\n<p>Special fields of a Microsoft client:<\/p>\n<pre style=\"color: rgb(8, 41, 138);\">\n<em>option space Microsoft;\nvendor-option-space Microsoft;\noption Microsoft.disable-netbios-over-tcpip     code 1   = unsigned integer 32;\noption Microsoft.release-dhcp-lease-on-shutdown code 2   = unsigned integer 8;\noption Microsoft.default-router-metric-base     code 3   = unsigned integer 8;\noption Microsoft.proxy-autodiscovery            code 252 = string<\/em><\/pre>\n<p>Special fields of a PXE client:<\/p>\n<pre style=\"color: rgb(8, 41, 138);\">\n<em>option space PXE;<\/em>\n<em>option PXE.mtftp-ip             code 1   = ip-address;\noption PXE.mtftp-cport          code 2   = unsigned integer 16;\noption PXE.mtftp-sport          code 3   = unsigned integer 16;\noption PXE.mtftp-tmout          code 4   = unsigned integer 8;\noption PXE.mtftp-delay          code 5   = unsigned integer 8;\noption PXE.discovery-control    code 6   = unsigned integer 8;\noption PXE.discover-maddr       code 7   = ip-address;\noption PXE.rembo-servers        code 8   = { unsigned integer 16, \n  unsigned integer 8, array of ip-address};\noption PXE.boot-server-menu     code 9   = { unsigned integer 16, \n  unsigned integer 8, string};\noption PXE.menu-prompt          code 10  = { unsigned integer 16, \n  unsigned integer 8 };\noption PXE.vendor-specific-info code 43  = string;\noption PXE.class-identifier     code 60  = string;\noption PXE.pxe-server-name      code 66  = string;\noption PXE.filename             code 67  = string;\noption PXE.pxe-ip-address       code 150 = string;<\/em><\/pre>\n<p>Thanks to these camps, and the power of the DHCP server of the ISC, we can do things like:<\/p>\n<pre style=\"color: rgb(8, 41, 138);\">\n<em>class \"PXE\" {<\/em>\n<em> match if substring(option vendor-class-identifier,0,9) = \"PXEClient\";\n vendor-option-space PXE;<\/em>\n<em>}<\/em>\n\n<em>class \"Microsoft\" {<\/em>\n<em> match if substring(option vendor-class-identifier,0,4) = \"MSFT\";\n option vendor-class-identifier = \"Microsoft\";\n vendor-option-space Microsoft;<\/em>\n<em>}<\/em><\/pre>\n<p>These definitions assign us a <em> vendor-option-space<\/em>, i.e., a structure and a \u201c<em>vendor-class-identifier<\/em>\u201d variable, a homogeneous description of our <em>vendor<\/em>. Now, we can assign special values based on these options, for example:<\/p>\n<pre style=\"color: rgb(8, 41, 138);\">\n<em>host astro {<\/em>\n<em> fixed-address 147.83.88.22;\n hardware ethernet 6C:62:6D:81:22:32;\n option PXE.discovery-control 11;\n option PXE.rembo-servers 43690 01 147.83.41.200;\n option Microsoft.rembo-servers 2231 01 147.83.58.34;\n next-server 147.83.41.200;<\/em>\n<em>}<\/em><\/pre>\n<p>Imagine that you want your computers to have different DNS servers depending on the operating system that we start at every moment. How can we do it automatically? Using the information passed by the DHCP client:<\/p>\n<pre style=\"color: rgb(8, 41, 138);\">\n<em>host astro {<\/em>\n\n<em>fixed-address 147.83.58.58;\nhardware ethernet 6C:62:6D:81:22:32;\nif (vendor-class-identifier = \"Microsoft\") {\n         option domain-name-servers 8.8.8.8 ;\n} else if (vendor-class-identifier = \"PXE\") {\n        option domain-name-servers 88.34.23.7 ;\n} else {\n        option domain-name-servers 4.4.4.4 ;\n}<\/em>\n<em>}<\/em><\/pre>\n<p>In this example, we assign the DNS based on the client making the DHCP request. At the initial PXE startup, we will assign the server 88.34.23.7, and then, to Windows, we will assign as DNS the 8.8.8.8. In other cases, for example, for a Linux client, we would assign 4.4.4.4 as the server.<\/p>\n<h4>What the manual does not explain:<\/h4>\n<p>Some of the functionality described is provided by the ISC server, on the DHCP server side, but many of these improvements can only be utilized if the DHCP client is able to interpret them and pass them on to the operating system. The ISC software includes a DHCP client capable of providing all these functionalities. It is highly recommended to use this client instead of the simple client included in the most common Linux distributions. Unfortunately, the Microsoft client is only capable of interpreting a few options implemented on their DHCP server.<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>DHCP is a powerful tool to manage and configure our workstations. In this article, we will see some functionalities that go beyond the usual uses. All know the DHCP (Dynamic Host Configuration Protocol) service as the protocol that allows us to automatically configure the IP configuration of our equipment, forgetting about having to do it [&hellip;]<\/p>\n","protected":false},"author":594,"featured_media":1236,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[572],"tags":[],"experteses":[],"class_list":["post-30861","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blog"],"acf":[],"_links":{"self":[{"href":"https:\/\/inlab.fib.upc.edu\/en\/wp-json\/wp\/v2\/posts\/30861","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/inlab.fib.upc.edu\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/inlab.fib.upc.edu\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/inlab.fib.upc.edu\/en\/wp-json\/wp\/v2\/users\/594"}],"replies":[{"embeddable":true,"href":"https:\/\/inlab.fib.upc.edu\/en\/wp-json\/wp\/v2\/comments?post=30861"}],"version-history":[{"count":0,"href":"https:\/\/inlab.fib.upc.edu\/en\/wp-json\/wp\/v2\/posts\/30861\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/inlab.fib.upc.edu\/en\/wp-json\/wp\/v2\/media\/1236"}],"wp:attachment":[{"href":"https:\/\/inlab.fib.upc.edu\/en\/wp-json\/wp\/v2\/media?parent=30861"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/inlab.fib.upc.edu\/en\/wp-json\/wp\/v2\/categories?post=30861"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/inlab.fib.upc.edu\/en\/wp-json\/wp\/v2\/tags?post=30861"},{"taxonomy":"experteses","embeddable":true,"href":"https:\/\/inlab.fib.upc.edu\/en\/wp-json\/wp\/v2\/experteses?post=30861"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}