{"id":368,"date":"2020-10-02T21:32:19","date_gmt":"2020-10-02T21:32:19","guid":{"rendered":"https:\/\/dft.wiki\/?p=368"},"modified":"2021-02-07T16:56:11","modified_gmt":"2021-02-07T16:56:11","slug":"routing-between-vlans-with-sub-interfaces-and-dhcp","status":"publish","type":"post","link":"https:\/\/dft.wiki\/?p=368","title":{"rendered":"Routing between VLANs with Sub-Interfaces and DHCP"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-370 size-full\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/image-31.png\" alt=\"\" width=\"384\" height=\"226\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/image-31.png 384w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/image-31-300x177.png 300w\" sizes=\"auto, (max-width: 384px) 100vw, 384px\" \/><\/p>\n<p>In the first look at the diagram above, there is no need for the Router R1 to the computers to be able to talk to each other. But the network is segmented in VLANs.<\/p>\n<p>You can read what is and how VLAN works in this other post [<a href=\"https:\/\/dft.wiki\/?p=199\">Read It<\/a>].<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-371 size-full\" src=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/image-32.png\" alt=\"\" width=\"384\" height=\"226\" srcset=\"https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/image-32.png 384w, https:\/\/dft.wiki\/wp-content\/uploads\/sites\/15\/2020\/10\/image-32-300x177.png 300w\" sizes=\"auto, (max-width: 384px) 100vw, 384px\" \/><\/p>\n<p>Switch configuration:<\/p>\n<pre>interface GigabitEthernet0\/1\r\nswitchport mode trunk\r\ninterface FastEthernet0\/1\r\nswitchport access vlan 10\r\nswitchport mode access\r\ninterface FastEthernet0\/7\r\nswitchport access vlan 20\r\nswitchport mode access\r\ninterface FastEthernet0\/13\r\nswitchport access vlan 30\r\nswitchport mode access\r\ninterface FastEthernet0\/19\r\nswitchport access vlan 40\r\nswitchport mode access<\/pre>\n<p>Router configuration:<\/p>\n<pre>int g0\/0\r\nno shut\r\nint g0\/0.10\r\nencapsulation dot1q 10\r\nip add 172.17.7.1 255.255.255.192\r\nint g0\/0.20\r\nencapsulation dot1q 20\r\nip add 172.17.7.65 255.255.255.192\r\nint g0\/0.30\r\nencapsulation dot1q 30\r\nip add 172.17.7.129 255.255.255.192\r\nint g0\/0.40\r\nencapsulation dot1q 40\r\nip add 172.17.7.193 255.255.255.192\r\nservice dhcp\r\nip dhcp pool POOL10\r\nnetwork 172.17.7.0 255.255.255.192\r\ndefault-router 172.17.7.1\r\ndns-server 172.17.7.1\r\nip dhcp excluded-address 172.17.7.1\r\nip dhcp pool POOL20\r\nnetwork 172.17.7.64 255.255.255.192\r\ndefault-router 172.17.7.65\r\ndns-server 172.17.7.65\r\nip dhcp excluded-address 172.17.7.65\r\nip dhcp pool POOL30\r\nnetwork 172.17.7.128 255.255.255.192\r\ndefault-router 172.17.7.129\r\ndns-server 172.17.7.129\r\nip dhcp excluded-address 172.17.7.129\r\nip dhcp pool POOL40\r\nnetwork 172.17.7.192 255.255.255.192\r\ndefault-router 172.17.7.193\r\ndns-server 172.17.7.193\r\nip dhcp excluded-address 172.17.7.193<\/pre>\n<p>Useful commands for this exercise:<\/p>\n<pre>show ip dhcp binding\r\nshow arp\r\ninterface range f0\/1-24\r\nencapsulation dot1Q <strong>1<\/strong> native<\/pre>\n<p>Note: the last command informs the router when VLAN the frame belongs in case it comes with no dot1Q encapsulation. Replace <strong>1<\/strong> with the desired Native (default) VLAN.<\/p>\n<p>Bonus: if there is a case where a router is between the client and the DHCP server, the router needs to be configured as DHCP Relay:<\/p>\n<pre>interface g0\/0\r\nip helper-address <strong>10.0.0.1<\/strong><\/pre>\n<p>Replace <strong>10.0.0.1<\/strong> with the IP address of the DHCP Server.<\/p>\n<p>The command &#8216;ip helper-address&#8217; does not only relays DHCP but also other services too:<\/p>\n<ul>\n<li>Time (port 37)<\/li>\n<li>TACACS (port 49)<\/li>\n<li>DNS (port 53)<\/li>\n<li>BOOTP\/DHCP Server (port 67)<\/li>\n<li>BOOTP\/DHCP Client (port 68)<\/li>\n<li>TFTP (port 69)<\/li>\n<li>NetBIOS name service (port 137)<\/li>\n<li>NetBIOS datagram service (port 138)<\/li>\n<\/ul>\n<p>You can define what will be forwarded (relayed) or not by using:<\/p>\n<pre>ip forward-protocol udp 37\r\nno ip forward-protocol udp 53\r\nip directed-broadcast<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>In the first look at the diagram above, there is no need for the Router [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-368","post","type-post","status-publish","format-standard","hentry","category-ccna"],"_links":{"self":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/368","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=368"}],"version-history":[{"count":12,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/368\/revisions"}],"predecessor-version":[{"id":945,"href":"https:\/\/dft.wiki\/index.php?rest_route=\/wp\/v2\/posts\/368\/revisions\/945"}],"wp:attachment":[{"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=368"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=368"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dft.wiki\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=368"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}