D
Deleted member 62525
Guest
It would be great if Asus supported VLAN on their routers for all of us that want a quick way to configure LAN ports isolation.
Until that time this is a quick way to use LAN bridge concepts to provide this functionality. I am using Asus RT-AC86U.
I am sharing here my own setup where I have a primary LAN (192.168.50.0/24) and a separate LAN segment (192.168.150.0/24). This separate and isolated segment is for my home Synology NAS with Plex server and main computer. All other devices, smart phones, printer, smart TV's are on main LAN. My NAS runs PLEX as well and Calendar and Contacts data. These NAS services can be accessed externally. I use duckdns.org as my provider. I am going to focus only on configuring LAN bridge here and provide the code. Modify to your own liking and purpose. The example here is based on this article.
In this example I am creating new LAN bridge (br100) with LAN segment 192.168.150.0/24. Default bridge that comes with the router is br0. You can run the command "brctl show" to have a look. Keep in mind that every Asus router may have different designations for LAN ports, so do your own research before modifying the scripts.
The first script you need is to create new bridge with interfaces and new IP segment. In my case I wanted LAN ports 3 and 4 to be part of the new LAN segment 192.168.150.0/24.
You need to add this script in /jffs/scripts/services-start to create the bridge on each startup. In may case both devices (my PC and NAS ) have static IP's so I do not need or want setup DHCP on the new LAN segment.
Next script is to configure the firewall. In my example you can tell that I am allowing traffic to new LAN segment for Synology NAS and Plex.
Here you can add your own rules as required. You need to call this script from /jffs/scripts/firewall-start so it takes effect on every boot.
Final code is to setup new LAN segment access to internet. Call this script from /jffs/scripts/nat-start
Hope this will help you get started - happy coding!
As a final note about NAS - this configuration combined with duckdns allows me to use Synology NAS as my personal and private cloud to store Calendar, Contacts, Notes, Photos and Music.
Until that time this is a quick way to use LAN bridge concepts to provide this functionality. I am using Asus RT-AC86U.
I am sharing here my own setup where I have a primary LAN (192.168.50.0/24) and a separate LAN segment (192.168.150.0/24). This separate and isolated segment is for my home Synology NAS with Plex server and main computer. All other devices, smart phones, printer, smart TV's are on main LAN. My NAS runs PLEX as well and Calendar and Contacts data. These NAS services can be accessed externally. I use duckdns.org as my provider. I am going to focus only on configuring LAN bridge here and provide the code. Modify to your own liking and purpose. The example here is based on this article.
In this example I am creating new LAN bridge (br100) with LAN segment 192.168.150.0/24. Default bridge that comes with the router is br0. You can run the command "brctl show" to have a look. Keep in mind that every Asus router may have different designations for LAN ports, so do your own research before modifying the scripts.
The first script you need is to create new bridge with interfaces and new IP segment. In my case I wanted LAN ports 3 and 4 to be part of the new LAN segment 192.168.150.0/24.
You need to add this script in /jffs/scripts/services-start to create the bridge on each startup. In may case both devices (my PC and NAS ) have static IP's so I do not need or want setup DHCP on the new LAN segment.
Code:
#!/bin/sh
# Physical port to interface map for RT-AC86U:
# eth0 WAN
# eth1 LAN 4
# eth2 LAN 3
# eth3 LAN 2
# eth4 LAN 1
# eth5 2.4 GHz Radio
# eth6 5 GHz Radio
# Delete those interfaces that we want to isolate from br0
brctl delif br0 eth1
brctl delif br0 eth2
# Create a new bridge br1 for isolated interfaces
logger -t "br100" "services-start: creating br100 with LAN PORTS 3 & 4 (eth1-2)"
brctl addbr br100
brctl stp br100 on # STP to prevent bridge loops
brctl addif br100 eth1
brctl addif br100 eth2
brctl setfd br100 2 # STP Forward Delay 2 sec (Default: 15 sec)
# Set up the IPv4 address for br100
# Here we set the subnet to be 192.168.150.0/24
logger -t "br100" "services-start: setting up IPv4 address for br100"
ifconfig br100 192.168.150.1 netmask 255.255.255.0
ifconfig br100 up
Next script is to configure the firewall. In my example you can tell that I am allowing traffic to new LAN segment for Synology NAS and Plex.
Here you can add your own rules as required. You need to call this script from /jffs/scripts/firewall-start so it takes effect on every boot.
Code:
#!/bin/sh
# Make sure the script is indeed invoked
logger -t "br100" "firewall-start: applying fw rules for br100"
# Allow new incoming connections from br100
iptables -I INPUT -i br100 -m state --state NEW,RELATED,ESTABLISHED -j ACCEPT
# Allow br100 access the web UI and SSH of the main router
iptables -I INPUT -i br100 -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -i br100 -p tcp --dport 443 -j ACCEPT
iptables -I INPUT -i br100 -p tcp --dport [YOUR SSH PORT] -j ACCEPT
# Forbid packets from br100 to be forwarded to other interfaces
iptables -I FORWARD -i br100 -j DROP
# But allow packet forwarding inside br100
iptables -I FORWARD -i br100 -o br100 -j ACCEPT
# Allow packet forwarding between br100 and eth0 (WAN)
iptables -I FORWARD -i br100 -o eth0 -j ACCEPT
# Forbid packets from br0 to be forwarded to br100, isolating new br100 from default br0
iptables -I FORWARD -i br0 -o br100 -j DROP
# But allow one-way traffic from br0 to br100 only for restricted ports - Synology NAS and PLEX
iptables -I FORWARD -i br0 -o br100 -p tcp --match multiport --dports 32400,5001 -j ACCEPT
iptables -I FORWARD -i br100 -o br0 -m state --state RELATED,ESTABLISHED -j ACCEPT
# Drop icmp ping requests to br100
iptables -A OUTPUT -d 192.168.150.1/24 -p icmp --icmp-type echo-request -j DROP
Final code is to setup new LAN segment access to internet. Call this script from /jffs/scripts/nat-start
Code:
#!/bin/sh
# Make sure the script is indeed invoked
logger -t "br100" "nat-start: applying POSTROUTING rules for br100"
iptables -t nat -A POSTROUTING -o eth0 -s 192.168.150.0/24 -j MASQUERADE
Hope this will help you get started - happy coding!
As a final note about NAS - this configuration combined with duckdns allows me to use Synology NAS as my personal and private cloud to store Calendar, Contacts, Notes, Photos and Music.
Last edited by a moderator: