Topic: Ethernet ports and Network interfaces (on a TP-Link TL-WR941ND)

Like many consumer devices, the TL-WR941ND is a router, a wireless access point and an Ethernet switch at the same time. It is a device sporting five Ethernet ports. One is labeled WAN, the rest are labeled (LAN) 1 through 4 on the casing. Thus far the hardware situation apparent to the user. Now, with OpenWrt, there's also a view from the inside of the device:

root@TIBERIUS: ~ > ifconfig | grep Link
br-lan    Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
eth0      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
lan1      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
lan2      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
lan3      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
lan4      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
lo        Link encap:Local Loopback
pppoe-wan Link encap:Point-to-Point Protocol
wan       Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0

I've used Linux on a lot of computers with network interface cards/controllers (NICs), all of them Ethernet cards. Usually, an Ethernet NIC has one Ethernet port. In my experience (as gathered on computers), there's also a correspondance between Ethernet ports and MAC addresses: one port, one address. But this does not hold true in the case of the router/switch device. There's five ports, and according to ifconfig all share one MAC address. This somewhat confuses me. Now I found this:

http://wiki.openwrt.org/doc/networking/network.interfaces

A switch has Ethernet ports, and sometimes some IC capable of tagging (hardware tagging) but a switch does not contain/incorporate a NIC. So Linux will show no physical or virtual software interfaces! Do not confuse a simple Ethernet port with a full-blown NIC!

Okay, this makes sense. Further down on the same page, in a section marked as containing outdated information, there's also this:

An OpenWrt box is actually three devices in one. It consists of a VLAN-configurable switch, a wireless port, and a Linux host. The switch and host are connected by one internal "wire" (Gigabit Media Independent Interface), over which VLAN tagged packets are exchanged. All of the physical ethernet ports on the box are just ports on a single internal switch. VLANs are then used to separate the ports into groups.

Does this still apply or is it actually outdated?

Do I conclude correctly that (a) my router/switch device has one NIC with five ports, as reflected by ifconfig showing just one MAC address, and that (b) this is only because it is not only a switch, but also a router, hence some kind of computer?

Re: Ethernet ports and Network interfaces (on a TP-Link TL-WR941ND)

Eumel71 wrote:

Does this still apply or is it actually outdated?

It is (almost) correct for my TL-MR 3420 and I think most popular SMB routers.

I wrote almost since the packets sent to the CPU are not VLAN tagged by default on TL-MR 3420. Which was a bit of a problem for me when I wanted to use port based VLANs, i.e. use one of the ports as a separate interface. I had to enable tagging of the CPU port, since an untagged vlan can only be connected to one port at a time but the CPU port need to be connected to two VLANs in my case. Which also meant I needed to use eth0.0 (tagged) instead of eth0 (untagged). (VLAN 0 seems to work well internally, but a physical port should not be tagged with VLAN 0, 1 och 4095 AFAIK.)

Re: Ethernet ports and Network interfaces (on a TP-Link TL-WR941ND)

Thanks, mikma. So the outdated doc is still sort of correct, at least for some cases.

Let's get some more basic, though. When I left Linux a couple years ago, network interfaces were organized like /dev/eth0 and /dev/eth1. VLANs may have existed but I never got into them. Now when I see lan1 through lan4, how do I know whether they're physical or virtual interfaces?

root@TIBERIUS: ~ > ifconfig eth0
eth0      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:119701 errors:0 dropped:0 overruns:36 frame:0
          TX packets:88672 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:40830778 (38.9 MiB)  TX bytes:34630443 (33.0 MiB)
          Interrupt:4

root@TIBERIUS: ~ > ifconfig lan4
lan4      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:59431 errors:0 dropped:1 overruns:0 frame:0
          TX packets:34350 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:10278146 (9.8 MiB)  TX bytes:26388720 (25.1 MiB)

