[SOLVED] Remote management IP range restriction no effect.

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Author Message
Jay689
DD-WRT Novice


Joined: 02 May 2011
Posts: 7

PostPosted: Sat Mar 11, 2023 3:51    Post subject: [SOLVED] Remote management IP range restriction no effect. Reply with quote
Router/Version: Netgear R6300v2
File/Kernel: v3.0-r51976 std (03/08/23)
Previous/Reset: upgraded from a 2019 build, already 30-30-30 as well as web gui reset
Mode/Status: Gateway mode, WAN is tied to 5G wifi Client mode DHCP, LAN + 2.4G wifi AP mode static address different from WAN
Issues/Errors: remote management - allow any IP doesn't seem to work correctly when set to disable

When allow-any-ip is set to disable, it reveals the option to enter what IP range allowed.
It doesn't seem to impose any restriction by the IP entered.
Once remote management enabled, it's enabled for all.

If I disable remote management, but turn off SPI firewall, then anyone can remote it too (this one is understandable since firewall is off; but I thought they could be two separate functions)

The WAN is 192.168.2.105/24
the LAN is 10.0.0.1/24
The admin computer is in another net 192.168.1.0/24

If I disable allow-any-ip, and enter allow only 192.168.1.170-180,
save, apply, wait for the 5G client link to re-connect,
then try to connect to the web gui from 192.168.2.0/24 network, it goes through.

the WAN is technically within the same net of any other 192.168.2.x/24 hosts, so I'm guessing this isn't really remote; unsure if this is the expected behavior. Perhaps the remote has to be in a different net for the firewall to consider it remote?

Then I tried to connect from 192.168.1.160 (still not within the allowed 170~180 range), but it goes through too.

So I'm a little lost now..
Looks like the IP range restriction just has no effect.
Sponsor
dale_gribble39
DD-WRT Guru


Joined: 11 Jun 2022
Posts: 1932

PostPosted: Sat Mar 11, 2023 5:42    Post subject: Reply with quote
With your intended remote management configuration, presuming it is ssh or http(s), what is the output of iptables -vnL? Remote management should add firewall rules. Only possible bug would be if the wireless interface used as WAN is somehow not correctly tied to the proper interface for the firewall to work properly.
_________________
"The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep." - Robert Frost

"I am one of the noticeable ones - notice me" - Dale Frances McKenzie Bozzio

<fact>code knows no gender</fact>

This is me, knowing I've ruffled your feathers, and not giving a ****
Some people are still hard-headed.

--------------------------------------
Mac Pro (Mid 2012) - Two 2.4GHz 6-Core Intel Xeon E5645 processors 64GB 1333MHz DDR3 ECC SDRAM OpenSUSE Leap 15.5
Jay689
DD-WRT Novice


Joined: 02 May 2011
Posts: 7

