Skip to content

Instantly share code, notes, and snippets.

@Juul
Created April 20, 2021 14:03
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Juul/c86ba881e3a8f747339f53d71c706dac to your computer and use it in GitHub Desktop.
Save Juul/c86ba881e3a8f747339f53d71c706dac to your computer and use it in GitHub Desktop.
Overview of VLAN config on OpenWRT using DSA

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.

Normal linux system using ip utility

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
@rogergithubbing
Copy link

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!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment