How to add multiple VLANs over single network interface to Synology DSM

**Update:**This approach works for both Synology DSM version 6.x and 7.x (tested with 6.2 and 7.0). In DSM 7, you won’t see the added network interfaces in the control panel.

I have a Synology NAS running Synology DSM 7. Since I’m running multiple VLANs over a single 10 Gbit/s Ethernet Link, I want the NAS to have multiple sub-network-interfaces. For example, I want it to have not only eth5 (no VLAN) but also eth5.200 for VLAN 200.

In order to do this, I created /usr/local/etc/rc.d/vlan.sh which will be run on NAS startup (most methods described on Synology forums didn’t work for me).

#!/bin/sh
insmod /lib/modules/8021q.ko
ip link del eth5.200

ip link add link eth5 name eth5.200 type vlan id 200
ip addr add 10.82.66.1/24 brd 10.82.66.255 dev eth5.200
ip link set dev eth5.200 up

You will also see those network interfaces in the interface manager (the Synology DSM software will automatically generate config files for them) but they will all be labeled *LAN 5,*so sometimes you have to click through all of them in order to find the correct one.

In order to setup the interfaces, copy the script to /usr/local/etc/rc.d/vlan.sh, then

sudo chmod +x /usr/local/etc/rc.d/vlan.sh

then run it once using

/usr/local/etc/rc.d/vlan.sh

after which (DSM version 6 only!) you need to configure the IP addresses again in the Synology web interface (just like for any normal network interface).

Adding more VLANs is easy, just repeat all the lines except the insmod line, for example:

#!/bin/sh
insmod /lib/modules/8021q.ko
ip link del eth5.200
ip link del eth5.201

ip link add link eth5 name eth5.200 type vlan id 200
ip addr add 10.82.66.1/24 brd 10.82.66.255 dev eth5.200
ip link set dev eth5.200 up

ip link add link eth5 name eth5.201 type vlan id 201
ip addr add 10.82.67.1/24 brd 10.82.67.255 dev eth5.201
ip link set dev eth5.201 up

This approach using vlan.sh turned out to be both reboot-safe and update-safe, although so far I have not performed the upgrade to Synology DSM 7.x