Secure a Client Machine on a vlan?

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


Joined: 31 Mar 2023
Posts: 1

PostPosted: Fri Mar 31, 2023 14:36    Post subject: Secure a Client Machine on a vlan? Reply with quote
Dear Forum.

I want to secure a client device on its own port (vlan6, br4, port 4) and to be isolated from the rest of the network.

I also want to only allow this client device to communicate with a group of whitelisted urls.


Router Model - TP-Link Archer C9
Firmware Version - DD-WRT v3.0-r44715 std (11/03/20)

My set up.
vlan2 = (WAN Internet)
port 1 = br0 = vlan1 eth1 = for desktop and admin
port 2 = br4 = vlan4 = for e.g. CCTV
port 3 = br5 = vlan5 = for e.g. WiFi
port 4 = br6 = vlan6 = for client device

Interface br4 -: IP 192.168.4.1/255.255.255.0
Interface br5 -: IP 192.168.5.1/255.255.255.0
Interface br6 -: IP 192.168.6.1/255.255.255.0

I want all bridges to have access to internet, but to be isolated from each other. Thus my firewall rules are:

# block anything that falls through (just a precaution)
iptables -I FORWARD -i br+ -o br+ -m state --state NEW -j REJECT
# deny isolate networks access to any other networks
iptables -I FORWARD -i br4 -o br+ -m state --state NEW -j REJECT
iptables -I FORWARD -i br5 -o br+ -m state --state NEW -j REJECT
iptables -I FORWARD -i br6 -o br+ -m state --state NEW -j REJECT

# allow MAIN network access to any other networks for admin
iptables -I FORWARD -i br0 -o br0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I FORWARD -i br0 -o br4 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I FORWARD -i br0 -o br5 -m state --state ESTABLISHED,RELATED -j ACCEPT


Now to only allow br6 to talk to a group of whitelisted urls (bbc.co.uk) i have added to the firewall:

iptables -I FORWARD -i br6 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I FORWARD -i br6 -d ! bbc.co.uk -j DROP

My iptables output looks like this:
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- br6 * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED


I have also tried:
iptables -I FORWARD -i br6 -s 192.168.6.101 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I FORWARD -i br6 -s 192.168.6.101 -d ! bbc.co.uk -j DROP

My iptables output is:
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- br6 * 192.168.6.101 0.0.0.0/0 state RELATED,ESTABLISHED

When I remove the not ! command:

iptables -I FORWARD -i br6 -s 192.168.6.101 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I FORWARD -i br6 -s 192.168.6.101 -d bbc.co.uk -j DROP

My output is:
pkts bytes target prot opt in out source destination
0 0 DROP all -- br6 * 192.168.6.101 151.101.192.81
0 0 DROP all -- br6 * 192.168.6.101 151.101.128.81
0 0 DROP all -- br6 * 192.168.6.101 151.101.64.81
0 0 DROP all -- br6 * 192.168.6.101 151.101.0.81
0 0 ACCEPT all -- br6 * 192.168.6.101 0.0.0.0/0 state RELATED,ESTABLISHED

The rules seem to be applied

Can anyone help with executing the ! rule?

Or is there an alternative method to achieve the same.

Many thanks for your help in advance.
Sponsor
dale_gribble39
DD-WRT Guru


Joined: 11 Jun 2022
Posts: 1941

PostPosted: Fri Mar 31, 2023 14:37    Post subject: Reply with quote
https://ftp.dd-wrt.com/dd-wrtv2/downloads/betas/2023/
_________________
"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
egc
DD-WRT Guru


Joined: 18 Mar 2014
Posts: 12889
Location: Netherlands

PostPosted: Fri Mar 31, 2023 15:12    Post subject: Re: Secure a Client Machine on a vlan? Reply with quote
bongo1129 wrote:
Dear Forum.

I want to secure a client device on its own port (vlan6, br4, port 4) and to be isolated from the rest of the network.

I also want to only allow this client device to communicate with a group of whitelisted urls.


Router Model - TP-Link Archer C9
Firmware Version - DD-WRT v3.0-r44715 std (11/03/20)

My set up.
vlan2 = (WAN Internet)
port 1 = br0 = vlan1 eth1 = for desktop and admin
port 2 = br4 = vlan4 = for e.g. CCTV
port 3 = br5 = vlan5 = for e.g. WiFi
port 4 = br6 = vlan6 = for client device

