: This page assumes you know what this is and why you want it. (Someone please add info or another page and a link).
If your device has more than 1 LAN port, it may contain a special connection between the different ports called switch. Most likely the internals may look like in the following picture
If you want to change how these ports are connected to each other you need to configure the switch of your device (see also network.interfaces)
Some of the assumptions, does not see to add up with the provided diagram. Someone familiar with the matter, should either fix them or add a better explanation.
- device is running kernel 2.6 or 3
- device uses an
swconfigtype switch configuration
- The switch is on
eth1. (Many are on
eth0) [Howto find out: → /proc/switch directory appears to contain the right eth number for the switch. please confirm], and also on chips like
- Five-port switch with 0-3 connected externally, 4 not connected, and 5 connected to the CPU's eth1 interface (which adds up to six ports except that 4 is not counted)
vlan0is to be all external ports but the last one
vlan1is only the last external port [Howto find out which Port corresponds:]
vlan0is the default vlan, meaning if a packet is untagged, it will be treated a vlan0 packet
config 'switch' 'eth1' option 'enable' '1' option 'enable_vlan' '1' option 'reset' '1'
The number of the VLAN is specified on the
option vlan line. The VID (VLAN ID) associated with a VLAN is by default the same as the number of the VLAN. This is overridden by using an
option vid line so, for example, that VLAN 1 could use 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.
doc/uci/network/switch.txt · Last modified: 2014/08/16 19:15 by gregorg