Setting up VLAN

I’m using a Flint 2 (GL-MT6000) on the latest firmware (4.11.0). I want to create a new VLAN, bind it to its own SSID, and route that SSID’s traffic through a VPN tunnel, separate from my main and guest networks.

There are several VLAN topics on the forum and in the documentation, but I couldn’t find an official guide that shows how to create a new VLAN, tie it to its own SSID, and route that traffic through a VPN on the Flint 2.

I was hoping to find a single guide that ties all of this together, So far I’ve created the VLAN and set up its netmask and subnet, and I assume the next step would be to get into LuCI.

Hi,

You can follow the steps below to configure Wi-Fi for your custom VLAN.

  1. In our example, the network interface is named vlan20.
  2. Log in to the router via SSH and run the following commands
    This example on a Flint 2 running firmware 4.11.0 and creates Wi-Fi on both 2.4 GHz and 5 GHz.
# Customize these settings
NET='vlan20'
SSID='VLAN20'
WIFI_PASSWORD='ChangeThisPassword123'

# Keep the VLAN bridge available without wired ports
BRIDGE="$(uci -q get "network.${NET}.device")"
for SECTION in $(uci show network | sed -n 's/^network\.\(.*\)=device$/\1/p'); do
    if [ "$(uci -q get "network.${SECTION}.name")" = "$BRIDGE" ] &&
       [ "$(uci -q get "network.${SECTION}.type")" = 'bridge' ]; then
        uci set "network.${SECTION}.bridge_empty=1"
    fi
done

# Create the 2.4 GHz Wi-Fi
uci set wireless.vlan20_2g='wifi-iface'
uci set wireless.vlan20_2g.device='mt798611'
uci set wireless.vlan20_2g.mode='ap'
uci set wireless.vlan20_2g.network="$NET"
uci set wireless.vlan20_2g.ifname='ra4'
uci set wireless.vlan20_2g.ssid="$SSID"
uci set wireless.vlan20_2g.encryption='psk2'
uci set wireless.vlan20_2g.key="$WIFI_PASSWORD"
uci set wireless.vlan20_2g.disabled='0'

# Create the 5 GHz Wi-Fi
uci set wireless.vlan20_5g='wifi-iface'
uci set wireless.vlan20_5g.device='mt798612'
uci set wireless.vlan20_5g.mode='ap'
uci set wireless.vlan20_5g.network="$NET"
uci set wireless.vlan20_5g.ifname='rax4'
uci set wireless.vlan20_5g.ssid="$SSID"
uci set wireless.vlan20_5g.encryption='psk2'
uci set wireless.vlan20_5g.key="$WIFI_PASSWORD"
uci set wireless.vlan20_5g.disabled='0'

unset WIFI_PASSWORD

# Save and reboot
uci commit network
uci commit wireless
sync
reboot
  1. Replace the following settings with your own values.
    Network interface: Replace NET='vlan20' with the network interface associated with your VLAN.
    Wi-Fi SSID: Replace SSID='VLAN20' with your preferred Wi-Fi name.
    Wi-Fi password: Replace WIFI_PASSWORD='ChangeThisPassword123' with your preferred password using 8–63 characters.
    image

After saving the settings and rebooting, the new Wi-Fi will be associated with your custom VLAN.

thank you! I will give it a try and update with result

Hi

Thank you for sharing this! I was facing a very frustrating issue where my wireless interface kept reverting to Client mode instead of functioning in Master (AP) mode bound to the bridge.

Without setting bridge_empty=1 and explicitly matching the MediaTek devices (mt798611/mt798612) and interface names (ra4/rax4) via CLI as shown in your script, GL.iNet's internal background processes would constantly overwrite the wireless config and break the AP setup.

Could you please clarify the exact step-by-step sequence to follow from the very beginning (starting from scratch via SSH, without touching LuCI at all) to properly define the VLAN interface, firewall zones, and then run this script?

I want to make sure I don't miss any prerequisite CLI commands before executing the wireless configuration commands above. Thanks!

Hi, you can use either of the following methods to create the network, then follow the wireless configuration in our earlier reply.

The examples below use a Flint 2 running firmware 4.11, with VLAN ID 20, network interface vlan20, and subnet 192.168.20.0/24.

Option 1: Create the network entirely through SSH