Interface br4 -: IP 192.168.4.1/255.255.255.0
Interface br5 -: IP 192.168.5.1/255.255.255.0
Interface br6 -: IP 192.168.6.1/255.255.255.0

I want all bridges to have access to internet, but to be isolated from each other. Thus my firewall rules are:

# block anything that falls through (just a precaution)
iptables -I FORWARD -i br+ -o br+ -m state --state NEW -j REJECT
# deny isolate networks access to any other networks
iptables -I FORWARD -i br4 -o br+ -m state --state NEW -j REJECT
iptables -I FORWARD -i br5 -o br+ -m state --state NEW -j REJECT
iptables -I FORWARD -i br6 -o br+ -m state --state NEW -j REJECT

# allow MAIN network access to any other networks for admin
iptables -I FORWARD -i br0 -o br0 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I FORWARD -i br0 -o br4 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I FORWARD -i br0 -o br5 -m state --state ESTABLISHED,RELATED -j ACCEPT


Now to only allow br6 to talk to a group of whitelisted urls (bbc.co.uk) i have added to the firewall:

iptables -I FORWARD -i br6 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I FORWARD -i br6 -d ! bbc.co.uk -j DROP

My iptables output looks like this:
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- br6 * 0.0.0.0/0 0.0.0.0/0 state RELATED,ESTABLISHED


I have also tried:
iptables -I FORWARD -i br6 -s 192.168.6.101 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I FORWARD -i br6 -s 192.168.6.101 -d ! bbc.co.uk -j DROP

My iptables output is:
pkts bytes target prot opt in out source destination
0 0 ACCEPT all -- br6 * 192.168.6.101 0.0.0.0/0 state RELATED,ESTABLISHED

When I remove the not ! command:

iptables -I FORWARD -i br6 -s 192.168.6.101 -m state --state ESTABLISHED,RELATED -j ACCEPT
iptables -I FORWARD -i br6 -s 192.168.6.101 -d bbc.co.uk -j DROP

My output is:
pkts bytes target prot opt in out source destination
0 0 DROP all -- br6 * 192.168.6.101 151.101.192.81
0 0 DROP all -- br6 * 192.168.6.101 151.101.128.81
0 0 DROP all -- br6 * 192.168.6.101 151.101.64.81
0 0 DROP all -- br6 * 192.168.6.101 151.101.0.81
0 0 ACCEPT all -- br6 * 192.168.6.101 0.0.0.0/0 state RELATED,ESTABLISHED

The rules seem to be applied

Can anyone help with executing the ! rule?

Or is there an alternative method to achieve the same.

Many thanks for your help in advance.


As the former speaker already noted you are running an old and outdated build.
First step is to upgrade to a current build.
Unfortunately coming from such an old build a reset *after* update and put settings in manually is highly recommended.

Luckily your iptables rules also can use some tweaking.

For the isolation of the VLANs/Bridges start with Enabling Net isolation on all interfaces e.g.:br1, br2 etc.

Now the bridges are isolated from the main network (br0) but not from each other.
You can simply do that with:
iptables -I FORWARD -i br+ -o br+ -m state --state NEW -j REJECT

However as a side effect this also isolates the bridge from itself which is used for WAN-NAT redirection, if that is no problem then you are good otherwise you have to specify it all (and do not use the br+ rule) e.g.:
iptables -I FORWARD -i br4 -o br5 -m state --state NEW -j REJECT
iptables -I FORWARD -i br4 -o br6 -m state --state NEW -j REJECT
iptables -I FORWARD -i br5 -o br4 -m state --state NEW -j REJECT
iptables -I FORWARD -i br5 -o br6 -m state --state NEW -j REJECT
iptables -I FORWARD -i br6 -o br4 -m state --state NEW -j REJECT
iptables -I FORWARD -i br6 -o br5 -m state --state NEW -j REJECT

Now enable access from br0:
iptables -I FORWARD -i br0 -o br+ -m state --state NEW -j ACCEPT

Disable access to BBC from br6:
I think you cannot specify multiple sources with the negate (!) sign.
So either do an nslookup to get all the ip addresses or use IPSET which is the better way as that also deals with dynamic IP addresses.
IPSET is a sticky in this forum.

_________________
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
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