1, 在 R4S 侧:为连接到小米路由器的那根网线口(比如 eth1
)创建多个 VLAN 接口:
eth1.10 → VLAN10 英国节点
eth1.20 → VLAN20 美国节点
eth1.30 → VLAN30 德国节点
每个 VLAN 接口走 Passwall 对应节点。
2, 在小米路由器侧:
无线 AP1 绑定 VLAN10
无线 AP2 绑定 VLAN20
无线 AP3 绑定 VLAN30
这样物理网线只有一根,但 VLAN Tag 把流量隔离出来
3, R4S openwrt上的配置文件
假设你的小米路由器那根网线接在 R4S 的 eth1
上,你可以在 /etc/config/network
添加:
config device
option name 'eth1.10'
option type '8021q'
option ifname 'eth1'
option vid '10'
config interface 'vlan10'
option device 'eth1.10'
option proto 'static'
option ipaddr '192.168.10.1'
option netmask '255.255.255.0'
config device
option name 'eth1.20'
option type '8021q'
option ifname 'eth1'
option vid '20'
config interface 'vlan20'
option device 'eth1.20'
option proto 'static'
option ipaddr '192.168.20.1'
option netmask '255.255.255.0'
config device
option name 'eth1.30'
option type '8021q'
option ifname 'eth1'
option vid '30'
config interface 'vlan30'
option device 'eth1.30'
option proto 'static'
option ipaddr '192.168.30.1'
option netmask '255.255.255.0'
这样会在 eth1
上打 VLAN 10、20、30 三个 Tag,分别对应英国 / 美国 / 德国节点。
配置 /etc/config/dhcp
config dhcp 'vlan10'
option interface 'vlan10'
option start '100'
option limit '150'
option leasetime '12h'
config dhcp 'vlan20'
option interface 'vlan20'
option start '100'
option limit '150'
option leasetime '12h'
config dhcp 'vlan30'
option interface 'vlan30'
option start '100'
option limit '150'
option leasetime '12h'
配置 /etc/config/firewall
config zone
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
list network 'vlan10'
list network 'vlan20'
list network 'vlan30'
4, 小米openwrt中的配置
典型端口名:eth0
/eth1
,桥 br-lan
,用 bridge-vlans 管理。
假设你用 LAN1 口接 R4S,这个 LAN1 要作为 trunk(tagged 10/20/30)。
a): /etc/config/network
### 把 lan 口做成桥,并在桥里定义 VLAN
config device
option name 'br-lan'
option type 'bridge'
list ports 'lan1'
list ports 'lan2'
list ports 'lan3'
list ports 'lan4'
# 注:如果你只有 2 个 LAN,就保留实际存在的端口
### 定义 bridge-vlans:把 LAN1 设为 trunk(tagged),其他 LAN 可不承载这些 VLAN(或留空)
config bridge-vlan
option device 'br-lan'
option vlan '10'
list ports 'lan1:t' # trunk:往R4S的这根口
# 如需在本机插线测试 untagged 出 VLAN10,可加 'lan2:u*'
config bridge-vlan
option device 'br-lan'
option vlan '20'
list ports 'lan1:t'
config bridge-vlan
option device 'br-lan'
option vlan '30'
list ports 'lan1:t'
### 给 AP(无线)侧各建一个不带 IP 的接口(桥到对应 VLAN)
config interface 'ap1_vlan10'
option device 'br-lan.10'
option proto 'none' # Unmanaged,不分配IP
config interface 'ap2_vlan20'
option device 'br-lan.20'
option proto 'none'
config interface 'ap3_vlan30'
option device 'br-lan.30'
option proto 'none'
说明:
br-lan.10/20/30
是桥上的 VLAN 子接口。ap*_vlan*
接口用proto none
(Unmanaged),只做二层桥接,不跑 IP。- LAN1 是接 R4S 的干道口(tagged 10/20/30)。你也可以换成 WAN 口,但需要把 WAN 并入
br-lan
,不建议新手这么做。
b): /etc/config/wireless
config wifi-device 'radio0'
option type 'mac80211'
option path 'pci/.../wifi0' # 系统自动生成的就行
option band '5g'
option htmode 'HE80'
option channel 'auto'
option country 'US' # 按需修改法规域
### AP1 → 绑到 VLAN10
config wifi-iface
option device 'radio0'
option mode 'ap'
option ssid 'AP1-UK'
option network 'ap1_vlan10'
option encryption 'psk2'
option key 'yourpassword1'
option isolate '1' # 客户端隔离可选
### AP2 → 绑到 VLAN20
config wifi-iface
option device 'radio0'
option mode 'ap'
option ssid 'AP2-US'
option network 'ap2_vlan20'
option encryption 'psk2'
option key 'yourpassword2'
option isolate '1'
### AP3 → 绑到 VLAN30
config wifi-iface
option device 'radio0'
option mode 'ap'
option ssid 'AP3-DE'
option network 'ap3_vlan30'
option encryption 'psk2'
option key 'yourpassword3'
option isolate '1'
c): /etc/config/dhcp
(关闭本机 DHCP)
config dhcp 'lan'
option interface 'lan'
option ignore '1' # 不在AP上发DHCP
# 可把其它段都忽略
config dhcp 'ap1_vlan10'
option interface 'ap1_vlan10'
option ignore '1'
config dhcp 'ap2_vlan20'
option interface 'ap2_vlan20'
option ignore '1'
config dhcp 'ap3_vlan30'
option interface 'ap3_vlan30'
option ignore '1'
d): /etc/config/firewall
# 作为纯AP,最简单是把防火墙功能整体关掉,或全部接口并入lan,仅作二层桥
config defaults
option syn_flood '1'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
# 清理 wan/masquerade/NAT 等(或直接停用 firewall 服务)
5, 与 R4S 的对接(一定要对应一致)
你之前在 R4S 上已经创建了:eth1.10
(英国)、eth1.20
(美国)、eth1.30
(德国),并在 Passwall 里按接口分流。
小米这边 trunk 口(lan1:t) 就要接到 R4S 的 eth1。
VLAN ID 必须一一对应:
- 小米
AP1 → VLAN 10
↔ R4Seth1.10
- 小米
AP2 → VLAN 20
↔ R4Seth1.20
- 小米
AP3 → VLAN 30
↔ R4Seth1.30
6, 应用与排错
应用配置:
/etc/init.d/network restart
wifi reload
# 或重启整机
常见排错:
- 连接不上某个 SSID → 检查该 SSID 绑定的
network
是否是对应的br-lan.XX/eth0.XX
。 - 终端拿不到 IP → 确认 DHCP 在 R4S 或你指定的地方开启(本机 AP 侧应关闭)。
- VLAN 不通 → 核对干道口两端是否都为 tagged 同一 VLAN ID。
- 只能上默认出口 → 看 R4S 的 Passwall 是否已按 接口/Zone 绑定节点,并允许该 VLAN 接口通过。