The "0" referring to the switch is a reference to the name of the MDIO bus. In the Linux kernel, for some reason beyond my understanding, the "name" of a MDIO bus is a number starting at 0 and increasing.
You can look at "/sys/class/mdio_bus" to see which available buses there are.
Port 5 always refers to the CPU port (A switch built into a router is actually a separate 6-port switch with one of the 6 ports hardwired into the NIC (or CPU). This is the reason that you natively only see one NIC, and why you need to specially communicate with the switch driver about which ports to use.
Note that the UCI commands and editing the config file are separate things and redundant (if you add config 'switch' 'eth0' into /etc/config/network, you do not want to type the "uci set" commands. And vice versa. The only difference with uci is that your changes will be reverted if you do not commit them afterwards.
I will post both the uci versions and the config file versions.
In your case, since you want 2 ports in one and 3 ports in the other, this is how you set it up:
config 'switch' '0'
option 'vlan1' '3 4 5t'
option 'vlan2' '0 1 2 5t'
config 'interface' 'wan'
option 'proto' 'static'
option 'ipaddr' '10.2.1.1'
option 'netmask' '255.255.255.0'
option 'ifname' 'eth0.1'
config 'interface' 'lan'
option 'proto' 'static'
option 'ipaddr' '192.168.1.1'
option 'netmask' '255.255.255.0'
option 'ifname' 'eth0.2'
Note that depending on how you set it up, network port 4 may actually be physically disconnected from the switch and instead will show up as "eth1" (while the switch is eth0) or show up as eth0 (while switched ports are at eth1). I do not have a RB450 so I don't know which it is.
So you may need to replace all eth0.1 with eth1.1, or you may need to divide up the switch ports differently (or combine them in a software bridge) if one of the ports is physically disconnected from the others.
The UCI commands are:
uci set network.0=switch
uci set network.0.vlan1='3 4 5t'
uci set network.0.vlan2='0 1 2 5t'
uci set network.wan=interface
uci set network.wan.proto=static
uci set network.wan.ipaddr=10.2.1.1
uci set network.wan.netmask=255.255.255.0
uci set network.wan.ifname=eth0.1
uci set network.lan=interface
uci set network.lan.proto=static
uci set network.lan.ipaddr=192.168.1.1
uci set network.lan.netmask=255.255.255.0
uci set network.lan.ifname=eth0.2
Either way, to test you can do "/etc/init.d/network restart" and if you use UCI commands, once the configuration works, you should do "uci commit" which will write the changes into the /etc/config/network file.
The way I have this configuration set up, the ports 0,1,2,cpu and 3,4,cpu are bridged by hardware--that is, firewall rules will not be run if #0 sends a packet directly to #2.
However, if you would like to bridge them (which takes more CPU), you can do as the example above:
config 'switch' '0'
option 'vlan1' '4 5t'
option 'vlan2' '3 5t'
option 'vlan3' '2 5t'
option 'vlan4' '1 5t'
option 'vlan5' '0 5t'
And then for any of the networks you want bridged, use "config type bridge" and use 'ifnames' instead of 'ifname', like this:
config 'interface' 'wan'
option 'type' 'bridge'
option 'proto' 'static'
option 'ipaddr' '10.2.1.1'
option 'netmask' '255.255.255.0'
option 'ifname' 'eth0.4 eth0.5'
config 'interface' 'lan'
option 'type' 'bridge'
option 'proto' 'static'
option 'ipaddr' '192.168.1.1'
option 'netmask' '255.255.255.0'
option 'ifname' 'eth0.1 eth0.2 eth0.3'
Do not be confused by the numbering vlan1-vlan5 and eth0.1-eth0.5. The IP175C spec says that you cannot use VLAN 0 for anything other than QOS tagging, so I use 1-5 instead of 0-4. If it makes things easier, you can add 10, and use vlans 10,11,12,13,14 to represent ports 0-4.
Hope this helps clarify
EDIT: fixed to use ifname (II figured the plural was if you have more than one based on some post I read)
(Last edited by phorn on 28 Jan 2009, 09:07)