PostPosted: Sat Mar 11, 2023 5:57    Post subject: Reply with quote
[quote="what is the output of iptables -vnL?[/quote]

Code:
Chain INPUT (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
  216 34690 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0            state INVALID
    0     0 ACCEPT     udp  --  eth2   *       0.0.0.0/0            0.0.0.0/0            udp spt:67 dpt:68
   23  1196 ACCEPT     tcp  --  eth2   *       0.0.0.0/0            10.0.0.1             tcp dpt:443
    0     0 ACCEPT     icmp --  eth2   *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     2    --  eth2   *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     tcp  --  eth2   *       0.0.0.0/0            0.0.0.0/0            tcp dpt:113
    2   120 ACCEPT     all  --  lo     *       0.0.0.0/0            0.0.0.0/0            state NEW
    6   192 ACCEPT     all  --  br0    *       0.0.0.0/0            0.0.0.0/0            state NEW
    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0           

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
    0     0 DROP       tcp  --  *      eth2   !192.168.2.105        0.0.0.0/0            state INVALID
    0     0 upnp       all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 lan2wan    all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     all  --  br0    br0     0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     tcp  --  *      eth2    10.0.0.0/24          0.0.0.0/0            tcp dpt:1723
    0     0 ACCEPT     47   --  *      eth2    10.0.0.0/24          0.0.0.0/0           
    0     0 ACCEPT     udp  --  eth2   *       0.0.0.0/0            224.0.0.0/4         
    0     0 TRIGGER    all  --  eth2   br0     0.0.0.0/0            0.0.0.0/0           TRIGGER type:in match:0 relate:0
    0     0 trigger_out  all  --  br0    *       0.0.0.0/0            0.0.0.0/0           
    0     0 TRIGGER    all  --  eth2   eth0    0.0.0.0/0            0.0.0.0/0           TRIGGER type:in match:0 relate:0
    0     0 trigger_out  all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0            state NEW
    0     0 TRIGGER    all  --  eth2   eth1    0.0.0.0/0            0.0.0.0/0           TRIGGER type:in match:0 relate:0
    0     0 trigger_out  all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0            state NEW
    0     0 TRIGGER    all  --  eth2   vlan1   0.0.0.0/0            0.0.0.0/0           TRIGGER type:in match:0 relate:0
    0     0 trigger_out  all  --  vlan1  *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     all  --  vlan1  *       0.0.0.0/0            0.0.0.0/0            state NEW
    0     0 ACCEPT     all  --  br0    *       0.0.0.0/0            0.0.0.0/0            state NEW
    0     0 DROP       all  --  *      *       0.0.0.0/0            0.0.0.0/0     


It's the same for allow-any-ip enabled, or disabled with an IP entered.



remote management.jpg
 Description:
 Filesize:  33.96 KB
 Viewed:  689 Time(s)

remote management.jpg


Jay689
DD-WRT Novice


Joined: 02 May 2011
Posts: 7

PostPosted: Sat Mar 11, 2023 6:04    Post subject: Reply with quote
It doesn't show any entry with the address 192.168.1.175-178 as I entered.
I run that command after save and apply, no change,
then re-run after a reboot, still the same.

firewall disabled, but entered an address for remote management:
Code:
Chain INPUT (policy ACCEPT 58 packets, 9626 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 DROP       tcp  --  eth2   *       0.0.0.0/0            0.0.0.0/0            tcp dpt:22
    0     0 DROP       tcp  --  eth2   *       0.0.0.0/0            0.0.0.0/0            tcp dpt:23

Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 ACCEPT     all  --  *      *       0.0.0.0/0            0.0.0.0/0            state RELATED,ESTABLISHED
    0     0 DROP       tcp  --  *      eth2   !192.168.2.105        0.0.0.0/0            state INVALID
    0     0 upnp       all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 lan2wan    all  --  *      *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     all  --  br0    br0     0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     udp  --  eth2   *       0.0.0.0/0            224.0.0.0/4         
    0     0 TRIGGER    all  --  eth2   br0     0.0.0.0/0            0.0.0.0/0           TRIGGER type:in match:0 relate:0
    0     0 trigger_out  all  --  br0    *       0.0.0.0/0            0.0.0.0/0           
    0     0 TRIGGER    all  --  eth2   eth0    0.0.0.0/0            0.0.0.0/0           TRIGGER type:in match:0 relate:0
    0     0 trigger_out  all  --  eth0   *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     all  --  eth0   *       0.0.0.0/0            0.0.0.0/0            state NEW
    0     0 TRIGGER    all  --  eth2   eth1    0.0.0.0/0            0.0.0.0/0           TRIGGER type:in match:0 relate:0
    0     0 trigger_out  all  --  eth1   *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     all  --  eth1   *       0.0.0.0/0            0.0.0.0/0            state NEW
    0     0 TRIGGER    all  --  eth2   vlan1   0.0.0.0/0            0.0.0.0/0           TRIGGER type:in match:0 relate:0
    0     0 trigger_out  all  --  vlan1  *       0.0.0.0/0            0.0.0.0/0           
    0     0 ACCEPT     all  --  vlan1  *       0.0.0.0/0            0.0.0.0/0            state NEW
    0     0 ACCEPT     all  --  br0    *       0.0.0.0/0            0.0.0.0/0            state NEW



eth2 seems to be the 5G wifi WAN, accepting tcp 443 for https.

Actually, I now realized that with the firewall enabled,
I can't even reach it via the WAN address.
For now with firewall enabled (but all the boxes unchecked),
I can only reach the web gui via the 10.0.0.1 address, either while connected to the 10.0.0.0/24 LAN, or from another net with policy routing and set gateway to the WAN of the client router (the 5G wifi WAN IP 192.168.2.105).[/code]
Jay689
DD-WRT Novice


Joined: 02 May 2011
Posts: 7

PostPosted: Sat Mar 11, 2023 7:15    Post subject: Reply with quote
Basically either no remote management, or remote management for all while firewall disabled.

With firewall enabled, only the LAN side is reachable.
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12881
Location: Netherlands

PostPosted: Sat Mar 11, 2023 8:53    Post subject: Reply with quote
It should be in the DNAT rule
I use range from 192.168.0.59 to 61

Code:
root@EA6900:~# iptables -vnL -t nat
Chain PREROUTING (policy ACCEPT 247 packets, 55145 bytes)
    1    52 DNAT       tcp  --  *      *       192.168.0.59         192.168.0.13         tcp dpt:22 to:192.168.13.1:22
    0     0 DNAT       tcp  --  *      *       192.168.0.60/31      192.168.0.13         tcp dpt:22 to:192.168.13.1:22


Connecting from 192.168.0.58 so outside this range is blocked.

So it works for me and allowing traffic in range and not outside this range

Note if you disable the firewall you do not need remote management just set a static route on the main router and you can connect to the router itself.

But as you are connection your WAN wirelessly (which is kind of a hack) all bets are off Sad

_________________
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


Last edited by egc on Sat Mar 11, 2023 9:20; edited 2 times in total
Alozaros
DD-WRT Guru


Joined: 16 Nov 2015
Posts: 6436
Location: UK, London, just across the river..

PostPosted: Sat Mar 11, 2023 8:53    Post subject: Reply with quote
have look here:

cat /tmp/.ipt

_________________
Atheros
TP-Link WR740Nv1 ---DD-WRT 55630 WAP
TP-Link WR1043NDv2 -DD-WRT 55723 Gateway/DoT,Forced DNS,Ad-Block,Firewall,x4VLAN,VPN
TP-Link WR1043NDv2 -Gargoyle OS 1.15.x AP,DNS,QoS,Quotas
Qualcomm-Atheros
Netgear XR500 --DD-WRT 55779 Gateway/DoH,Forced DNS,AP Isolation,4VLAN,Ad-Block,Firewall,Vanilla
Netgear R7800 --DD-WRT 55819 Gateway/DoT,AD-Block,Forced DNS,AP&Net Isolation,x3VLAN,Firewall,Vanilla
Netgear R9000 --DD-WRT 55779 Gateway/DoT,AD-Block,AP Isolation,Firewall,Forced DNS,x2VLAN,Vanilla
Broadcom
Netgear R7000 --DD-WRT 55460 Gateway/SmartDNS/DoH,AD-Block,Firewall,Forced DNS,x3VLAN,VPN
NOT USING 5Ghz ANYWHERE
------------------------------------------------------
Stubby DNS over TLS I DNSCrypt v2 by mac913
Jay689
DD-WRT Novice


Joined: 02 May 2011
Posts: 7

PostPosted: Sat Mar 11, 2023 10:59    Post subject: Reply with quote
Alozaros wrote:
have look here:

cat /tmp/.ipt


Code:
*mangle
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu
COMMIT
*nat
:PREROUTING ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -i br0 -p udp --dport 53 -j DNAT --to 10.0.0.1
-A PREROUTING -i br0 -p tcp --dport 53 -j DNAT --to 10.0.0.1
-A PREROUTING -p tcp -d 192.168.2.105 --dport 8080 -j DNAT --to-destination 10.0.0.1:443
-A PREROUTING -p icmp -d 192.168.2.105 -j DNAT --to-destination 10.0.0.1
-A PREROUTING -d 192.168.2.105 -j TRIGGER --trigger-type dnat
-A POSTROUTING -s 10.0.0.1/24 -o eth2 -j SNAT --to-source 192.168.2.105
-A POSTROUTING -o br0 -m pkttype --pkt-type broadcast -j RETURN
-A POSTROUTING -o br0 -s 10.0.0.1/24 -d 10.0.0.1/24 -j MASQUERADE
COMMIT
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]

:trigger_out - [0:0]
:upnp - [0:0]
:lan2wan - [0:0]
:grp_1 - [0:0]
:advgrp_1 - [0:0]
:grp_2 - [0:0]
:advgrp_2 - [0:0]
:grp_3 - [0:0]
:advgrp_3 - [0:0]
:grp_4 - [0:0]
:advgrp_4 - [0:0]
:grp_5 - [0:0]
:advgrp_5 - [0:0]
:grp_6 - [0:0]
:advgrp_6 - [0:0]
:grp_7 - [0:0]
:advgrp_7 - [0:0]
:grp_8 - [0:0]
:advgrp_8 - [0:0]
:grp_9 - [0:0]
:advgrp_9 - [0:0]
:grp_10 - [0:0]
:advgrp_10 - [0:0]
:grp_11 - [0:0]
:advgrp_11 - [0:0]
:grp_12 - [0:0]
:advgrp_12 - [0:0]
:grp_13 - [0:0]
:advgrp_13 - [0:0]
:grp_14 - [0:0]
:advgrp_14 - [0:0]
:grp_15 - [0:0]
:advgrp_15 - [0:0]
:grp_16 - [0:0]
:advgrp_16 - [0:0]
:grp_17 - [0:0]
:advgrp_17 - [0:0]
:grp_18 - [0:0]
:advgrp_18 - [0:0]
:grp_19 - [0:0]
:advgrp_19 - [0:0]
:grp_20 - [0:0]
:advgrp_20 - [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -m state --state INVALID -j DROP
-A INPUT -i eth2 -p udp --sport 67 --dport 68 -j ACCEPT
-A INPUT -i eth2 -p tcp -d 10.0.0.1 --dport 443 -j ACCEPT
-A INPUT -i eth2 -p icmp -j ACCEPT
-A INPUT -i eth2 -p igmp -j ACCEPT
-A INPUT -i eth2 -p tcp --dport 113 -j ACCEPT
-A INPUT -i lo -m state --state NEW -j ACCEPT
-A INPUT -i br0 -m state --state NEW -j ACCEPT
-A INPUT -j DROP
-A FORWARD -m state --state RELATED,ESTABLISHED -j ACCEPT
-A FORWARD ! -s 192.168.2.105 -o eth2 -p tcp -m state --state INVALID -j DROP
-A FORWARD -j upnp
-A FORWARD -j lan2wan
-A FORWARD -i br0 -o br0 -j ACCEPT
-A FORWARD -o eth2 -s 10.0.0.1/24 -p tcp --dport 1723 -j ACCEPT
-A FORWARD -o eth2 -s 10.0.0.1/24 -p gre -j ACCEPT
-A FORWARD -i eth2 -p udp --destination 224.0.0.0/4 -j ACCEPT
-A FORWARD -i eth2 -o br0 -j TRIGGER --trigger-type in
-A FORWARD -i br0 -j trigger_out
-A FORWARD -i eth2 -o eth0 -j TRIGGER --trigger-type in
-A FORWARD -i eth0 -j trigger_out
-A FORWARD -i eth0 -m state --state NEW -j ACCEPT
-A FORWARD -i eth2 -o eth1 -j TRIGGER --trigger-type in
-A FORWARD -i eth1 -j trigger_out
-A FORWARD -i eth1 -m state --state NEW -j ACCEPT
-A FORWARD -i eth2 -o vlan1 -j TRIGGER --trigger-type in
-A FORWARD -i vlan1 -j trigger_out
-A FORWARD -i vlan1 -m state --state NEW -j ACCEPT
-A FORWARD -i br0 -m state --state NEW -j ACCEPT
-A FORWARD -j DROP
COMMIT


okay, guessing my brain hadn't waked up..
Just realized I forgot the :8080 when trying to connect via the WAN address, as the internal and external https use different port numbers. Don't know why I were blind on that 8080 just above the IP setting. (was on the LAN side during initial setup, then moved to the WAN side and simply changed address, forgot to add the :8080 or change the default 8080 port to 443) duh.. Embarassed


egc wrote:
It should be in the DNAT rule

Yup, you got it; I've also changed the default remote management port 8080 to 443 too just in case Embarassed

Code:
Chain PREROUTING (policy ACCEPT 6 packets, 312 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 DNAT       udp  --  br0    *       0.0.0.0/0            0.0.0.0/0            udp dpt:53 to:10.0.0.1
    0     0 DNAT       tcp  --  br0    *       0.0.0.0/0            0.0.0.0/0            tcp dpt:53 to:10.0.0.1
   25  1300 DNAT       tcp  --  *      *       192.168.1.175        192.168.2.105        tcp dpt:443 to:10.0.0.1:443
    0     0 DNAT       tcp  --  *      *       192.168.1.176/31     192.168.2.105        tcp dpt:443 to:10.0.0.1:443
    0     0 DNAT       tcp  --  *      *       192.168.1.178        192.168.2.105        tcp dpt:443 to:10.0.0.1:443
    1    60 DNAT       icmp --  *      *       0.0.0.0/0            192.168.2.105        to:10.0.0.1
    0     0 TRIGGER    all  --  *      *       0.0.0.0/0            192.168.2.105       TRIGGER type:dnat match:0 relate:0

Chain INPUT (policy ACCEPT 32 packets, 1672 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain OUTPUT (policy ACCEPT 6 packets, 320 bytes)
 pkts bytes target     prot opt in     out     source               destination         

Chain POSTROUTING (policy ACCEPT 6 packets, 320 bytes)
 pkts bytes target     prot opt in     out     source               destination         
    0     0 SNAT       all  --  *      eth2    10.0.0.0/24          0.0.0.0/0            to:192.168.2.105
    0     0 RETURN     all  --  *      br0     0.0.0.0/0            0.0.0.0/0            PKTTYPE = broadcast
    0     0 MASQUERADE  all  --  *      br0     10.0.0.0/24          10.0.0.0/24     


The commands are super useful,
working as expected now,
Thanks a lot for all the tips Wink
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware 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 can attach files in this forum
You can download files in this forum