{"id":10164,"date":"2009-12-01T19:57:09","date_gmt":"2009-12-01T19:57:09","guid":{"rendered":"https:\/\/aidanfinn.com\/?p=10164"},"modified":"2009-12-01T19:57:09","modified_gmt":"2009-12-01T19:57:09","slug":"hyper-v-and-vlans-2","status":"publish","type":"post","link":"https:\/\/aidanfinn.com\/?p=10164","title":{"rendered":"Hyper-V and VLAN\u2019s"},"content":{"rendered":"<p>How do you run multiple virtual machines on different subnets?&#160; Forget for for just a moment that these are virtual machines.&#160; How would you do it if they were physical machines?&#160; The network administrators would set up a Virtual Local Area Network or VLAN.&#160; A VLAN is a broadcast domain, i.e. it is a single subnet and broadcasts cannot be transmitted beyond its boundaries without some sort of forwarder to convert the broadcast into a unicast.&#160; Network administrators use VLAN\u2019s for a bunch of reasons:<\/p>\n<ul>\n<li>Control broadcasts because they can become noisy. <\/li>\n<li>They need to be creative with IP address ranges. <\/li>\n<li>The want to separate network devices using firewalls. <\/li>\n<\/ul>\n<p>That last one is why we have multiple VLAN\u2019s at work.&#160; Each VLAN is firewalled from every other VLAN.&#160; We open up what ports we need to between VLAN\u2019s and to\/from the Internet.&#160; <\/p>\n<p>Each VLAN has an ID.&#160; That is used by administrators for configuring firewall rules, switches and servers.<\/p>\n<p>How do you tell a physical server that it is on a VLAN?<\/p>\n<p>There\u2019s two ways I can think of:<\/p>\n<ul>\n<li>The network administrators would assign the switch ports that will connect the server to a specific VLAN <\/li>\n<li>The network administrators can create a \u201ctrunk\u201d on a switch port.&#160; That\u2019s when all VLAN\u2019s are available on that port.&#160; Then on the server you need to use the network card driver or management software to specify which VLAN to bind the NIC to.&#160; Some software (HP NCU) allows you to create multiple virtual network cards to bind the server to multiple VLAN\u2019s using one physical NIC. <\/li>\n<\/ul>\n<p>How about a virtual machine; how do you bind the virtual NIC of a virtual machine to a specific VLAN?&#160; It\u2019s a similar process.&#160; I must warn anyone reading this that I\u2019ve worked with a Cisco CCIE while working on Hyper-V and previously with another senior Cisco guy while working on VMware ESX and neither of them could really get their heads around this stuff.&#160; Is it too complicated for them?&#160; Hardly.&#160; I think the problem was that it was too simple!&#160; Seriously!<\/p>\n<p>Let\u2019s have a look at the simplest virtual networking scenario:<\/p>\n<p><a href=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2009\/12\/image11.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2009\/12\/image_thumb11.png\" width=\"404\" height=\"274\" \/><\/a>The host server has a single physical NIC to connect virtual machines.&#160; A virtual switch is created in Hyper-V to pass the physical network that is attached to that NIC to any VM that is bound to that virtual switch.<\/p>\n<p>You can see above that the switch only operates with VLAN 101.&#160; Every server on the network operates on VLAN 101.&#160; The physical servers are on it, the parent partition of the host is on it, etc.&#160; The physical switch port is connected to the virtual machine NIC in the host using a physical network cable.&#160; In Hyper-V, the host administrator creates a virtual switch.<\/p>\n<p>Network admins: Here\u2019s where you pull what hair you have left out.&#160; This is not a switch like you think of a switch.&#160; There is no console, no MIB, no SNMP, no ports, no spanning tree loops, nada!&#160; It is a software connection and network pass through mechanism that exists only in the memory of the host.&#160; It interacts in no way with the physical network.&#160; You don\u2019t need to architect around them.<\/p>\n<p>The virtual switch is a linking mechanism.&#160; It connects the physical network card to the virtual network card in the virtual machine.&#160; It\u2019s as simple as that.&#160; In this case both of the VM\u2019s are connected to the single virtual switch (configured as an External type).&#160; That means they too are connected to VLAN 101.<\/p>\n<p>How do we get multiple Hyper-V virtual machines to connect to multiple VLAN\u2019s?&#160; There\u2019s a few ways we can attack this problem.<\/p>\n<h4>Multiple Physical NIC\u2019s<\/h4>\n<p>In this scenario the physical host server is configured with multiple NIC\u2019s.&#160; <\/p>\n<p>*Rant Alert* Right, there\u2019s a certain small number of journalists\/consultants who are saying \u201cyou should always try to have 1 NIC for every VM on the host\u201d.&#160; Duh!&#160; Let\u2019s get real.&#160; Most machines don\u2019t use their GB connections in a well designed and configured network.&#160; That nightly tape backup over the network design is a dinosaur.&#160; Look at differential, block level continuous incremental backups instead, e.g. Microsoft System Center Data Protection Manager or Iron Mountain Live Vault.&#160; Next, who has money to throw at installing multiple quad NIC\u2019s with physical switch ports all over the place.&#160; The idea here is to consolidate!&#160; Finally, if you are dealing with blade servers you only have so many mezzanine card slots and enclosure\/chassis device slots.&#160; If a blade can have 144GB of RAM, giving maybe 40+ VM\u2019s, that\u2019s an awful lot of NIC\u2019s you\u2019re going to need :)&#160; Sure there are scenarios where a VM might need a dedicated NIC but there are extremely rare. *Rant Over*<\/p>\n<p><a href=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2009\/12\/image12.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2009\/12\/image_thumb12.png\" width=\"404\" height=\"259\" \/><\/a>In this situation the network administrator has set up two ports on the switches, one for each VLAN to connect to the Hyper-V host.&#160; VLAN 101 has a physical port on the switch that is cabled to NIC 1 on the host.&#160;&#160; VLAN 102 has a physical port on the switch that is cabled to NIC 2 on the host.&#160; The parent partition has it\u2019s own NIC, not shown.&#160; Virtual Switch 1 is created and connected to NIC 1 and Virtual Switch 2 is created and connected to NIC 2.&#160; Every VM that needs to talk on VLAN 101 will be connected to Virtual Switch 1 by the host administrator.&#160; Every VM that needs to talk on VLAN 102 should be connected to Virtual Switch 2 by the host administrator.<\/p>\n<h4>Virtual Switch Binding<\/h4>\n<p>You can only bind one External type virtual switch to a NIC.&#160; So in the above example we could not have matched up two virtual switches to the first NIC and changed the physical switch port to be a network trunk.&#160; We can do something similar but different.<\/p>\n<p><a href=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2009\/12\/image13.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2009\/12\/image_thumb13.png\" width=\"404\" height=\"377\" \/><\/a>When we create an external virtual switch we can tell it to only communicate on a specific VLAN.&#160; You can see in the above screenshot that I\u2019ve built a new virtual switch and instructed it to use the VLAN ID (or tag) of 102.&#160; That means that every VM virtual NIC that connects to this virtual switch will expect to be on VLAN 102 with no exceptions. <\/p>\n<p>Taking our previous example, here\u2019s how this would look:<\/p>\n<p><a href=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2009\/12\/image14.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2009\/12\/image_thumb14.png\" width=\"404\" height=\"259\" \/><\/a>The network administrator has done things slightly different this time.&#160; Instead of configuring the two physical switch ports to be bound to specific VLAN\u2019s they\u2019re simple configured trunks.&#160; That means many VLAN\u2019s are available on that port.&#160; The device communicating on the trunk must specify what VLAN it is on to communicate successfully.&#160; Worried about security?&#160; As long as you trust the host administrator to get things right you are OK.&#160; Users of the virtual machines cannot change their VLAN affiliation.<\/p>\n<p>You can see that virtual switch 1 is now bound to VLAN 101.&#160; Every VM that connects to virtual switch 1 will be only able to communicate on VLAN 101 via the trunk on NIC 1.&#160; It\u2019s similar on NIC 2.&#160; It\u2019s set up with a virtual switch on VLAN 102 and all bound VM\u2019s can only communicate on that VLAN.<\/p>\n<p>We\u2019ve changed where the VLAN responsibility lies but we haven\u2019t solved the hardware costs and consolidation issue.<\/p>\n<h4>VLAN ID on the VM<\/h4>\n<p>Here\u2019s the solution you are most likely to employ.&#160; For the sake of simplicity let\u2019s forget about NIC teaming for a moment.<\/p>\n<p><a href=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2009\/12\/image15.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2009\/12\/image_thumb15.png\" width=\"404\" height=\"379\" \/><\/a>Instead of setting the VLAN on the virtual switch we can do it in the properties of the VM.&#160; To be more precise we can do it in the properties of the virtual network adapter of the VM.&#160; You can see that I\u2019ve done this above by configuring the network adapter to only communicate on VLAN (ID or tag) 102.<\/p>\n<p>This is how it looks in our example:<\/p>\n<p><a href=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2009\/12\/image16.png\"><img loading=\"lazy\" decoding=\"async\" style=\"border-right-width: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/aidanfinn.com\/wp-content\/uploads\/2009\/12\/image_thumb16.png\" width=\"404\" height=\"259\" \/><\/a>Again, the network administrator has set up a trunk on the physical switch port.&#160; A single external virtual switch is configured and no VLAN ID is specified.&#160; The two VM\u2019s are set up and connected to the virtual switch.&#160; It is here that the VLAN specification is done.&#160; VM 1 has it\u2019s network adapter configured to talk on VLAN 101.&#160; VM 2 is configured to operate on VLAN 102.&#160; And it works, just like that!<\/p>\n<p><em>Waiver: I\u2019m seeing a problem where VMM created NIC\u2019s do not bind to a VLAN.&#160; Instead I have to create the virtual network adapter in the Hyper-V console.<\/em><\/p>\n<p>Here\u2019s one to watch out for if you use the self servicing console.&#160; If you cannot trust delegated administrators\/users to get VLAN ID configuration right or don\u2019t trust them security-wise then do not allow them to alter VM configurations.&#160; If you do then they can alter the VLAN ID and put their VM into a VLAN that it might not belong to.<\/p>\n<h4>Firewall Rules<\/h4>\n<p>Unless network administrators allow it, virtual machines on VLAN 101 cannot see virtual machines on VLAN 102.&#160; A break out is theoretically impossible due to the architecture of Hyper-V leveraging the No eXecute Bit (AKA DEP or Data Execution Prevention).<\/p>\n<h4>Summary<\/h4>\n<p>You can see that you can set up a Hyper-V host to run VM\u2019s on different VLAN\u2019s.&#160; You\u2019ve got different ways to do it.&#160; You can even see that you can use your VLAN\u2019s to firewall VM\u2019s from each other.&#160; Hopefully I\u2019ve explained this in a way that you can understand.<\/p>\n<div style=\"padding-bottom: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: none; padding-top: 0px\" id=\"scid:0767317B-992E-4b12-91E0-4F059A8CECA8:84a08b14-1a98-4da6-a946-57e40b5a9e1a\" class=\"wlWriterEditableSmartContent\">Technorati Tags: <a href=\"http:\/\/technorati.com\/tags\/Hyper-V\" rel=\"tag\">Hyper-V<\/a>,<a href=\"http:\/\/technorati.com\/tags\/Windows+Server+2008+R2\" rel=\"tag\">Windows Server 2008 R2<\/a>,<a href=\"http:\/\/technorati.com\/tags\/Networking\" rel=\"tag\">Networking<\/a><\/div>\n","protected":false},"excerpt":{"rendered":"<p>How do you run multiple virtual machines on different subnets?&#160; Forget for for just a moment that these are virtual machines.&#160; How would you do it if they were physical machines?&#160; The network administrators would set up a Virtual Local Area Network or VLAN.&#160; A VLAN is a broadcast domain, i.e. it is a single &hellip; <a href=\"https:\/\/aidanfinn.com\/?p=10164\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Hyper-V and VLAN\u2019s&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"om_disable_all_campaigns":false,"_monsterinsights_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"_uf_show_specific_survey":0,"_uf_disable_surveys":false,"footnotes":""},"categories":[20],"tags":[181,80,117],"class_list":["post-10164","post","type-post","status-publish","format-standard","hentry","category-hyper-v","tag-hyper-v","tag-networking","tag-windows-server-2008-r2"],"aioseo_notices":[],"jetpack_featured_media_url":"","amp_enabled":true,"_links":{"self":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts\/10164","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10164"}],"version-history":[{"count":0,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=\/wp\/v2\/posts\/10164\/revisions"}],"wp:attachment":[{"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10164"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10164"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/aidanfinn.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10164"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}