{"id":198,"date":"2012-01-10T15:39:59","date_gmt":"2012-01-10T14:39:59","guid":{"rendered":"http:\/\/elkano.org\/blog\/?p=198"},"modified":"2012-01-10T15:43:22","modified_gmt":"2012-01-10T14:43:22","slug":"vlan-tagging-on-linux-for-kvm","status":"publish","type":"post","link":"https:\/\/elkano.org\/blog\/vlan-tagging-on-linux-for-kvm\/","title":{"rendered":"VLAN tagging on Linux for KVM"},"content":{"rendered":"<p>Today, I&#8217;m going to explain my config for KVM server to get network connectivity on guests machines using tagged vlans to get independent networks. As virtual platform I am using <a href=\"http:\/\/pve.proxmox.com\/wiki\/Main_Page\" title=\"Proxmox VE\">Proxmox ve<\/a>. Proxmox is a great platform to administer KVM and OpenVZ machines, actually it is based on Debian Lenny, but very soon will be available the 2.0 version based on Debian Squeeze and with many great features.<\/p>\n<p>I have connected my kvm server network interfaces to two different switches and the switch ports configured in trunk mode only accepting traffic for my tagged vlans. For vlan configuration I am using <strong>vlan<\/strong> package in debian, rather than specify them like eth0.X, I prefer to configure them using this tool.<\/p>\n<p>To install vlan package simply run:<\/p>\n<pre class=\"brush: text; gutter: false; first-line: 1; highlight: []; html-script: false\"> # apt-get install vlan<\/pre>\n<p>Above the two network interfaces I have configured a bond interface in active-backup mode. My \/etc\/network\/interfaces file looks like this:<\/p>\n<pre class=\"brush: text; gutter: true; first-line: 1; highlight: []; html-script: false\">iface eth0 inet manual\r\niface eth1 inet manual\r\n\r\n\r\nauto bond0\r\niface bond0 inet manual\r\n        slaves eth0 eth1\r\n        bond_miimon 100\r\n        bond_mode active-backup\r\n\r\nauto vlan50\r\niface vlan50 inet manual\r\n        vlan_raw_device bond0\r\n\r\nauto vlan60\r\niface vlan60 inet manual\r\n       vlan_raw_device bond0\r\n\r\nauto vlan100\r\niface vlan100 inet manual\r\n       vlan_raw_device bond0\r\n\r\n\r\nauto vmbr0\r\niface vmbr0 inet static\r\n        address  172.17.16.5\r\n        netmask  255.255.240.0\r\n        gateway  172.17.16.1\r\n        bridge_ports vlan100\r\n        bridge_stp off\r\n        bridge_fd 0\r\n\r\nauto vmbr50\r\niface vmbr50 inet static\r\n        address 0.0.0.0\r\n        netmask 255.255.255.255\r\n        bridge_ports vlan50\r\n        bridge_stp off\r\n        bridge_fd 0\r\n\r\nauto vmbr60\r\niface vmbr60 inet static\r\n        address 0.0.0.0\r\n        netmask 255.255.255.255\r\n        bridge_ports vlan60\r\n        bridge_stp off\r\n        bridge_fd 0\r\n\r\n\r\n<\/pre>\n<p>I have three bridges configured, vmbr0 (with vlan 100), required to access proxmox web interface, and vmbr50 and vmbr60, each of them accessing to their vlans to provide access to guests. The bridge vmbr0 is the only bridge that has an IP address configured, because is the only interface I&#8217;m going to use to access to the kvm server. <\/p>\n<p>Now, it is easy to provide network connectivity to the kvm guests machines, simply you have to link their network interfaces to the bridge you want depending on, to that vlan you want they get access.<\/p>\n<p>For example, part of one of my kvm machine config file looks like this:<\/p>\n<pre class=\"brush: text; gutter: false; first-line: 1; highlight: []; html-script: false\">\r\n\r\nvlan60: virtio=DE:17:7C:C3:CE:B2\r\nvlan50: virtio=B2:0A:19:3E:72:4D\r\n\r\n<\/pre>\n<p>This is automatically added using proxmox ve web interface.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Today, I&#8217;m going to explain my config for KVM server to get network connectivity on guests machines using tagged vlans to get independent networks. As virtual platform I am using Proxmox ve. Proxmox is a great platform to administer KVM and OpenVZ machines, actually it is based on Debian Lenny, but very soon will be [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[6,3,27,7],"tags":[147,148,29,28],"_links":{"self":[{"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/posts\/198"}],"collection":[{"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/comments?post=198"}],"version-history":[{"count":23,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/posts\/198\/revisions"}],"predecessor-version":[{"id":221,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/posts\/198\/revisions\/221"}],"wp:attachment":[{"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/media?parent=198"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/categories?post=198"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elkano.org\/blog\/wp-json\/wp\/v2\/tags?post=198"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}