I can see that eth0 has an interrupt and a non-zero value for txqueuelen. Other than that, they're undistinguishable to me. How do you tell whether it's physical or virtual? There are lan* entries below /sys/devices/platform and links from /sys/devices/virtual. Not sure that's the way you're supposed to get information about your system … please tell me if you know of a better way:

root@TIBERIUS: ~ > find /sys -name \*lan\*
/sys/devices/platform/dsa.0/net/lan1
/sys/devices/platform/dsa.0/net/lan2
/sys/devices/platform/dsa.0/net/lan3
/sys/devices/platform/dsa.0/net/lan4
/sys/devices/platform/leds-gpio/leds/tp-link:green:wlan
/sys/devices/platform/ath9k/net/wlan0
/sys/devices/virtual/net/br-lan
/sys/devices/virtual/net/br-lan/brif/lan1
/sys/devices/virtual/net/br-lan/brif/lan2
/sys/devices/virtual/net/br-lan/brif/lan3
/sys/devices/virtual/net/br-lan/brif/lan4
/sys/devices/virtual/net/br-lan/brif/wlan0
/sys/class/leds/tp-link:green:wlan
/sys/class/net/lan1
/sys/class/net/lan2
/sys/class/net/lan3
/sys/class/net/lan4
/sys/class/net/br-lan
/sys/class/net/wlan0
/sys/kernel/debug/ieee80211/phy0/netdev:wlan0
root@TIBERIUS: ~ > find /sys -name \*eth\*
/sys/devices/platform/ag71xx.0/net/eth0
/sys/class/net/eth0

I'm just trying to configure the system, but doing so I see I don't understand the fundamentals, which is probably why I'm failing to properly configure the system, hence the desire to clarify the fundamentals first. Thanks for any light you can shed on this.

Re: Ethernet ports and Network interfaces (on a TP-Link TL-WR941ND)

Your particular model does not feature a configurable switch, instead the single ethernet ports are exposed as interfaces "lan1" .. "lan4" and bound together using software bridging.

All switch vlan, swconfig and similar documentation does not apply to your device.

Re: Ethernet ports and Network interfaces (on a TP-Link TL-WR941ND)

Thanks, jow. You're saying:

… the single ethernet ports are exposed as interfaces "lan1" .. "lan4" and bound together using software bridging.

Is this a standard Linux facility or is it specific to OpenWrt?

Also, why would the four ports need to be "bridged"? They are four ports on a hub or switch and sort of in the same boat at the Ethernet level. Googling "software bridging" seems to indicate that it is like hardware bridging, i.e. a facility to link heterogenous networks like Ethernet and WLAN. So not sure how it applies here given that these ports already are linked at the Ethernet level.

root@TIBERIUS: ~ > ifconfig | grep Link
br-lan    Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
eth0      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
lan1      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
lan2      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
lan3      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
lan4      Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0
lo        Link encap:Local Loopback
pppoe-wan Link encap:Point-to-Point Protocol
wan       Link encap:Ethernet  HWaddr 00:23:CD:20:C3:B0

What is the documentation I need to read in order to make sense of the devices OpenWrt exposes and to figure out how to use which ones and why when configuring Netfilter?

Re: Ethernet ports and Network interfaces (on a TP-Link TL-WR941ND)

At least br-lan is a software bridge.

Try: brctl --help

Re: Ethernet ports and Network interfaces (on a TP-Link TL-WR941ND)

Thanks, mikma - this helps.

root@TIBERIUS: ~ > brctl show
bridge name     bridge id               STP enabled     interfaces
br-lan          8000.0023cd20c3b0       no              lan1
                                                        lan2
                                                        lan3
                                                        lan4
                                                        wlan0

If I interpret the output directly, it bridges Ethernet (lan1 through lan4) and WLAN (wlan0). Just for lan1 through lan4, there wouldn't be a need to bridge anything, I think, as all four ports are neighbours on the same Ethernet - but I may very well think wrong.