Yota
Very Senior Member
Today, I will show you how to set up the same guest network on the primary router and the secondary router, and prevent the guest network from accessing resources on the LAN.
What do I need?
I have two RT-AC68U routers, they both flashed Merlin 384.14_2, One is running router mode, the other one is running in AP mode. I need to set a guest network on the AP, and make sure that the guest network cannot access the devices on my LAN.
If you want to do that, you need to set VLANs. but, asus doesn't support setting the VLAN in the GUI of the firmware, which is very troublesome. however, thanks to this great forum, I used two weeks reading each relevant threads and testing scripts, and now I have achieved some results, I think no one has discussed similar topics, so I will share my results and code.
First, enable the guest network on your Primary router and enable JFFS custom scripts and config. Then create the following, you may need to edit it according to your use case.
Primary router (Router mode)
/jffs/scripts/services-start
Primary router (Router mode)
/jffs/scripts/firewall-start
Primary router (Router mode)
/jffs/configs/dnsmasq.conf.add
Then, set up the same guest network on the secondary router (AP mode), and connect the WAN of the secondary router to the LAN 4 of the primary router. Create the following script for the secondary router
Secondary router (AP Mode)
/jffs/scripts/services-start
Finally restart both routers and you should get a perfect extended guest network. However, it is not a hundred percent perfect. For example, you cannot to PING secondary router from the guest network of the primary router, and vice versa. I don't know how to solve it.
What does the scripts do?
Created a VLAN, added Guest WIFI 5GHz 1 to the VLAN, and passed the VLAN to another one router, and the other router also added Guest WIFI to the VLAN.
Allow DHCP to assign different subnets to the VLAN.
Set up some iptables rules to prevent VLANs from accessing the LAN.
This scripts should work under AiMesh node after modification, but I'm not sure, I haven't tested it.
This scripts may only apply to ARMv7 models, because new models such as RT-AC86U, RT-AX88U do not use these commands to create VLANs, I do not have these models, so I don’t know how to improve it, maybe you can share your improved script.
Thanks for your reply, hope you can provide any comments for this scripts.
References:
VLAN settings in router mode:
https://www.snbforums.com/threads/using-vlans-for-a-2nd-access-point-with-home-guest-wifi.32125/
https://www.snbforums.com/threads/vlans-on-merlin-mini-howto.20529/
https://www.snbforums.com/threads/use-lan-port-4-as-private-network.14983/
https://www.snbforums.com/threads/f...guest-network-for-asus-merlin-rt-ac68u.18969/
https://www.snbforums.com/threads/trying-to-implement-vlans-on-rt-ac3100-in-ap-mode.55822/
https://www.snbforums.com/threads/ssid-to-vlan-only-works-with-open-authentication.55013/
https://www.snbforums.com/threads/merlin-384-5-vlan-dhcp-problem.47780/
https://www.snbforums.com/threads/vlan-problem.36269/
https://www.snbforums.com/threads/v...s-for-1-wireless-client-and-1-lan-port.32808/
https://www.snbforums.com/threads/traffic-across-vlans-for-ip-cams-and-iot-devices.46634/
https://www.snbforums.com/threads/vlan-routing-across-networks.47502/
https://www.snbforums.com/threads/help-on-dhcp-for-custom-bridge.28004/
VLAN settings in ap mode:
https://www.snbforums.com/threads/ssid-to-vlan.24791/
https://www.snbforums.com/threads/wap-guest-ssid-port-based-vlan.12750/
https://www.snbforums.com/threads/help-setting-up-vlan-on-asus-rt-ac68u.49312/
If you use RT-AC86U or AX88U, maybe you are interested to see this link:
https://gist.github.com/Jimmy-Z/6120988090b9696c420385e7e42c64c4
What do I need?
I have two RT-AC68U routers, they both flashed Merlin 384.14_2, One is running router mode, the other one is running in AP mode. I need to set a guest network on the AP, and make sure that the guest network cannot access the devices on my LAN.
If you want to do that, you need to set VLANs. but, asus doesn't support setting the VLAN in the GUI of the firmware, which is very troublesome. however, thanks to this great forum, I used two weeks reading each relevant threads and testing scripts, and now I have achieved some results, I think no one has discussed similar topics, so I will share my results and code.
First, enable the guest network on your Primary router and enable JFFS custom scripts and config. Then create the following, you may need to edit it according to your use case.
Primary router (Router mode)
/jffs/scripts/services-start
Code:
#!/bin/sh
PATH="/sbin:/usr/sbin:/bin:/usr/bin:${PATH}"
robocfg show | grep -i vlan101 > /dev/null 2>&1 || \
(
# Assign a physical port to the VLAN. Note that 5T is a
# RT-AC68U CPU, and different models have different numbers.
robocfg vlan 101 ports "4t 5t"
# I don t understood why to do this,
# looks like setting a VLAN for the WAN.
vconfig add eth0 101
ifconfig vlan101 up
# wl1.1 is Guest WiFi 5GHz 1, I don t enable more SSID,
# so if you want to use it yourself, you may need to edit it.
brctl addbr br1
brctl stp br1 on
brctl delif br0 wl1.1
brctl addif br1 vlan101
brctl addif br1 wl1.1
# Most models use 192.168.50.1 as the default LAN,
# so I use this subnetwork as the guest network.
ifconfig br1 192.168.1.1 netmask 255.255.255.0
ifconfig br1 up
nvram set lan_ifnames="vlan1 eth1 eth2"
nvram set lan_ifname="br0"
nvram set lan1_ifnames="vlan101 wl1.1"
nvram set lan1_ifname="br1"
nvram commit
)
Primary router (Router mode)
/jffs/scripts/firewall-start
Code:
#!/bin/sh
PATH="/sbin:/usr/sbin:/bin:/usr/bin:${PATH}"
# I don t know anything about the rules of iptables and ebtables,
# so I can t guarantee that this setting is safe enough.
# Allow BR1 to access WAN
iptables -D FORWARD -i br1 -m state --state NEW -j ACCEPT >/dev/null 2>&1
iptables -I FORWARD -i br1 -m state --state NEW -j ACCEPT
# Prevent BR1 from accessing BR0 and vice versa
iptables -D FORWARD -i br1 -o br0 -m state --state NEW -j DROP >/dev/null 2>&1
iptables -I FORWARD -i br1 -o br0 -m state --state NEW -j DROP
iptables -D FORWARD -i br0 -o br1 -m state --state NEW -j DROP >/dev/null 2>&1
iptables -I FORWARD -i br0 -o br1 -m state --state NEW -j DROP
# I don t know what it does.
iptables -D INPUT -i br1 -m state --state NEW -j DROP >/dev/null 2>&1
iptables -I INPUT -i br1 -m state --state NEW -j DROP
# Allow DNSMASQ to distribute IP addresses for br1.
iptables -D INPUT -i br1 -p tcp --dport 53 -j ACCEPT >/dev/null 2>&1
iptables -I INPUT -i br1 -p tcp --dport 53 -j ACCEPT
# Allow DNSMASQ to distribute IP addresses for br1.
iptables -D INPUT -i br1 -p udp -m multiport --dport 53,67 -j ACCEPT >/dev/null 2>&1
iptables -I INPUT -i br1 -p udp -m multiport --dport 53,67 -j ACCEPT
sleep 1
killall eapd
eapd
Primary router (Router mode)
/jffs/configs/dnsmasq.conf.add
Code:
interface=br1
dhcp-range=br1,192.168.1.2,192.168.1.254,255.255.255.0,86400s
dhcp-option=br1,3,192.168.1.1
dhcp-option=br1,6,192.168.1.1
Then, set up the same guest network on the secondary router (AP mode), and connect the WAN of the secondary router to the LAN 4 of the primary router. Create the following script for the secondary router
Secondary router (AP Mode)
/jffs/scripts/services-start
Code:
#!/bin/sh
PATH="/sbin:/usr/sbin:/bin:/usr/bin:${PATH}"
robocfg show | grep -i vlan101 > /dev/null 2>&1 || \
(
robocfg vlan 101 ports "0t 5t"
vconfig add eth0 101
ifconfig vlan101 up
brctl addbr br1
brctl delif br0 wl1.1
brctl addif br1 vlan101
brctl addif br1 wl1.1
ifconfig br1 up
nvram set lan_ifnames="vlan1 eth1 eth2"
nvram set lan_ifname="br0"
nvram set lan1_ifnames="vlan101 wl1.1"
nvram set lan1_ifname="br1"
nvram commit
killall eapd
eapd
)
Finally restart both routers and you should get a perfect extended guest network. However, it is not a hundred percent perfect. For example, you cannot to PING secondary router from the guest network of the primary router, and vice versa. I don't know how to solve it.
What does the scripts do?
Created a VLAN, added Guest WIFI 5GHz 1 to the VLAN, and passed the VLAN to another one router, and the other router also added Guest WIFI to the VLAN.
Allow DHCP to assign different subnets to the VLAN.
Set up some iptables rules to prevent VLANs from accessing the LAN.
Code:
╲ ╱ ╲ ╱
Guest WiFi LAN WiFi Guest WiFi LAN WiFi
╲ ╱ ╲ ╱
│─────────│ │─────────│
│ Router │──────────────│ AP │
│─────────│ LAN&VLAN │─────────│
This scripts should work under AiMesh node after modification, but I'm not sure, I haven't tested it.
This scripts may only apply to ARMv7 models, because new models such as RT-AC86U, RT-AX88U do not use these commands to create VLANs, I do not have these models, so I don’t know how to improve it, maybe you can share your improved script.
Thanks for your reply, hope you can provide any comments for this scripts.
References:
VLAN settings in router mode:
https://www.snbforums.com/threads/using-vlans-for-a-2nd-access-point-with-home-guest-wifi.32125/
https://www.snbforums.com/threads/vlans-on-merlin-mini-howto.20529/
https://www.snbforums.com/threads/use-lan-port-4-as-private-network.14983/
https://www.snbforums.com/threads/f...guest-network-for-asus-merlin-rt-ac68u.18969/
https://www.snbforums.com/threads/trying-to-implement-vlans-on-rt-ac3100-in-ap-mode.55822/
https://www.snbforums.com/threads/ssid-to-vlan-only-works-with-open-authentication.55013/
https://www.snbforums.com/threads/merlin-384-5-vlan-dhcp-problem.47780/
https://www.snbforums.com/threads/vlan-problem.36269/
https://www.snbforums.com/threads/v...s-for-1-wireless-client-and-1-lan-port.32808/
https://www.snbforums.com/threads/traffic-across-vlans-for-ip-cams-and-iot-devices.46634/
https://www.snbforums.com/threads/vlan-routing-across-networks.47502/
https://www.snbforums.com/threads/help-on-dhcp-for-custom-bridge.28004/
VLAN settings in ap mode:
https://www.snbforums.com/threads/ssid-to-vlan.24791/
https://www.snbforums.com/threads/wap-guest-ssid-port-based-vlan.12750/
https://www.snbforums.com/threads/help-setting-up-vlan-on-asus-rt-ac68u.49312/
If you use RT-AC86U or AX88U, maybe you are interested to see this link:
https://gist.github.com/Jimmy-Z/6120988090b9696c420385e7e42c64c4
Last edited: