{"id":40,"date":"2007-06-18T21:10:25","date_gmt":"2007-06-18T19:10:25","guid":{"rendered":"http:\/\/lexa.tenet.ua\/blog\/2007\/06\/18\/configuring-vlans-under-fedorarhelcentos\/"},"modified":"2007-06-18T21:10:25","modified_gmt":"2007-06-18T19:10:25","slug":"configuring-vlans-under-fedorarhelcentos","status":"publish","type":"post","link":"https:\/\/lexa.od.ua\/blog\/2007\/06\/18\/configuring-vlans-under-fedorarhelcentos\/","title":{"rendered":"Configuring VLANs Under Fedora\/RHEL\/CentOS"},"content":{"rendered":"<p>The configuration of VLANs under FC\/RHEL\/CentOS is something that I always end up looking in the &#8220;ifup&#8221; script and experimenting around with. This is made worse by there being two different conventions that can be used for the interface naming. Here&#8217;s how I set up VLANs.<br \/>\n<!--more--><br \/>\nFirst of all, the base interface needs to be configured. Usually, it&#8217;s already got at least a stub file, which needs to be modified to have the following elements:<\/p>\n<p>DEVICE=eth0                   #  use real interface name here<br \/>\nBOOTPROTO=static<br \/>\nHWADDR=AA:17:31:9C:8D:BC      #  use real MAC address here<br \/>\nONBOOT=no<br \/>\nTYPE=Ethernet<br \/>\nIPADDR=0.0.0.0<br \/>\nNETMASK=255.255.255.0<\/p>\n<p>In this example, I am configuring the device &#8220;eth0&#8243; (the file \/etc\/sysconfig\/network-scripts\/ifcfg-eth0&#8221;, with the MAC address of &#8220;AA:17:31:9C:8D:BC&#8221;. You will need to plug in your system&#8217;s values for these two lines, and the rest should be left the same.<br \/>\nFor &#8220;vlanX&#8221; Interfaces<\/p>\n<p>If you want your interfaces named &#8220;vlanX&#8221;, use this section. The next section describes how to set it up for interfaces named &#8220;eth0.X&#8221;. The benefit of vlanX naming is that if you only have one VLAN name-space, you don&#8217;t have to care about which interface has the VLAN tagging enabled on it. If you move the physical interface, the vlan interface names stay the same, so you don&#8217;t have to modify firewall rules, etc&#8230;<\/p>\n<p>To set up the VLAN with ID 5, on eth0, you would create a file named &#8220;\/etc\/sysconfig\/network-scripts\/ifcfg-vlan5&#8221; with the following in it:<\/p>\n<p>VLAN=yes<br \/>\nVLAN_NAME_TYPE=VLAN_PLUS_VID_NO_PAD<br \/>\nDEVICE=vlan5<br \/>\nPHYSDEV=eth0<br \/>\nBOOTPROTO=static<br \/>\nONBOOT=yes<br \/>\nTYPE=Ethernet<br \/>\nIPADDR=10.254.5.254<br \/>\nNETMASK=255.255.255.0<\/p>\n<p>The &#8220;PHYSDEV&#8221; line is needed to tell the &#8220;ifup&#8221; script what device to attach the VLAN to. Once you&#8217;ve done this, &#8220;ifup vlan5&#8221; should bring up your vlan5 interface with the IP information specified above. &#8220;ONBOOT&#8221; says the interface should be brought up at boot.<\/p>\n<p>The &#8220;VLAN_NAME_TYPE&#8221; line specifies that devices should be named &#8220;vlan5&#8221;. This only has to appear in the first vlan interface file, but it&#8217;s probably best to have in all of them, in case the first one is removed. Note that only the first one is used, so you can&#8217;t have different naming between VLANs via the Red Hat network scripts. To do that, you&#8217;d have to manually configure the different interfaces.<br \/>\nFor &#8220;eth0.X&#8221; Interfaces<\/p>\n<p>The other method for naming is &#8220;eth0.X&#8221; which has the benefit that you don&#8217;t have to specify the interface name in the ifcfg script. Also, since VLAN interfaces are named based on the physical interface, you can have different VLAN name-spaces. In other words, eth0.5 may be a different network than eth1.5. However, VLAN IDs have a name-space of up to 4096, so unless you&#8217;re dealing with multiple networks outside of your control, you can (and should) probably use a non-overlapping VLAN name-space.<\/p>\n<p>The draw-back is that \/etc\/sysctl.conf interprets the &#8220;.&#8221; in the name as meaning a &#8220;\/&#8221; in the \/proc heirarchy, which breaks things like &#8220;net.ipv4.conf.eth0.5.forwarding = 1&#8221;.<\/p>\n<p>To configure &#8220;eth0.5&#8221;, write a &#8220;\/etc\/sysconfig\/network-scripts\/ifcfg-eth0.5&#8221; file with:<\/p>\n<p>VLAN=yes<br \/>\nDEVICE=eth0.5<br \/>\nBOOTPROTO=static<br \/>\nONBOOT=yes<br \/>\nTYPE=Ethernet<br \/>\nIPADDR=10.254.5.254<br \/>\nNETMASK=255.255.255.0<\/p>\n<p>This is the same as for &#8220;vlan5&#8221; above, but the &#8220;PHYSDEV&#8221; and &#8220;VLAN_NAME_TYPE&#8221; lines may be omitted. <\/p>\n<p>Original <a href=\"http:\/\/www.tummy.com\/journals\/entries\/jafo_20061130_063931\">here<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>The configuration of VLANs under FC\/RHEL\/CentOS is something that I always end up looking in the &#8220;ifup&#8221; script and experimenting around with. This is made worse by there being two different conventions that can be used for the interface naming. Here&#8217;s how I set up VLANs.<\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"ngg_post_thumbnail":0,"footnotes":""},"categories":[2],"tags":[],"class_list":["post-40","post","type-post","status-publish","format-standard","hentry","category-unix"],"_links":{"self":[{"href":"https:\/\/lexa.od.ua\/blog\/wp-json\/wp\/v2\/posts\/40","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/lexa.od.ua\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/lexa.od.ua\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/lexa.od.ua\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/lexa.od.ua\/blog\/wp-json\/wp\/v2\/comments?post=40"}],"version-history":[{"count":0,"href":"https:\/\/lexa.od.ua\/blog\/wp-json\/wp\/v2\/posts\/40\/revisions"}],"wp:attachment":[{"href":"https:\/\/lexa.od.ua\/blog\/wp-json\/wp\/v2\/media?parent=40"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/lexa.od.ua\/blog\/wp-json\/wp\/v2\/categories?post=40"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/lexa.od.ua\/blog\/wp-json\/wp\/v2\/tags?post=40"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}