asus-ac86u配置vlan

预置条件

1.系统设置里面打开: Enable JFFS custom scripts and configs
2.开机自启需要把脚本重命名为: /jffs/scripts/services-start
3.ac86u网络接口和物理网口对应关系:
eth0 --> wan
eth1 --> lan4
eth2 --> lan3
eth3 --> lan2
eth4 --> lan1
eth5 --> 无线2.4G
eth6 --> 无线5G
wl0.1 --> 访客12.4G
wl1.1 --> 访客15G
wl0.2 --> 访客22.4G
wl1.2 --> 访客25G
wl0.3 --> 访客32.4G
wl1.3 --> 访客35G

vlan配置脚本

#!/bin/sh

# 添加并且使能vlan接口(vlanId分别为: 45、100)
ip link add link eth0 name vlan45 type vlan id 45
ip link set vlan45 up

ip link add link eth0 name vlan100 type vlan id 100
ip link set vlan100 up

# 添加并且使能网桥(br0是自带的, 不用添加)
brctl addbr br1
ip link set br1 up

# 从br0网桥中删除不属于它的接口, eth6对应无线5G
brctl delif br0 eth6

# 把vlan45添加到网桥br0
brctl addif br0 vlan45

# 把eth6接口和vlan100添加到新网桥br1
brctl addif br1 vlan100
brctl addif br1 eth6

# seems like eapd reads config from these
# no need to set lan_ifname since it's already there
nvram set lan_ifnames="eth0 eth1 eth2 eth3 eth4 eth5 vlan45"
#下面这一行br0的可以不用
nvram set lan_ifname="br0"
nvram set br0_ifnames="eth0 eth1 eth2 eth3 eth4 eth5 vlan45"
#下面这一行br0的可以不用
nvram set br0_ifname="br0"

nvram set lan1_ifnames="eth6 vlan100"
nvram set lan1_ifname="br1"
nvram set br1_ifnames="eth6 vlan100"
nvram set br1_ifname="br1"

# is there a better way to do this like `service restart eapd` ?
killall eapd
eapd
参考文章: 
https://www.bilibili.com/read/cv18920654
https://gist.github.com/Jimmy-Z/6120988090b9696c420385e7e42c64c4
https://www.snbforums.com/threads/setting-up-vlans-on-ac68p.65588