1.\" $NetBSD: vlan.4,v 1.34 2015/11/20 17:02:58 christos Exp $ 2.\" 3.\" Copyright (c) 2000, 2015 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Jason R. Thorpe of Zembu Labs, Inc. 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.\" 30.Dd November 20, 2015 31.Dt VLAN 4 32.Os 33.Sh NAME 34.Nm vlan 35.Nd IEEE 802.1Q Virtual LAN network device 36.Sh SYNOPSIS 37.Cd "pseudo-device vlan" 38.Sh DESCRIPTION 39The 40.Nm 41interface provides support for 42.Tn IEEE 43802.1Q Virtual Local Area Networks 44.Pq Tn VLAN . 45This supports the 46trunking of more than one network on a single network interface by using 47802.1Q tagged and untagged frames. 48.Pp 49To use a 50.Nm vlan 51interface, the administrator must first create the interface and then 52specify the VID 53.Po 54.Tn VLAN 55identifier, the first 12 bits from a 16-bit integer which 56distinguishes each 57.Tn VLAN 58from any others 59.Pc 60and 61.Pq parent 62physical interface associated with the 63.Tn VLAN . 64This can be done by using the 65.Xr ifconfig 8 66.Ic create , 67.Ic vlan , 68and 69.Ic vlanif 70subcommands from a shell command line or script. 71From within a C program, use the 72.Xr ioctl 2 73system call with the 74.Dv SIOCSIFCREATE 75and 76.Dv SIOCSIFVLAN 77arguments. 78.Pp 79Packets sent through a 80.Nm 81interface are tagged with the VID and passed to the parent interface for 82transmission. 83Tagged packets received on the parent interface are passed to the 84.Nm 85interface with the corresponding VID associated with the parent interface. 86Packets sent directly through the parent interface are transmitted as 87untagged frames. 88Untagged frames received on the parent interface are handled by the 89parent interface. 90Tagged frames received on the parent interface with a VID of 0 and an 91EtherType of IP or IPv6 are processed on the parent interface. 92Tagged frames received on the parent interface for which no 93.Nm 94interface with a matching VID exists are dropped and counted as 95.Dq unknown protocol . 96.Po 97These are displayed by the 98.Xr ifconfig 8 99.Fl v 100option. 101.Pc 102.Pp 103If the 104.Nm 105pseudo-device is not configured in the kernel only packets tagged with a 106VID of 0 are processed. 107.Pp 108To be compatible with other 109.Tn IEEE 110802.1Q devices, the 111.Nm 112interface supports a 1500 byte 113.Tn MTU , 114which means that the parent interface will have to handle packets 115that are 4 bytes larger than the original 116.Tn Ethernet 117standard. 118Drivers supporting this increased 119.Tn MTU 120are: 121.Pp 122.Bl -dash -compact 123.It 124drivers using the DP8390 core 125.Po 126such as 127.Xr ec 4 , 128.Xr ne 4 , 129.Xr we 4 , 130and possibly others 131.Pc 132.It 133.Xr bge 4 134.It 135.Xr bnx 4 136.It 137.Xr ea 4 138.It 139.Xr eb 4 140.It 141.Xr epic 4 142.It 143.Xr etherip 4 144.It 145.Xr ex 4 146.It 147.Xr fxp 4 148.It 149.Xr gem 4 150.It 151.Xr hme 4 152.It 153.Xr le 4 154.It 155.Xr sip 4 156.It 157.Xr ste 4 158.It 159.Xr stge 4 160.It 161.Xr ti 4 162.It 163.Xr tl 4 164.It 165.Xr tlp 4 166.It 167.Xr vge 4 168.It 169.Xr vr 4 170.It 171.Xr wm 4 172.It 173.Xr xi 4 174.El 175.Pp 176.Nm 177can be used with devices not supporting the 178.Tn IEEE 179802.1Q 180.Tn MTU , 181but then the 182.Tn MTU 183of the 184.Nm 185interface will be 4 bytes too small and will not interoperate 186properly with other 187.Tn IEEE 188802.1Q devices, unless the 189.Tn MTU 190of the other hosts on the 191.Tn VLAN 192are also lowered to match. 193.Sh EXAMPLES 194The following will create interface 195.Sy vlan0 196with VID six, on the 197.Tn Ethernet 198interface 199.Sy tlp0 : 200.Bd -literal -offset indent 201ifconfig vlan0 create 202ifconfig vlan0 vlan 6 vlanif tlp0 203.Ed 204.Pp 205After this set up, 206.Tn IP 207addresses (and/or other protocols) can be assigned to the 208.Sy vlan0 209interface. 210All other hosts on the 211.Tn Ethernet 212connected to 213.Sy tlp0 214which configure a 215.Tn VLAN 216and use VID six will see all traffic transmitted through 217.Sy vlan0 . 218.Pp 219The same 220.Tn VLAN 221can be created at system startup time 222by placing the following in 223.Pa /etc/ifconfig.vlan0 : 224.Bd -literal -offset indent 225create 226vlan 6 vlanif tlp0 227.Ed 228.Sh SEE ALSO 229.Xr bridge 4 , 230.Xr ifconfig 8 231.Sh HISTORY 232The 233.Nm 234device first appeared in 235.Nx 1.5.1 , 236and was derived from a 237.Tn VLAN 238implementation that appeared in 239.Fx 240and 241.Ox . 242.Sh BUGS 243The 244.Nm 245interfaces do not currently inherit changes made to the physical 246interfaces' 247.Tn MTU . 248