{"id":780,"date":"2024-12-04T03:56:48","date_gmt":"2024-12-04T00:56:48","guid":{"rendered":"https:\/\/itgen.itbumper.com\/?page_id=780"},"modified":"2024-12-05T03:27:16","modified_gmt":"2024-12-05T00:27:16","slug":"0024_cisco-dhcp","status":"publish","type":"page","link":"https:\/\/itgen.itbumper.com\/?page_id=780","title":{"rendered":"0024_Cisco: DHCP"},"content":{"rendered":"<p style=\"text-align: justify;\" data-tadv-p=\"keep\"><strong>DHCP (Dynamic Host Configuration Protocol)<\/strong> automatically assigns IP addresses and network parameters to client devices. On Cisco devices, a switch or router can be configured as a DHCP server or a DHCP relay to forward requests to a remote server.<\/p>\n<h4><strong>Main Functions:<\/strong><\/h4>\n<ul>\n<li><strong>DHCP Server<\/strong> \u2014 Assigns IP addresses to clients.<\/li>\n<li><strong>DHCP Relay (ip helper-address)<\/strong> \u2014 Forwards DHCP requests from different subnets to a centralized DHCP server.<\/li>\n<\/ul>\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n#DHCP\n#DHCP servers use UDP 67 port\n#DHCP clients use UDP 68 port\n#Magic cookie?!\n\n\t\t| --&gt; DHCP Discover (I need IP addr) --&gt;\t\t\t\t\t\t|\n\t\t|\t  broadcast request Src:68 Dst:67\t\t\t\t\t\t\t|\t\n\t\t| &lt;--DHCP Offer (how about this IP addr? &lt;--\t\t\t\t\t|\nDHCP\t|\t\t  \t \t(Src:67, Dst:68)\t\t\t\t\t\t\t\t|\tDHCP\nCLIENT\t| --&gt;DHCP Request (I want to use the IP addr you offered) --&gt;\t|\tSERVER\n\t\t|\t\t\t\t(Src:68, Dst:67)\t\t\t\t\t\t\t\t|\n\t\t| \t&lt;--DHCP Ack (Okay, you may use it), Src:67, Dst:68)&lt;--\t\t|\n\t\t|\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t|\n#Discover\tCLIENT-SERVER\tBroadcast\n#Offer\t\tSERVER-CLIENT\tBroadcast or Unicast\n#Request\tCLIENT-SERVER\tBroadcast\n#Ack\t\tSERVER-CLIENT\tBroadcast or Unicast\n#Release\tCLIENT-SERVER\tUnicast\n\n\n#DHCP Relay on Cisco routers\n#DHCP relay agent\n#DHCP server\n#DHCP client\t\t\n\t\n\t\n#DHCP SERVER\n\t\tip dhcp excluded-address 192.168.1.1 192.168.1.10\t#to specify a range of IP addresses that won`t be given to DHCP clients\n\t\tip dhcp pool &lt;pool-name&gt;\n\t\t\tdns-server\t&lt;IP address&gt;\n\t\t\tdomain-name &lt;domain-name&gt;\n\t\t\tdefault-router &lt;GW IP address&gt;\n\t\t\tlease {&lt;days hourse mitutes&gt; | infinite}\n\tshow ip dhcp binding\n\t\n#DHCP RELAY AGENT\n#Choose the interface that the clients connected\n\t\tinterface &lt;clients connected interface&gt;\n\t\t\tip helper-address &lt;DHCP Server IP address&gt;\n\tshow ip interface &lt;clients connected interface&gt;\t#there is info about helper\n\t\n\n#DHCP CLIENT CONFIGURATION\n\tinterface &lt;interface&gt;\n\t\tip address dhcp\n\t\n\t\n\t\n#Make IP address &quot;STAIC&quot; by DHCP\n\t\tip dhcp pool &lt;DHCP pool name&gt;\t\t\t\t\t#for each entry you have to create a new DHCP pool\n\t\t\thost &lt;IP address mask&gt;\n\t\t\tclient-identifier &lt;01+MAC&gt; \t\t\t\t\t# If MAC=0026.18d5.b5d7, then write 0100.2618.d5b5.d7\n\t\t\tdefault-router &lt;IP default gateway&gt; \n\t\t\tdomain-name &lt;domain name&gt;\n\t\t\tdns-server &lt;dns server 1  dns server 2&gt; \n\t\t\tlease {&lt;days hourse mitutes&gt; | infinite}\n\t\t\n\t\t\n#Client-identifier format in DHCP:\n#01 \u2014 Client Hardware Type (Ethernet MAC) \n#03 - Token Ring\n#06 - IEEE 802 Networks\n\n#Additional options:\n\t\t\toption 42 ip 192.168.1.100 192.168.1.101\t#NTP servers\n\t\t\toption 66 ip 192.168.1.200\t\t\t\t\t#TFTP IP address\n\t\t\toption 121 hex 18C0A86400C0A80101\t\t\t#&lt;prefix length&gt;+&lt;network&gt;+&lt;gateway&gt; each field must be hex format\n\n#Example 1: Add the static route for the network 192.168.100.0\/24 by the gateway 192.168.1.1\n#Prefix length = 24, in hex =18\n#Network = 192.168.100.0\n#\tIn decimal: 11000000.10101000.01100100.00000000\n#\tFirst 24 bit (192.168.100) in hex = C0A864 \n\n#Gateway = 192.168.1.1\n#\tIn decimal: 11000000.10101000.00000001.00000001\n#\tIn hex = C0A80101\n#The total value is 18C0A86400C0A80101\n\n#Example 2: Add the static route for the network 10.1.2.0\/23 by the gateway 192.168.1.254\n#Prefix length = 23, in hex 17\n#Network = 10.1.2.0: 10.1.2 --&gt;0A0102\n#Gateway = 192.168.1.254 --&gt;C0A801FE\n\n#How to count\n\n#hex\n# 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A,  B,  C,  D,  E,  F\n# 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15\n#Example 1:\n# 24 in decimal \u00f7 16 = 1 + 8, in hex = 18 \n\n#Example 1:\n# In decimal 160 \u00f7 16 =10 + 0, now we have to conver 10 again (because there in no 10 in hex). Decimal 10 in hex = A\n# 160 in decimal = 0A in hex\n<\/pre><\/div>","protected":false},"excerpt":{"rendered":"<p>DHCP (Dynamic Host Configuration Protocol) automatically assigns IP addresses and network parameters to client devices. On Cisco devices, a switch or router can be configured as a DHCP server or a DHCP relay to forward requests to a remote server. Main Functions: DHCP Server \u2014 Assigns IP addresses to clients. DHCP Relay (ip helper-address) \u2014 &hellip; <a href=\"https:\/\/itgen.itbumper.com\/?page_id=780\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;0024_Cisco: DHCP&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"categories":[],"tags":[],"_links":{"self":[{"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=\/wp\/v2\/pages\/780"}],"collection":[{"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=780"}],"version-history":[{"count":2,"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=\/wp\/v2\/pages\/780\/revisions"}],"predecessor-version":[{"id":791,"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=\/wp\/v2\/pages\/780\/revisions\/791"}],"wp:attachment":[{"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=780"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=780"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itgen.itbumper.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=780"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}