This a quick guide to configuring tagged VLAN using DSA on OpenWRT routers with a switch and only a single physical ethernet port.
This was tested on a Xiaomi Redmi AC2100 (MT7621 chipset) running OpenWRT Snapshot from April 19th 2021.
Here's how you make an interface lan3.2
which will send tagged packets on lan port 3. This assumes the lan port 3 interface is called lan3
.
config interface 'pub'
option ifname 'lan3.2'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
This works even if lan3
is a switch port going to eth0
. In ip link
you will see something like:
6: lan3@eth0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN qlen 1000
13: lan3.2@lan3: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state LOWERLAYERDOWN qlen 1000
For a bridge you can just do:
config interface 'pub'
option type 'bridge'
option ifname 'lan3.2'
option proto 'static'
option ipaddr '192.168.1.1'
option netmask '255.255.255.0'
Note that bridge vlan show
gives wrong output.
Here's how to quickly configure a VLAN interface with the ip
utility:
sudo ip link add link enp0s25 name enp0s25.2 type vlan id 2
sudo ip addr add dev enp0s25.2 192.168.1.2/24
sudo ip link set dev enp0s25.2 up
Hello, thanks for your guide. I have also this router; My ISP requires me to have VLAN 6. HOW CAN I do it ? Can I connect the eth. Cable from the ont to my "internet" named connection on this router, and then do the same with config interface "wan" ? Please, I ask you to give me a detailed answer, because I'm a noob in router's stuff... Thanks!!!