For a new setup, the commands below create the bridge, network interface, DHCP server, and firewall rules for Wi-Fi clients.

Please use an unused VLAN ID and subnet, and run this example when the vlan20 network has not yet been created.

# Back up the existing configuration
umask 077
BACKUP="/root/vlan-backup-$(date +%Y%m%d-%H%M%S)"
mkdir "$BACKUP"
cp -p /etc/config/network /etc/config/dhcp \
  /etc/config/firewall /etc/config/wireless "$BACKUP/"

# Create the network, DHCP server, and firewall rules
uci batch <<'EOF'
set network.bridge_vlan20='device'
set network.bridge_vlan20.name='br-vlan20'
set network.bridge_vlan20.type='bridge'
set network.bridge_vlan20.bridge_empty='1'

set network.vlan20='interface'
set network.vlan20.device='br-vlan20'
set network.vlan20.proto='static'
set network.vlan20.ipaddr='192.168.20.1'
set network.vlan20.netmask='255.255.255.0'
set network.vlan20.display_name='vlan20'
set network.vlan20.vlan_id='20'

set dhcp.vlan20='dhcp'
set dhcp.vlan20.interface='vlan20'
set dhcp.vlan20.start='100'
set dhcp.vlan20.limit='150'
set dhcp.vlan20.leasetime='12h'
set dhcp.vlan20.ignore='0'

set firewall.vlan20='zone'
set firewall.vlan20.name='vlan20'
add_list firewall.vlan20.network='vlan20'
set firewall.vlan20.input='REJECT'
set firewall.vlan20.output='ACCEPT'
set firewall.vlan20.forward='REJECT'

set firewall.vlan20_wan='forwarding'
set firewall.vlan20_wan.src='vlan20'
set firewall.vlan20_wan.dest='wan'

set firewall.vlan20_dhcp='rule'
set firewall.vlan20_dhcp.name='Allow-DHCP-vlan20'
set firewall.vlan20_dhcp.src='vlan20'
set firewall.vlan20_dhcp.proto='udp'
set firewall.vlan20_dhcp.dest_port='67'
set firewall.vlan20_dhcp.family='ipv4'
set firewall.vlan20_dhcp.target='ACCEPT'

set firewall.vlan20_dns='rule'
set firewall.vlan20_dns.name='Allow-DNS-vlan20'
set firewall.vlan20_dns.src='vlan20'
set firewall.vlan20_dns.proto='tcp udp'
set firewall.vlan20_dns.dest_port='53'
set firewall.vlan20_dns.target='ACCEPT'

commit network
commit dhcp
commit firewall
EOF

These rules allow DHCP, DNS, and forwarding to WAN while keeping forwarding to other local firewall zones blocked by default.


Option 2: Create the VLAN through the firmware 4.11 Web interface

Go to NETWORK → LAN, click Add, and enter the following settings.

  • Name :vlan20
  • VLAN ID:20
  • Gateway :192.168.20.1
  • Netmask :255.255.255.0
    The Admin Panel creates the initial network, DHCP, and firewall configuration for this workflow.
    You can refer to the VLAN Networks guide for the Web configuration steps.
    LAN - GL.iNet Router Docs 4

Once the network is created, use the same wireless configuration from our earlier reply, then reboot the router.

Tomorrow i'll try, thank you very much for help.

The script to create the VLAN worked without any issues. Fast forward, after setting up the vpn tunnel and the global policy both are up and running.

Initally, the device(AndroidTV) had a working connection, however the traffic was bypassing the tunnel. I had unplugged and reconnected in between, afterward it wasn't getting internet. At first, I thought the DHCP wasn't able to hand out dns server, but if was true, it wouldn't show an IP and a gateway

I'm kind of wondering what might have happened, few things comes to mind

  • DNS issue, whether it can't reach the upstream queries after switching from “use VPN tunnel” to manual DNS (Quad9)?
    can’t reach, or the upstream queries are going out the WAN and being dropped once traffic is forced into the tunnel.

Current setup:
DNS mode: Using manual DNS, though VPN was initally enabled after config
VPN tu

nnel: Up and running
VPN Policy: From the device, To route all traffic

Security Settings:

  • VLAN AP Isolation: enabled
  • WLAN Access Control: Block WAN Subnet