Device vs Interface

This is the configuration of my Newifi D2:

config interface 'lan'
	option type 'bridge'
	option ifname 'eth0.1'
	option proto 'static'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option ipaddr '192.168.100.1'

config device 'lan_dev'
	option name 'eth0.1'
	option macaddr '20:76:93:46:64:4f'

config interface 'wan'
	option ifname 'eth0.2'
	option proto 'dhcp'
	option type 'bridge'

config device 'wan_dev'
	option name 'eth0.2'
	option macaddr '20:76:93:46:64:50'

config interface 'wan6'
	option ifname 'eth0.2'
	option proto 'dhcpv6'

config switch
	option name 'switch0'
	option reset '1'
	option enable_vlan '1'

config switch_vlan
	option device 'switch0'
	option vlan '1'
	option ports '0 1 2 3 6t'
	option vid '1'

config switch_vlan
	option device 'switch0'
	option vlan '2'
	option ports '4 6t'
	option vid '2'

Basically, 4 LAN ports belong to 802.1q VLAN1, and the WAN port belong to VLAN2. The switch sends the data over the trunk interface (port 6t) to the internal computer (aka CPU), which receives all packets on its trunk port called eth0, then separates the data to corresponding eth0.1 and eth0.2 interfaces. I have some questions:

  1. On the configuration above, what is the differences between interface and device? The only difference I can see is that a device has MAC address, while an interface doesn't. Maybe we can create multiple interfaces on a single device? But then, what is the purpose of it?
  2. On LuCI, I can see the lan interface has the same MAC address with lan_dev device (due to bridging?). But if I add another interface with same parameters:
config interface 'test-interface'
	option type 'bridge'
	option ifname 'eth0.1'
	option proto 'static'
	option netmask '255.255.255.0'
	option ip6assign '60'
	option ipaddr '192.168.100.123'

This test-interface shows no MAC address on LuCI, unless I remove the option type 'bridge'. I am very confused.

  • config device refers to a PHY. For some reason you (or the default config) specified MAC addresses, hence a device config section - this can normally be omitted
  • config interface is an OpenWrt-enumerated network connection, (basically) this will specify all PHYs that will be included in one logical broadcast domain on the router

This is not due to bridging. It's due to the fact you have given VLAN 1 a MAC address. And yes, VLAN 1 is bridged so it also covers WiFi. Your reconfiguration removed the bridge, and hence the WiFi SSID from LAN.

See:

2 Likes

Thanks for your answer. I now understand the option type 'bridge' option. It creates a software bridge that links several interfaces together just like connecting multiple devices to a switch. I can now even bridge an SSID to WAN interface, so that wireless clients connect to the upstream router, bypassing OpenWrt and LAN's clients entirely.

For the config device option, I think your answer is not clear. You said device is a physical, and interface is logical. But according to the link you provide, the eth0.1 is a virtual interface (in the config device section above). And I still don't get why they need to separate the configuration of a WAN device and a WAN interface. These 2 sections can be merged into 1, unless there are other reasons.

A config device block with the MAC address is only necessary on some models where the kernel doesn't automatically load the factory MAC into the driver. It's generated by a firstboot script that knows where to find the factory MAC in the flash and copies it to the config file. Setting up the MAC is all that that block does. As far as configuring your networks, you can look past it.

1 Like