User Tools

Site Tools


zh-cn:doc:uci:network:switch

交换机手册(Switch Documentation)

FIXME: This page assumes you know what this is and why you want it. (Someone please add info or another page and a link).

如果你的设备含有不少于1个的LAN接口,那这个设备在不同的接口之间可能有一个被称为交换(switch)的特殊连接。大多数的内部构造如下图所示:

如果你想要更改这些端口如何互相连接的,你需要配置你的switch设备。 (see also network.interfaces)

UCI config, swconfig style

假设

  • 设备运行在kernel 2.6 或 3 的版本
  • 设备使用swconfig类型的switch配置
  • —————————————————
  • swithc位于eth1上。FIXME(大多是在eth0上)[Howto find out:/proc/switch directory appears to contain the right eth number for the switch. please confirm], 并且同样位于芯片上,例如:rtl8366s.
  • 5个接口的交换设备,其中0-3连接外部,4没有连接,5连接到CPU的eth1接口上(which adds up to six ports except that 4 is not counted)
  • vlan0 仅表示所有的对外接口除了最后的那个。
  • vlan1 仅表示最后的那个对外接口。[Howto find out which Port corresponds:]
  • vlan0 是默认的vlan,就是说如果包没有标签(untagged)将会被看作vlan0的包看待。

配置

交换配置

/etc/config/network

config 'switch' 'eth1'
   option 'enable'      '1'
   option 'enable_vlan' '1'
   option 'reset'       '1'
   option 'pvid'        '100'

VLAN: switch config

in /etc/config/network

Notes

VLAN的数字在选项 vlan 行 是特殊的。 VID(vlan id)与vlan的关联默认与vlan的数字一样的。这个数字可以被选项:option pvid 更改。例如,VLAN1可以使用VID 100

In the 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.

The config sections

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/network config

VLAN interface sections look just like regular interface sections, except that instead of eth1 (or eth0, or whatever), you have eth1.0, 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 /etc/config/network

e.g.

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 wan interface eth0.1 and the lan eth0.0 with appropriately matching switch, switch_vlan and switch_port sections.

See also backplane.

zh-cn/doc/uci/network/switch.txt · Last modified: 2014/05/06 11:40 by zz.zhangz.gmail.com