Changing the name of the VLAN interface

Here is the default configuration of my device and it works:

config device 'wan_dev'
	option name 'eth0.1'
	option macaddr '20:76:93:46:64:70'

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

I tried to follow the configuration in this article and it did not work:

config device
	option name 'wan_dev'
	option type '8021q'
	option ifname 'eth0'
	option vid '1'
	option macaddr '20:76:93:46:64:70'

config interface 'wan'
	option ifname 'wan_dev'
	option proto 'dhcp'

This did not work either:

config interface 'wan'
	option ifname 'my_vlan_1'
	option proto 'dhcp'

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

config switch_vlan 'my_vlan_1'
	option device 'switch0'
	option vlan '1'
	option ports '4 6t'

I do not want to rely too much on implicit notation. By reading the tutorial so far, I have a feeling that the information and example are quite out of date, and does not reflect current configuration of OpenWrt.

I have never seen that configuration before.
On the contrary I am using the configuration example at the bottom of the page without any issues.

1 Like

Just try the example configuration above the bottom one:

config device
	option type '8021q'
	option ifname 'eth0'
	option vid '106'
	option name 'vlan1'
 
config device
	option type '8021q'
	option ifname 'eth0'
	option vid '204'
	option name 'vlan2'
 
config interface 'lan'
	option type 'bridge'
	option ifname 'vlan1'
	option proto 'static'
	option ipaddr '192.168.1.1'
	option netmask '255.255.255.0'
 
config interface 'wan'
	option ifname 'vlan2'
	option proto 'dhcp'

It doesn't work at all.

@jow is it safe to remove it? Or does it apply to certain devices only?

Implicit notation is all I've ever used so far, and that works fine for me. What drawbacks do they have that you don't want to use them?

Maybe you do not do programming. When you do, you'll soon see that relying on default behaviors is never a good thing. It is error prone and makes your code unclear, harder to read and maintain.

And what when the system changes that behavior in the future? If you use explicit commands, you will get an error at compile time. But if you rely on some sort of default behaviors, you will think it works until runtime. At that moment, you scratch your head wondering why it does not work, then spend days finding the cause.

1 Like