: This page assumes you know what this is and why you want it. (Someone please add info or another page and a link).
如果你想要更改这些端口如何互相连接的，你需要配置你的switch设备。 (see also network.interfaces)
vlan1仅表示最后的那个对外接口。[Howto find out which Port corresponds:]
config 'switch' 'eth1' option 'enable' '1' option 'enable_vlan' '1' option 'reset' '1' option 'pvid' '100'
VLAN标识号是由option vlan行来指定。 一个VLAN的VID(VLAN ID)默认是与相同VLAN标识号关联的。这个标识号可以被option pvid行更改。例如，VLAN1可以使用VID 100
option ports line, a number indicates that the specified vlan includes the port with that number. If the number is followed by a “t” then packets transmitted out that port on this VLAN are tagged, and that packets received on that port may be received with this VLAN tag. 5 is generally the CPU or 'internal' port and is most often used as tagged. Other suffixes are ignored on devices using
swconfig but Broadcom kmod-switch style interfaces (
/proc/switch/) use “*” and “u” to indicate PVID and untagged ports respectively (as they have the CPU port implicitly tagged one needs to use “u” to untag it).
So, '0 1 2 3 5t' would mean that packets on this VLAN are transmitted untagged when leaving ports 0, 1, 2 and 3, but tagged when leaving port 5 (generally the CPU internal port as described above).
Tagged packets received on a port will be directed to the VLAN indicated by the VID contained in the packet. Untagged packets received on a port will be directed to the default port VLAN (usually called the PVID). A separate
config switch_port section is required to set the default port VLAN.
The relevant standards document is 801.2q which says that VID values 0 and 4095 may not be used for tagging packets as they denote reserved values - VID 0 is the default 'native' vlan - leaving 4094 valid values in between, although VID 1 is often reserved for network management (see Dell 2708 for example). This means vlan0 can be used as a VLAN within or between devices, but you cannot tag packets with it.
config 'switch_vlan' option 'vlan' '0' option 'device' 'eth1' option 'ports' '0 1 2 5t' config 'switch_vlan' option 'vlan' '1' option 'device' 'eth1' option 'ports' '3 5t' config 'switch_port' option 'port' '3' option 'pvid' '1'
VLAN interface sections look just like regular interface sections, except that instead of
eth0, or whatever), you have
eth1.1, etc. where a digit after a
. is a VLAN number. (that is, for kernel 2.6; 2.4 kernels do something different).
The following example is for a two-interface router, with eth0 being the WAN and eth1 being the five-port switch configured as above. It goes in
config 'interface' 'lan' option 'ifname' 'eth1.0' option 'proto' 'static' option 'ipaddr' '192.168.1.1' option 'netmask' '255.255.255.0' option 'defaultroute' '0' option 'peerdns' '0' option 'nat' '1' config 'interface' 'extranet' option 'ifname' 'eth1.1' option 'proto' 'dhcp' config 'interface' 'wan' option 'ifname' 'eth0.2' option 'proto' 'pppoe' option 'username' 'szabozsolt-em' option 'password' 'M3IuWBt4'
Of course, if you only had a five port switch on eth0 (and no other interfaces), you might make the
eth0.1 and the lan
eth0.0 with appropriately matching
See also backplane.