Of Atheros switches and VLANS on OpenWRT

Being a fan of TP-Link Routers, mesh networks and OpenWRT I had to play around again. Here are my latest results:
If you are trying to configure a port-based VLAN numbered higher than 15 on an Atheros 7240-based wireless router, such as the TP-Link TL-WR842ND, please keep in mind, that the current OpenWRT snapshot r31954 is not yet able to comply with your wish:

root@OpenWRT:~# swconfig dev switch0 help
switch0: eth0(AR7240/AR9330 built-in switch), ports: 5 (cpu @ 0), vlans: 16
–switch
Attribute 1 (int): enable_vlan (Enable VLAN mode)
Attribute 2 (none): apply (Activate changes in the hardware)
Attribute 3 (none): reset (Reset the switch)
–vlan
Attribute 1 (int): vid (VLAN ID)
Attribute 2 (ports): ports (VLAN port mapping)
–port
Attribute 1 (int): pvid (Primary VLAN ID)
Attribute 2 (string): link (Get port link information)

Btw: It seems, that there are two devices involved on this router: eth0 (switch), and eth1 (another interface) (unproved):

root@OpenWRT:~# swconfig dev switch0 show
Global attributes:
enable_vlan: 1
Port 0:
pvid: 1
link: port:0 link:up speed:1000baseT full-duplex txflow rxflow
Port 1:
pvid: 1
link: port:1 link:down
Port 2:
pvid: 1
link: port:2 link:down
Port 3:
pvid: 1
link: port:3 link:down
Port 4:
pvid: 1
link: port:4 link:up speed:100baseT full-duplex auto
VLAN 1:
vid: 1
ports: 0 1 2 3 4 Port 0 seems to be the CPU in this case. On other routers port 5 often represents the CPU, while port 0 is the WAN interface on the same switch.

Well, for comparison, these are the features of a RTL8366RB – as in TP-Link TL-WR1043ND:

root@OpenWRT:~# swconfig dev switch0 help
switch0: rtl8366rb(RTL8366RB), ports: 6 (cpu @ 5), vlans: 4096
–switch
Attribute 1 (int): enable_learning (Enable learning, enable aging)
Attribute 2 (int): enable_vlan (Enable VLAN mode)
Attribute 3 (int): enable_vlan4k (Enable VLAN 4K mode)
Attribute 4 (none): reset_mibs (Reset all MIB counters)
Attribute 5 (int): blinkrate (Get/Set LED blinking rate (0 = 43ms, 1 = 84ms, 2 = 120ms, 3 = 170ms, 4 = 340ms, 5 = 670ms))
Attribute 6 (int): enable_qos (Enable QOS)
Attribute 7 (none): apply (Activate changes in the hardware)
Attribute 8 (none): reset (Reset the switch)
–vlan
Attribute 1 (string): info (Get vlan information)
Attribute 2 (int): fid (Get/Set vlan FID)
Attribute 3 (ports): ports (VLAN port mapping)
–port
Attribute 1 (none): reset_mib (Reset single port MIB counters)
Attribute 2 (string): mib (Get MIB counters for port)
Attribute 3 (int): led (Get/Set port group (0 – 3) led mode (0 – 15))
Attribute 4 (int): disable (Get/Set port state (enabled or disabled))
Attribute 5 (int): rate_in (Get/Set port ingress (incoming) bandwidth limit in kbps)
Attribute 6 (int): rate_out (Get/Set port egress (outgoing) bandwidth limit in kbps)
Attribute 7 (int): pvid (Primary VLAN ID)
Attribute 8 (string): link (Get port link information)

Note at least the switch attribute no. 3: “enable_vlan4k”. That’s what you are looking for.
Until now you can only wait for an update or contribute the missing code yourself.

Nevertheless, if you don’t need port-based VLANs anyways, setting the missing e.g. on eth1 (wan) will work as usual:

… see /etc/config/network and add this section:

config interface ‘vlan100’
option ifname ‘eth1.100’
option type ‘bridge’
option proto ‘static’
option ipaddr ‘192.168.100.1’
option netmask ‘255.255.255.0’

Further literature:
http://wiki.openwrt.org/doc/uci/network/switch
http://wiki.openwrt.org/doc/uci/network
http://wiki.openwrt.org/toh/tp-link/tl-wr842nd
http://www.tp-link.com/en/products/details/?categoryid=238&model=TL-WR842ND

Disclaimer: Any of the trademarks, service marks, collective marks, design rights or similar rights that are mentioned, used or cited within this post are the property of their respective owners.

Advertisement:
netcup.de

2 thoughts on “Of Atheros switches and VLANS on OpenWRT

  1. Hello, im noob in this of openwrt and vlans, im trying to set up a small net with 3 or 4 vlans using the same router (tl-wr842nd), I've readed a lot of openwrt and vlans stuff on wiki.openwrt, but i cant get it works :'(

    This is the only page that talks about this model using vlans, and i have a lot of doubths about how to associate a port to a vlan interface(e.g eth0.1 to vlan10 or vlan2 in port 1 or 2)…

    i got this net config file:

    http://pastebin.com/eb3uf7UL

    i'll be really gratefull with any response, comment or kind of help

    Like

  2. The trick when doing this is, that you cannot mix plain ethernet and vlan modes. As soon as you activate your first vlan, vlan0 will be tagged too.
    So to use your switch ports, you need to use only vlans on them.
    Untagging ports afterwards should work as expected.

    I've seen this on an Routerboard RB750 UP.
    Just play around with swconfig, you'll see, what I mean.

    Like

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s