Guest and IoT iptables for DNS, FTP and Web access

Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking
Author Message
coolgoose3
DD-WRT Novice


Joined: 05 Mar 2021
Posts: 20

PostPosted: Wed Apr 14, 2021 0:46    Post subject: Guest and IoT iptables for DNS, FTP and Web access Reply with quote
Old Subject: Firewall/iptables performance/slowness

I have just installed dd-wrt on my DLink DIR-860LA router for the first time.

I had it running for some days and things were fine.

Last weekend, I created two VAPs (wl0.1 and wl0.2) on my 2GHz interface (wl0), using wl0.1 for guest network and wl0.2 for my Automation devices. What I want to achieve is:

  • Guests (on 192.168.2) should have internet access but no access to main network (isolation works well). But:
    * Sometimes guests want to transfer files so I want to allow all access to guests from one machine.
    * I want my DNS server on main LAN to be the DNS server for all guests.
  • Automation devices (on 192.168.3.96-159) should have no access to main network and most of the IPs on Automation subnet should not have internet. But
    * A small set of IPs (192.168.3.96-111) can have internet access just in case some IoT devices cannot work without internet.
    * One computer on my main LAN (192.168.1.105) should have full access to Automation devices so that I could login/configure etc.
    * Automation devices should have FTP access to one IP on main LAN (192.168.1.102) so that they could upload alerts/info.
    * I want my DNS server on main LAN to be the DNS server for Automation devices.


So in order to achieve this, I did

  • AP Isolation and Net Isolation for Guest VAP
  • AP Isolation only for Automation network (blocking all access via iptables)


Code:

root@router:~# nvram show | grep isolat | grep wl0\. | sort -u
size: 41459 bytes (24077 left)
wl0.1_ap_isolate=1
wl0.1_isolation=1
wl0.2_ap_isolate=1
wl0.2_isolation=0
wl0_ap_isolate=0


Here are the iptables rules I am using:
Code:

root@router:~# nvram get rc_firewall
iptables -I FORWARD -s 192.168.1.128/27 -j logdrop
iptables -I FORWARD -s 192.168.1.112/28 -j logdrop
iptables -I FORWARD -i wl0.2 -s 192.168.3.1/24 -j logdrop
iptables -I FORWARD -i wl0.2 -s 192.168.3.96/28 -j ACCEPT
iptables -I FORWARD -i wl0.2 -s 192.168.3.96/28 -d 192.168.2.1/24 -j logdrop
iptables -I FORWARD -i wl0.2 -s 192.168.3.96/28 -d 192.168.1.1/24 -j logdrop
iptables -I FORWARD -i wl0.1 -p tcp -d 192.168.1.5 --dport 53 -j ACCEPT
iptables -I FORWARD -i wl0.1 -p udp -d 192.168.1.5 --dport 53 -j ACCEPT
iptables -I FORWARD -i wl0.1 -p tcp -d 192.168.1.5 --dport 67 -j ACCEPT
iptables -I FORWARD -i wl0.1 -p udp -d 192.168.1.5 --dport 67 -j ACCEPT
iptables -I FORWARD -i wl0.2 -p tcp -d 192.168.1.5 --dport 53 -j ACCEPT
iptables -I FORWARD -i wl0.2 -p udp -d 192.168.1.5 --dport 53 -j ACCEPT
iptables -I FORWARD -i wl0.2 -p tcp -d 192.168.1.5 --dport 67 -j ACCEPT
iptables -I FORWARD -i wl0.2 -p udp -d 192.168.1.5 --dport 67 -j ACCEPT
iptables -I FORWARD -i br0 -o wl0.1 -s 192.168.1.105 -j ACCEPT
iptables -I FORWARD -i br0 -o wl0.2 -s 192.168.1.105 -j ACCEPT
iptables -I FORWARD -i br0 -o wl0.2 -p all -s 192.168.1.102 --dport 80 -j ACCEPT
iptables -I FORWARD -i br0 -o wl0.2 -p all -s 192.168.1.102 --dport 443 -j ACCEPT
iptables -I INPUT -i wl0.2 -p all -d 192.168.1.102 --dport 21 -j ACCEPT
iptables -I FORWARD -i wl0.2 -p all -d 192.168.1.102 --dport 21 -j ACCEPT
iptables -D INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -I INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -D FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
iptables -I FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT


But since adding VAPs, I am experiencing slower network. When I open any website in a browser, it takes a second to connect and then follow up pages load fine. This makes me guess that iptables/firewall is slowing the router down.

Has anyone tried and achieved anything similar using iptables ? Any suggestions to speed up iptables or to debug/diagnose iptables' performance ? (One thing I am thinking of trying is to use multiport match)
Sponsor
coolgoose3
DD-WRT Novice


Joined: 05 Mar 2021
Posts: 20

PostPosted: Thu Apr 15, 2021 1:31    Post subject: Reply with quote
Slowness turned out to be my DNS server. My DNS server was misconfigured and was not able to forward upstream. Now that issue is solved.

But I would still seek any advice anyone may have for iptables for Guest and Automation networks and if anyone has suggestions on performance measurement tools/tips for dd-wrt in general or iptables.
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12881
Location: Netherlands

PostPosted: Thu Apr 15, 2021 7:09    Post subject: Reply with quote
https://wiki.dd-wrt.com/wiki/index.php/Iptables_command

https://pastebin.com/r4u62P0B

_________________
Routers:Netgear R7000, R6400v1, R6400v2, EA6900 (XvortexCFE), E2000, E1200v1, WRT54GS v1.
Install guide R6400v2, R6700v3,XR300:https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=316399
Install guide R7800/XR500: https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=320614
Forum Guide Lines (important read):https://forum.dd-wrt.com/phpBB2/viewtopic.php?t=324087
coolgoose3
DD-WRT Novice


Joined: 05 Mar 2021
Posts: 20

PostPosted: Thu Apr 15, 2021 20:24    Post subject: Reply with quote
egc wrote:
https://wiki.dd-wrt.com/wiki/index.php/Iptables_command

https://pastebin.com/r4u62P0B


Thanks, that helps. I had read the iptables wiki page but the example you posted is a good validation.

A lot of forum posts are talking about VLANs rather than VAPs. I was thinking of going VAP route, for two reasons 1) it does not reserve a physical port on my router for Guest and IoT 2) R8500 WebUI port assignment is not fully functional I read somewhere. Is there an advantage to going VLAN (br1) route that I am missing, as compared to VAP (wl0.1) ? I could still write my firewall rules on wl0.1 rather than br1.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Advanced Networking All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum