isolate vlans / ports / iptables question

Post new topic   Reply to topic    DD-WRT Forum Index -> Broadcom SoC based Hardware
Goto page 1, 2  Next
Author Message
john_es
DD-WRT User


Joined: 05 May 2008
Posts: 97

PostPosted: Sun Feb 08, 2009 6:27    Post subject: isolate vlans / ports / iptables question Reply with quote
My VLAN config:
VLAN0 - no ports
VLAN1 - W
VLAN2 - Port 2
VLAN3 - Port 3
VLAN4 - Port 4
VLAN5 - Port 1

So if I want to separate wireless, all vlans, all ports, I am guessing I want to do something like this:

iptables -I FORWARD -i Y -o X -j DROP

Where X and Y are all possible combinations of:

br0
eth1
vlan0
vlan1
vlan2
vlan3
vlan4
vlan5

Does that sound right?
Sponsor
soulstace
DD-WRT Guru


Joined: 04 Aug 2007
Posts: 6427

PostPosted: Sun Feb 08, 2009 11:26    Post subject: Reply with quote
Yes that's fine. But keep in mind if you block any VLAN access to VLAN1, it will not be able to reach the internet.

It is also possible to completely isolate any port. See http://www.dd-wrt.com/wiki/index.php/Default_Configuration_Overview
john_es
DD-WRT User


Joined: 05 May 2008
Posts: 97

PostPosted: Sun Feb 08, 2009 22:47    Post subject: Reply with quote
soulstace wrote:
Yes that's fine. But keep in mind if you block any VLAN access to VLAN1, it will not be able to reach the internet.

It is also possible to completely isolate any port. See http://www.dd-wrt.com/wiki/index.php/Default_Configuration_Overview


Funny -- right after I posted that, I couldn't access the net. SO I took it line by line until I figured out that I don't want to block vlan1 :)

So I removed the lines that were blocking access to vlan1 and everything works now. I just wasn't sure if allowing access to the vlan1, if that would allow other vlans to talk to each other but my experiments show that they are still isolated.

thanks!
john_es
DD-WRT User


Joined: 05 May 2008
Posts: 97

PostPosted: Sun Feb 08, 2009 22:48    Post subject: Reply with quote
If I don't have anything associated with vlan0, what does vlan0 do? Right now my iptables blocks everything from vlan0 and doesnt seem to be creating any bad side effects.
AndreyPopov
DD-WRT User


Joined: 15 May 2008
Posts: 431

PostPosted: Sun Feb 08, 2009 23:05    Post subject: Re: isolate vlans / ports / iptables question Reply with quote
john_es wrote:
My VLAN config:
VLAN0 - no ports
VLAN1 - W
VLAN2 - Port 2
VLAN3 - Port 3
VLAN4 - Port 4
VLAN5 - Port 1

So if I want to separate wireless, all vlans, all ports, I am guessing I want to do something like this:

iptables -I FORWARD -i Y -o X -j DROP

Where X and Y are all possible combinations of:

br0
eth1
vlan0
vlan1
vlan2
vlan3
vlan4
vlan5

Does that sound right?


all you need at startup send value "0" to ip_forvarding on ALL interfaces like this:
echo "0"> /proc/sys/net/ipv4/ip_forward
and set Routing on Administration->Managment page to Disable
john_es
DD-WRT User


Joined: 05 May 2008
Posts: 97

PostPosted: Mon Feb 09, 2009 0:38    Post subject: Re: isolate vlans / ports / iptables question Reply with quote
AndreyPopov wrote:

all you need at startup send value "0" to ip_forvarding on ALL interfaces like this:
echo "0"> /proc/sys/net/ipv4/ip_forward
and set Routing on Administration->Managment page to Disable


Question ! Can you explain what your suggestion does? If it saves me from having 80 rules in iptables, this is awesome.
soulstace
DD-WRT Guru


Joined: 04 Aug 2007
Posts: 6427

PostPosted: Mon Feb 09, 2009 11:05    Post subject: Reply with quote
it disables IP forwarding. but if the router can't forward packets it isn't a router anymore. I don't think you want to disable IP forwarding but maybe I'm wrong.
john_es
DD-WRT User


Joined: 05 May 2008
Posts: 97

PostPosted: Wed Feb 11, 2009 12:21    Post subject: Reply with quote
Right, which is why I am sticking with my iptables rules.
john_es
DD-WRT User


Joined: 05 May 2008
Posts: 97

PostPosted: Tue Feb 24, 2009 11:33    Post subject: Reply with quote
Is there a way to shorten this with a bit different logic, perhaps denying everything and then adding lines to allow vlan1 and all combinations of the various vlans1?

along the lines of:
iptables -I FORWARD -i * -o * -j DROP
iptables -I FORWARD -i vlan1 -o * -j ACCEPT
iptables -I FORWARD -i * -o vlan1 -j ACCEPT
Bird333
DD-WRT Guru


Joined: 07 Jun 2006
Posts: 809

PostPosted: Tue Feb 24, 2009 16:30    Post subject: Reply with quote
You can set a policy that rejects all packets if there are no matching rules. I think right now dd-wrt has an iptables policy that accepts all packets if there is no match.
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Tue Feb 24, 2009 20:20    Post subject: Reply with quote
If I understand this correctly you want to block every local host from communicating with each other but still allow them all internet access? If that is correct then you can use the following rules adjusted with a netmask that encompasses your entire local network depending on how you have addresses set up.

iptables -I FORWARD -s 192.168.0.0/24 -j ACCEPT
iptables -I FORWARD -s 192.168.0.0/24 -d 192.168.0.0/24 -j DROP
john_es
DD-WRT User


Joined: 05 May 2008
Posts: 97

PostPosted: Sun Mar 08, 2009 10:30    Post subject: Reply with quote
let me clear up what I am trying to do - I appreciate your help.

Basically, I have each of the 4 ports set to their own vlans. I also have a couple of wireless networks.

What I want to do is:

- allow all clients access to the internet
- prevent all communication between the vlans.
- so that means vlan2 cant talk to vlan3, 4, 5
- vlan 3 cant talk to vlan 2, 4, 5
- etc.

But if I go through all of these combos, I run out of space.

Will your method work for me?
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Sun Mar 08, 2009 11:53    Post subject: Reply with quote
This should do the trick.

iptables -I FORWARD -i br0 -o br0 -j DROP
john_es
DD-WRT User


Joined: 05 May 2008
Posts: 97

PostPosted: Sat Aug 01, 2009 1:50    Post subject: Reply with quote
I am coming back to this after a few months away from using my router... is there a way to isolate all vlans from ewach other without having a billion iptables rules?

Thanks,
John
phuzi0n
DD-WRT Guru


Joined: 10 Oct 2006
Posts: 10141

PostPosted: Sat Aug 01, 2009 3:33    Post subject: Reply with quote
Split all the ports into vlans, bridge them all in br0, and use this in your firewall.

insmod ebtables
iptables -I FORWARD -i br0 -o br0 -j DROP

_________________
Read the forum announcements thoroughly! Be cautious if you're inexperienced.
Available for paid consulting. (Don't PM about complicated setups otherwise)
Looking for bricks and spare routers to expand my collection. (not interested in G spec models)
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
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