@Markster, thanks for your help. I was able to load up the scripts as you suggested and rebooted the router without anything breaking. However, I don't seem to have any internet connectivity on my isolated LAN port. What might be causing the issue?
# Allow packet forwarding between br100 and eth0 (WAN)
iptables -I FORWARD -i br100 -o eth0 -j ACCEPT
ip route
# Allow packet forwarding between br100 and WAN
iptables -I FORWARD -i br100 -o $(nvram get wan0_ifname) -j ACCEPT
# Allow packet forwarding between br100 and WAN
WAN_IF="$1"
iptables -I FORWARD -i br100 -o $WAN_IF -j ACCEPT
Thanks for your suggestion. I am aware about the different WAN and port naming conventions across router models, but they should be the same for a given model right? I have the same router, AC86U as the OP, which is why I decided to try his approach - no guess work adapting other scripts on these forums.Perhaps this rule.
Code:# Allow packet forwarding between br100 and eth0 (WAN) iptables -I FORWARD -i br100 -o eth0 -j ACCEPT
On some routers, perhaps eth0 is the WAN. But NOT on my RT-AC68U. It's vlan2.
I would double-check by dumping the routing table and seeing what the default route says.
Code:ip route
That's why it would be better if the script instead referenced nvram variables. Just safer. Esp. if someone attempts to port this to other routers.
Code:# Allow packet forwarding between br100 and WAN iptables -I FORWARD -i br100 -o $(nvram get wan0_ifname) -j ACCEPT
Or given the fact this is called from the firewall-start script, which passes the WAN network interface as an argument ...
Code:# Allow packet forwarding between br100 and WAN WAN_IF="$1" iptables -I FORWARD -i br100 -o $WAN_IF -j ACCEPT
Thanks for your suggestion. I am aware about the different WAN and port naming conventions across router models, but they should be the same for a given model right? I have the same router, AC86U as the OP, which is why I decided to try his approach - no guess work adapting other scripts on these forums.
Nevertheless, I'd like to try your suggestion about checking via the ip route command. However, I am still learning, so could you please help with some more description? I know how to access the router log in the GUI and can clear it there. Is that the "dumping the routing table" you refer to? And then, where do I enter the ip route command? I'm doing it from terminal bash but no result - do I need to navigate somewhere? Thanks!
admin@lab-merlin1:/tmp/home/root# ip route
192.168.63.1 dev vlan2 proto kernel scope link
10.8.0.0/24 dev tun21 proto kernel scope link src 10.8.0.1
192.168.1.0/24 dev br0 proto kernel scope link src 192.168.1.1
192.168.63.0/24 dev vlan2 proto kernel scope link src 192.168.63.102
192.168.61.0/24 via 192.168.63.1 dev vlan2 metric 1
ifconfig
ip route
brctl show
iptables -vnL INPUT
iptables -vnL FORWARD
iptables -t nat -vnL POSTROUTING
Hello! I have the same AC86U router as the OP, but I need something different. I need to use my WAN port as a LAN, can I get help with that?
I am connected to the internet via a USB modem (4G), but I need to connect 5 devices to one network using a wired cable.
Buy a cheap 4 ports unmanaged switch. Solved.Hello! I have the same AC86U router as the OP, but I need something different. I need to use my WAN port as a LAN, can I get help with that?
I am connected to the internet via a USB modem (4G), but I need to connect 5 devices to one network using a wired cable.
Nowhere in the log does "firewall-start" appear, even though that script is supposed to write to the log.May 5 01:05:15 br100: services-start: creating br100 with LAN PORT 4 (eth1)
May 5 01:05:15 br100: services-start: setting up IPv4 address for br100
May 5 01:05:15 wsdd2[1840]: error: wsdd-mcast-v4: wsd_send_soap_msg: send
May 5 01:05:16 wsdd2[1840]: error: wsdd-mcast-v4: wsd_send_soap_msg: send
and here's the script itself, is there anything wrong with it?XXXXXXX@RT-AC86U-3610:/jffs/scripts# ls
firewall-start nat-start services-start
#!/bin/sh
# For isolating LAN4 (assigned to bridge br100 in services-start
logger -t "br100" “firewall-start: setting up firewall for br100"
# Forbid packets from br100 to be forwarded to other interfaces
iptables -I FORWARD -i br100 -j DROP
logger -t "br100" “firewall-start: allow internet access for br100”
# Allow packet forwarding between br100 and eth0 (WAN)
iptables -I FORWARD -i br100 -o eth0 -j ACCEPT
XXXXXXXX@RT-AC86U-3610:/# ip route
default via XX.XXX.XXX.X dev eth0
XX.XXX.XXX.X dev tun14 proto kernel scope link src XX.XXX.XXX.X
XX.XXX.XXX.X dev tun15 proto kernel scope link src XX.XXX.XXX.X
XX.XXX.XXX.X dev tun12 proto kernel scope link src XX.XXX.XXX.X
XX.XXX.XXX.0/21 dev eth0 proto kernel scope link src [MY PUBLIC IP ADDRESS]
XX.XXX.XXX..1 dev eth0 proto kernel scope link
XX.XXX.XXX.X/8 dev lo scope link
192.168.50.0/24 dev br0 proto kernel scope link src 192.168.50.1
192.168.150.0/24 dev br100 proto kernel scope link src 192.168.150.1
sh -x /jffs/scripts/firewall-start
I ran the iproute command as you suggested and it does seem that eth0 is my WAN. Results below, specific IPs masked. Note I have a few VPN clients running (not currently tunneling isolated LAN port, but I do hope to if I can get this to work)
Code:XXXXXXXX@RT-AC86U-3610:/# ip route default via XX.XXX.XXX.X dev eth0 XX.XXX.XXX.X dev tun14 proto kernel scope link src XX.XXX.XXX.X XX.XXX.XXX.X dev tun15 proto kernel scope link src XX.XXX.XXX.X XX.XXX.XXX.X dev tun12 proto kernel scope link src XX.XXX.XXX.X XX.XXX.XXX.0/21 dev eth0 proto kernel scope link src [MY PUBLIC IP ADDRESS] XX.XXX.XXX..1 dev eth0 proto kernel scope link XX.XXX.XXX.X/8 dev lo scope link 192.168.50.0/24 dev br0 proto kernel scope link src 192.168.50.1 192.168.150.0/24 dev br100 proto kernel scope link src 192.168.150.1
sh -x /jffs/scripts/firewall-start
ASUSWRT-Merlin RT-AC86U 386.3_2 Fri Aug 6 21:48:26 UTC 2021
XXXXXXXXX@RT-AC86U-3610:/tmp/home/root# ip route
default via YY.YYY.YYY.1 dev eth0
10.32.0.82 dev tun14 proto kernel scope link src 10.32.0.81
10.34.0.86 dev tun15 proto kernel scope link src 10.34.0.85
10.35.0.33 dev tun12 proto kernel scope link src 10.35.0.34
YY.YYY.YYY.0/21 dev eth0 proto kernel scope link src [MY PUBLIC IP]
YY.YYY.YYY.1 dev eth0 proto kernel scope link
127.0.0.0/8 dev lo scope link
192.168.50.0/24 dev br0 proto kernel scope link src 192.168.50.1
192.168.150.0/24 dev br100 proto kernel scope link src 192.168.150.1
Chain FORWARD (policy DROP 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
...
0 0 ACCEPT all -- br100 eth0 0.0.0.0/0 0.0.0.0/0
0 0 DROP all -- br100 * 0.0.0.0/0 0.0.0.0/0
If you will have only static IP's on the new LAN you dont need to do anything else. Just assign each client static IP in the new LAN subnet range. For example, if you have configured new segment with "
ifconfig br100 192.168.150.1 netmask 255.255.255.0", just assign clients IP within this IP range. This is all you need.
On the other hand, if you need DHCP for thie new LAN segment add the following code to /jffs/configs/dnsmasq.conf.add and restart dnsmasq.
interface=br100
# DHCPv4 range: 192.168.150.2 - 192.168.150.254, netmask: 255.255.255.0
# DHCPv4 lease time: 86400s (1 day)
dhcp-range=br100,192.168.150.2,192.168.150.254,255.255.255.0,86400s
# DHCPv4 router (option 3): 192.168.150.1
dhcp-option=br100,3,192.168.150.1
CONFIGS_DIR='/jffs/configs'
CONFIG="$CONFIGS_DIR/dnsmasq.conf.add"
mkdir -p $CONFIGS_DIR
create_config() {
cat << "EOF" > $CONFIG
interface=br100
dhcp-range=br100,192.168.150.2,192.168.150.254,255.255.255.0,24h
dhcp-option=br100,3,192.168.150.1
dhcp-option=br100,6,8.8.8.8,8.8.4.4
EOF
}
if [ -f $CONFIG ]; then
echo "error: $CONFIG already exists; requires manual installation"
else
create_config
echo 'Done.'
fi
:
Thanks for this. It ran without error:@dcballers (or anyone else interested)
If you prefer DHCP support, you can simply copy/paste the following script into an ssh window, then reboot.
Code:CONFIGS_DIR='/jffs/configs' CONFIG="$CONFIGS_DIR/dnsmasq.conf.add" mkdir -p $CONFIGS_DIR create_config() { cat << "EOF" > $CONFIG interface=br100 dhcp-range=br100,192.168.150.2,192.168.150.254,255.255.255.0,24h dhcp-option=br100,3,192.168.150.1 dhcp-option=br100,6,8.8.8.8,8.8.4.4 EOF } if [ -f $CONFIG ]; then echo "error: $CONFIG already exists; requires manual installation" else create_config echo 'Done.' fi :
XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root# CONFIGS_DIR='/jffs/configs'
XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root# CONFIG="$CONFIGS_DIR/dnsmasq.conf.add"
XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root#
XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root# mkdir -p $CONFIGS_DIR
XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root#
XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root# create_config() {
> cat << "EOF" > $CONFIG
> interface=br100
> dhcp-range=br100,192.168.150.2,192.168.150.254,255.255.255.0,24h
> dhcp-option=br100,3,192.168.150.1
> dhcp-option=br100,6,8.8.8.8,8.8.4.4
> EOF
> }
XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root#
XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root# if [ -f $CONFIG ]; then
> echo "error: $CONFIG already exists; requires manual installation"
> else
> create_config
> echo 'Done.'
> fi
Done.
:/# sh -x /jffs/scripts/services-start
+ cal port to interface map for RT-AC86U:
/jffs/scripts/services-start: line 1: cal: not found
+ brctl delif br0 eth1
can't delete eth1 from br0: Operation not supported
+ logger -t br100 services-start: creating br100 with LAN PORT 4 (eth1)
+ brctl addbr br100
add bridge failed: Invalid argument
+ brctl stp br100 on
+ brctl addif br100 eth1
can't add eth1 to bridge br100: Operation not supported
+ brctl setfd br100 2
+ 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
Thanks for this. It ran without error:
Code:XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root# CONFIGS_DIR='/jffs/configs' XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root# CONFIG="$CONFIGS_DIR/dnsmasq.conf.add" XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root# XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root# mkdir -p $CONFIGS_DIR XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root# XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root# create_config() { > cat << "EOF" > $CONFIG > interface=br100 > dhcp-range=br100,192.168.150.2,192.168.150.254,255.255.255.0,24h > dhcp-option=br100,3,192.168.150.1 > dhcp-option=br100,6,8.8.8.8,8.8.4.4 > EOF > } XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root# XXXXXXXXXXX@RT-AC86U-3610:/tmp/home/root# if [ -f $CONFIG ]; then > echo "error: $CONFIG already exists; requires manual installation" > else > create_config > echo 'Done.' > fi Done.
And I did a reboot but still no luck. I did the set of ip config commands and as you noted earlier, there's still no packets showing in br100.
I then thought to try and run the nat-start and services-start scripts manually as you had suggested I do with the firewall-start to see if any errors showed up. nat-start ran fine but services-start threw some errors below. What's not clear to me is, are these errors due to the operation already having been run at boot (can't delete eth1 from br0 because it's already been added to br100) or is there something else?
Code::/# sh -x /jffs/scripts/services-start + cal port to interface map for RT-AC86U: /jffs/scripts/services-start: line 1: cal: not found + brctl delif br0 eth1 can't delete eth1 from br0: Operation not supported + logger -t br100 services-start: creating br100 with LAN PORT 4 (eth1) + brctl addbr br100 add bridge failed: Invalid argument + brctl stp br100 on + brctl addif br100 eth1 can't add eth1 to bridge br100: Operation not supported + brctl setfd br100 2 + 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
cat << "EOF" > /jffs/scripts/services-start
#!/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
EOF
chmod +x /jffs/scripts/services-start
:
cat << "EOF" > /jffs/scripts/firewall-start
#!/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
EOF
chmod +x /jffs/scripts/firewall-start
:
cat << "EOF" > /jffs/scripts/services-start
#!/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 4 (eth1)"
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
EOF
chmod +x /jffs/scripts/services-start
:
XXXXX@RT-AC86U-3610:/tmp/home/root# sh -x /jffs/scripts/services-start
+ brctl delif br0 eth1
can't delete eth1 from br0: Operation not supported
+ logger -t br100 services-start: creating br100 with LAN PORTS 4 (eth1)
+ brctl addbr br100
add bridge failed: Invalid argument
+ brctl stp br100 on
+ brctl addif br100 eth1
can't add eth1 to bridge br100: Operation not supported
+ brctl setfd br100 2
+ 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
ifconfig br100 allmulti up
Thanks, I crossed posts with you here. Didn't see this until I already posted my reply. I'm not sure that I want all of the same traffic rules as him with the remote access and some interactions allowed between the bridges that he describes. I suppose I could try this verbatim as proof of concept, but I would like to limit this to just keeping the br100 without any intranet access.Same thing w/ the firewall-start script.
Code:cat << "EOF" > /jffs/scripts/firewall-start #!/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 EOF chmod +x /jffs/scripts/firewall-start :
You shouldn't need the nat-start script, as I indicated in a prior post.
Then reboot and see what you get.
Welcome To SNBForums
SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.
If you'd like to post a question, simply register and have at it!
While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!