{"id":22,"date":"2011-05-10T18:05:56","date_gmt":"2011-05-10T17:05:56","guid":{"rendered":"http:\/\/openbsd.g7obs.com\/?p=22"},"modified":"2011-05-10T18:05:56","modified_gmt":"2011-05-10T17:05:56","slug":"multiple-vlan-setup-on-openbsd","status":"publish","type":"post","link":"http:\/\/openbsd.g7obs.com\/?p=22","title":{"rendered":"Multiple VLAN setup on OpenBSD"},"content":{"rendered":"<p>Open BSD has for some while supported 802.1q Virtual LANs (VLAN). This allow you to have a server using only one Network Card\/Cable to be a part of multiple distinct network ranges. Now in order to do this you need to be connected to a network switch that understands VLANS (most decent smart switches do), and you need to configure the port that is attached to your server as a trunk port, and optionally supply a list of VLAN identifiers that will pass down that trunk.<\/p>\n<p>Configuring the switch side is an exercise for the reader, since every switch maker has a &#8216;slightly&#8217; different way to do it, but on a Cisco switch for example<\/p>\n<pre>interface FastEthernet0\/1<\/pre>\n<pre>description Trunk link to OpenBSD Server<\/pre>\n<pre>switchport mode trunks<\/pre>\n<pre>switchport allowed vlan 1,7,9<\/pre>\n<pre>speed 100<\/pre>\n<pre>duplex full<\/pre>\n<p>&nbsp;<\/p>\n<p>would allow access to the Virtual LANs 1, 7, and 9 to be sent towards the server.<\/p>\n<p>&nbsp;<\/p>\n<p>On the server side, the setup is amazingly simple, thanks to the built in support for the <strong>vlan<\/strong> device<\/p>\n<p>First, we need to bring up the master interface (say xl0) but we do not give it an ip address<\/p>\n<pre><strong>ifconfig xl0 up<\/strong><\/pre>\n<p>we can then add the required vlans as virtual network interfaces<\/p>\n<p>&nbsp;<\/p>\n<pre>ifconfig vlan1 create<\/pre>\n<pre>ifconfig vlan7 create<\/pre>\n<pre>ifconfig vlan9 create<\/pre>\n<pre>ifconfig vlan1 vlan 1 vlandev xl0<\/pre>\n<pre>ifconfig vlan7 vlan 7 vlandev xl0<\/pre>\n<pre>ifconfig vlan9 vlan 9 vlandev xl0<\/pre>\n<p>&nbsp;<\/p>\n<p>In the above examples I have kept the name of the interfaces the same as the vlan they are attached to, but there is no reason why you cannot call them something different if you want to, the important bit is that the number after the vlan keyword must match the vlan definition on the switches<\/p>\n<p>Now that we have our vlan interfaces, we can configure them in the normal way for networking<\/p>\n<pre>ifconfig vlan1 inet 10.10.10.1 netmask 255.255.255.0<\/pre>\n<pre>ifconfig vlan7 inet 10.20.30.1 netmask 255.255.255.0<\/pre>\n<pre>ifconfig vlan9 inet 10.30.40.1 netmask 255.255.255.0<\/pre>\n<p>&nbsp;<\/p>\n<p>Of course, in order to make this persis after you next reboot the box, we need to configure the \/etc\/hostname.xxx files in the normal way, this configuration would look like<\/p>\n<p>\/etc\/hostname.xl0<\/p>\n<pre>up<\/pre>\n<p>&nbsp;<\/p>\n<p>\/etc\/hostname.vlan1<\/p>\n<pre>inet 10.10.10.1 255.255.255.0 10.10.10.255 vlandev xl0 description \"VLAN1-Net1\"<\/pre>\n<p>&nbsp;<\/p>\n<p>\/etc\/hostname.vlan7<\/p>\n<pre>inet 10.20.30.1 255.255.255.0 10.20.30.255 vlandev xl0 description \"VLAN7-Net2\"<\/pre>\n<p>&nbsp;<\/p>\n<p>and so on<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Open BSD has for some while supported 802.1q Virtual LANs (VLAN). This allow you to have a server using only one Network Card\/Cable to be a part of multiple distinct network ranges. Now in order to do this you need to be connected to a network switch that understands VLANS (most decent smart switches do), [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[14,12,13],"class_list":["post-22","post","type-post","status-publish","format-standard","hentry","category-networking","tag-dot1q","tag-network","tag-vlan"],"_links":{"self":[{"href":"http:\/\/openbsd.g7obs.com\/index.php?rest_route=\/wp\/v2\/posts\/22","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/openbsd.g7obs.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/openbsd.g7obs.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/openbsd.g7obs.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/openbsd.g7obs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=22"}],"version-history":[{"count":4,"href":"http:\/\/openbsd.g7obs.com\/index.php?rest_route=\/wp\/v2\/posts\/22\/revisions"}],"predecessor-version":[{"id":26,"href":"http:\/\/openbsd.g7obs.com\/index.php?rest_route=\/wp\/v2\/posts\/22\/revisions\/26"}],"wp:attachment":[{"href":"http:\/\/openbsd.g7obs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=22"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/openbsd.g7obs.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=22"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/openbsd.g7obs.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=22"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}