{"id":1106,"date":"2013-09-19T13:10:07","date_gmt":"2013-09-19T12:10:07","guid":{"rendered":"http:\/\/www.phillips321.co.uk\/?p=1106"},"modified":"2013-09-19T13:58:49","modified_gmt":"2013-09-19T12:58:49","slug":"testing-multiple-vlans-the-easy-way-trunk-ports","status":"publish","type":"post","link":"https:\/\/www.phillips321.co.uk\/2013\/09\/19\/testing-multiple-vlans-the-easy-way-trunk-ports\/","title":{"rendered":"Testing multiple VLANs the easy way &#8211; Trunk Ports"},"content":{"rendered":"<p>Okay, so me and a colleague were tasked with a job which meant we had a short space of time to test around 300 devices spread over 10+ VLANs. We could have requested that a port was set up on each switch for us to gain access but we also had a trunk port set up. (Cheers to DK1 for the pointers)<\/p>\n<p>A trunk port basically allows you to set your device up to connect to multiple VLANs. In the Cisco world VLANs are local to each switches database and VLAN information is not generally passed between switches. Using a trunk port will allow you to connect two switches together so that they can send data regardless of VLAN.<\/p>\n<p>To set up a trunk port on a Cisco device you need to do roughly the following (milage might vary):<\/p>\n<div class=\"codecolorer-container text vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/><\/div><\/td><td><div class=\"text codecolorer\">interface GigabitEthernet0\/10<br \/>\n&nbsp;description PenTesting-delete after 31\/12\/13<br \/>\n&nbsp;switchport trunk encapsulation dot1q<br \/>\n&nbsp;switchport trunk native vlan 0<br \/>\n&nbsp;switchport mode trunk<br \/>\n&nbsp;switchport nonegotiate<br \/>\n&nbsp;no cdp enable<br \/>\nno shutdown<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Trunk ports only carry VLAN tagged packets so when a switch receives data on it&#8217;s trunk port it forwards it to the VLAN denoted by the frame tag. The reason we have set <em>native vlan 0<\/em> is to ensure that anything that isn&#8217;t tagged is set to a specific VLAN.<\/p>\n<p>Now that the switch is set up for trunking we need to ensure that our testing device is set up for VLAN trunking. In Kali Linux this is as easy as <em>apt-get install vlan<\/em><\/p>\n<p>Then we need to set up the interfaces that we will associate with the VLANs. We can call them anything we want but in this instance we will call them vlan<em>x<\/em> (where <em>x<\/em> denotes the VLAN number).<\/p>\n<p>Open <em>\/etc\/network\/interfaces<\/em> using your favourite text editor (we all know nano is best!). And then set up the interfaces as follows:<\/p>\n<div class=\"codecolorer-container bash vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;height:300px;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/>11<br \/>12<br \/>13<br \/>14<br \/>15<br \/>16<br \/>17<br \/>18<br \/>19<br \/>20<br \/>21<br \/>22<br \/>23<br \/>24<br \/><\/div><\/td><td><div class=\"bash codecolorer\"><span class=\"co0\"># The loopback network interface<\/span><br \/>\nauto lo<br \/>\niface lo inet loopback<br \/>\n<br \/>\n<span class=\"co0\"># VLAN Settings<\/span><br \/>\nauto eth0<br \/>\n<br \/>\nauto vlan10 <br \/>\niface vlan10 inet static<br \/>\naddress 10.0.0.200 &nbsp;<br \/>\nnetmask 255.255.255.0<br \/>\nvlan_raw_device eth0<br \/>\n<br \/>\nauto vlan172<br \/>\niface vlan172 inet static<br \/>\naddress 172.16.0.200<br \/>\nnetmask 255.255.255.0 &nbsp;<br \/>\nvlan_raw_device eth0<br \/>\n<br \/>\nauto vlan192<br \/>\niface vlan192 inet static<br \/>\naddress 192.168.0.200 <br \/>\nnetmask 255.255.255.0 &nbsp;<br \/>\nvlan_raw_device eth0<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>Note: If you&#8217;re using Kali Linux make sure you remove entries from the network-manager to prevent it from trying to take over your network (Why the devs of Kali Linux defaulted to a network manager in a hacker distro I do not know, I mean aren&#8217;t the people using the distro meant to understand about networking and don&#8217;t need hand holding?)<\/p>\n<p>Disable networking by going to the networking manager in the top right and clicking &#8220;<em>Edit Connections&#8230;<\/em>&#8221;<br \/>\n<a href=\"https:\/\/www.phillips321.co.uk\/wp-content\/uploads\/2013\/09\/Screen-Shot-2013-09-19-at-12.30.491.png\"><img loading=\"lazy\" src=\"https:\/\/www.phillips321.co.uk\/wp-content\/uploads\/2013\/09\/Screen-Shot-2013-09-19-at-12.30.491-283x300.png\" alt=\"Screen Shot 2013-09-19 at 12.30.49\" width=\"283\" height=\"300\" class=\"aligncenter size-medium wp-image-1115\" srcset=\"https:\/\/www.phillips321.co.uk\/wp-content\/uploads\/2013\/09\/Screen-Shot-2013-09-19-at-12.30.491-283x300.png 283w, https:\/\/www.phillips321.co.uk\/wp-content\/uploads\/2013\/09\/Screen-Shot-2013-09-19-at-12.30.491.png 454w\" sizes=\"(max-width: 283px) 100vw, 283px\" \/><\/a><\/p>\n<p>Then delete all the network connections from the wired tab:<br \/>\n<a href=\"https:\/\/www.phillips321.co.uk\/wp-content\/uploads\/2013\/09\/Screen-Shot-2013-09-19-at-12.31.22.png\"><img loading=\"lazy\" src=\"https:\/\/www.phillips321.co.uk\/wp-content\/uploads\/2013\/09\/Screen-Shot-2013-09-19-at-12.31.22-300x238.png\" alt=\"Screen Shot 2013-09-19 at 12.31.22\" width=\"300\" height=\"238\" class=\"aligncenter size-medium wp-image-1112\" srcset=\"https:\/\/www.phillips321.co.uk\/wp-content\/uploads\/2013\/09\/Screen-Shot-2013-09-19-at-12.31.22-300x238.png 300w, https:\/\/www.phillips321.co.uk\/wp-content\/uploads\/2013\/09\/Screen-Shot-2013-09-19-at-12.31.22.png 882w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n<p>Then you need to restart your networking so that the new VLAN interfaces are brought up:<\/p>\n<div class=\"codecolorer-container bash vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/>2<br \/>3<br \/>4<br \/>5<br \/>6<br \/>7<br \/>8<br \/>9<br \/>10<br \/><\/div><\/td><td><div class=\"bash codecolorer\"><span class=\"co4\">root@kali:~# <\/span>service networking restart<br \/>\n<span class=\"br0\">&#91;<\/span>....<span class=\"br0\">&#93;<\/span> Reconfiguring network interfaces...Ignoring unknown interface <span class=\"re2\">eth0<\/span>=eth0.<br \/>\nWARNING: &nbsp;Could not open <span class=\"sy0\">\/<\/span>proc<span class=\"sy0\">\/<\/span>net<span class=\"sy0\">\/<\/span>vlan<span class=\"sy0\">\/<\/span>config. &nbsp;Maybe you need to load the 8021q module, or maybe you are not using PROCFS??<br \/>\nSet name-type <span class=\"kw1\">for<\/span> VLAN subsystem. Should be visible <span class=\"kw1\">in<\/span> <span class=\"sy0\">\/<\/span>proc<span class=\"sy0\">\/<\/span>net<span class=\"sy0\">\/<\/span>vlan<span class=\"sy0\">\/<\/span>config<br \/>\nAdded VLAN with VID == <span class=\"nu0\">10<\/span> to IF -:eth0:-<br \/>\nSet name-type <span class=\"kw1\">for<\/span> VLAN subsystem. Should be visible <span class=\"kw1\">in<\/span> <span class=\"sy0\">\/<\/span>proc<span class=\"sy0\">\/<\/span>net<span class=\"sy0\">\/<\/span>vlan<span class=\"sy0\">\/<\/span>config<br \/>\nAdded VLAN with VID == <span class=\"nu0\">172<\/span> to IF -:eth0:-<br \/>\nSet name-type <span class=\"kw1\">for<\/span> VLAN subsystem. Should be visible <span class=\"kw1\">in<\/span> <span class=\"sy0\">\/<\/span>proc<span class=\"sy0\">\/<\/span>net<span class=\"sy0\">\/<\/span>vlan<span class=\"sy0\">\/<\/span>config<br \/>\nAdded VLAN with VID == <span class=\"nu0\">192<\/span> to IF -:eth0:-<br \/>\ndone.<\/div><\/td><\/tr><\/tbody><\/table><\/div>\n<p>To test that the interfaces are up run a quick arp scan across the interfaces using the following:<\/p>\n<div class=\"codecolorer-container bash vibrant\" style=\"overflow:auto;white-space:nowrap;width:100%;\"><table cellspacing=\"0\" cellpadding=\"0\"><tbody><tr><td class=\"line-numbers\"><div>1<br \/><\/div><\/td><td><div class=\"bash codecolorer\"><span class=\"kw1\">for<\/span> i <span class=\"kw1\">in<\/span> <span class=\"sy0\">`<\/span><span class=\"kw2\">cat<\/span> <span class=\"sy0\">\/<\/span>etc<span class=\"sy0\">\/<\/span>network<span class=\"sy0\">\/<\/span>interfaces <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> auto <span class=\"sy0\">|<\/span> <span class=\"kw2\">grep<\/span> <span class=\"re5\">-v<\/span> lo <span class=\"sy0\">|<\/span> <span class=\"kw2\">cut<\/span> <span class=\"re5\">-d<\/span><span class=\"st0\">&quot; &quot;<\/span> <span class=\"re5\">-f<\/span> <span class=\"nu0\">2<\/span><span class=\"sy0\">`<\/span> ; <span class=\"kw1\">do<\/span> arp-scan <span class=\"re5\">-l<\/span> <span class=\"re5\">-I<\/span> <span class=\"re1\">$i<\/span> ; <span class=\"kw1\">done<\/span><\/div><\/td><\/tr><\/tbody><\/table><\/div>\n","protected":false},"excerpt":{"rendered":"<p>Okay, so me and a colleague were tasked with a job which meant we had a short space of time to test around 300 devices spread over 10+ VLANs. We could have requested that a port was set up on each switch for us to gain access but we also had a trunk port set [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1119,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[402,401,400,399],"_links":{"self":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts\/1106"}],"collection":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/comments?post=1106"}],"version-history":[{"count":13,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts\/1106\/revisions"}],"predecessor-version":[{"id":1123,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/posts\/1106\/revisions\/1123"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/media\/1119"}],"wp:attachment":[{"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/media?parent=1106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/categories?post=1106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.phillips321.co.uk\/wp-json\/wp\/v2\/tags?post=1106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}