Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
problems with bridging firewall
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
jwalcik
n00b
n00b


Joined: 22 Sep 2003
Posts: 27
Location: austin, tx

PostPosted: Wed Apr 07, 2004 8:05 pm    Post subject: problems with bridging firewall Reply with quote

i'm trying to setup a bridging firewall very similar to the one described in the how-to posted here:

https://forums.gentoo.org/viewtopic.php?t=78039

the only difference being that instead of assigning an ip to br0, i've got a third physical ethernet interface (eth2) that has an ip address that i can ssh to for administration.

the bridge itself is working just fine. i have a machine behind it and traffic is flowing in both directions. the firewall part however, doesn't appear to be working correctly, and i'm not sure what i'm doing wrong.

i've executed the exact (as far as i can tell) series of iptables commands outlined in the how-to's "iptables.sh". i didn't include any extra statements for services other than ssh. from what i understand, that should have left me with a bridge that allows everything out, but only ssh in.

however, all traffic is still flowing both ways. i can still browse to the webserver sitting behind the bridge from machines that are on the other side. have i entered one of the rules incorrectly? it looks like nothing is making it past the first rule.

Code:

root@bridge jwalcik # iptables -L -v
Chain INPUT (policy ACCEPT 1128 packets, 113K bytes)
 pkts bytes target     prot opt in     out     source               destination                                                                                 
 1210 93952 ACCEPT     all  --  any    any     anywhere             anywhere         state RELATED,ESTABLISHED
    0     0 ACCEPT     tcp  --  eth0   any     anywhere             anywhere         tcp dpt:ssh
    0     0 REJECT     all  --  eth0   any     anywhere             anywhere         reject-with icmp-port-unreachable
 
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
 pkts bytes target     prot opt in     out     source               destination                                                                                 
    0     0 DROP       all  --  any    any     anywhere             anywhere         state INVALID
    0     0 ACCEPT     all  --  eth0   any     anywhere             anywhere         state RELATED,ESTABLISHED
    0     0 ACCEPT     all  --  eth1   eth0    anywhere             anywhere                                                                                 
    0     0 ACCEPT     icmp --  eth0   eth1    anywhere             anywhere                                                                                 
    0     0 REJECT     all  --  eth0   any     anywhere             anywhere         reject-with icmp-port-unreachable
 
Chain OUTPUT (policy ACCEPT 1137 packets, 134K bytes)
 pkts bytes target     prot opt in     out     source               destination                                                                                 

Back to top
View user's profile Send private message
jwalcik
n00b
n00b


Joined: 22 Sep 2003
Posts: 27
Location: austin, tx

PostPosted: Thu Apr 08, 2004 8:37 pm    Post subject: Reply with quote

just to be thorough, i've removed the third ethernet card from the setup, and i'm now using the exact same setup as the how-to. same scripts and all. it still appears to be ignoring the iptables rules.

i've also tried the following, which i believe should block all traffic flowing across the bridge:

Code:

/sbin/iptables -F
/sbin/iptables -I INPUT -i eth0 -j REJECT
/sbin/iptables -A INPUT -i eth1 -j REJECT
/sbin/iptables -I FORWARD -i eth0 -j REJECT
/sbin/iptables -A FORWARD -i eth0 -j REJECT
/etc/init.d/iptables save
/etc/init.d/iptables restart


with those rules in place, it still allows all traffic to flow freely both ways. is there some step i'm missing? after i bring up the bridge and before or after i define the iptables rules that actually activates the rules? i've seen enough how-to's w/ very similar steps to think that there must be some little piece i'm missing here. any suggestions on where to look or how to proceed in troubleshooting this?
Back to top
View user's profile Send private message
jwalcik
n00b
n00b


Joined: 22 Sep 2003
Posts: 27
Location: austin, tx

PostPosted: Mon Apr 12, 2004 6:35 pm    Post subject: Reply with quote

okay, one last try. any suggestions anyone could give me on this would be greatly appreciated.

at the suggestion of someone from a mailing list i subscribe to i tried using the following two rules to block all traffic:
Code:

iptables -F
iptables -A FORWARD -j REJECT
iptables -A INPUT -j REJECT
/etc/init.d/iptables save
/etc/init.d/iptables restart


that should block all traffic, regardless of interface, still traffic is flowing freely across the bridge. i've double and triple checked that i have the iptables and bridging support built into my kernel, and i've re-emerged both the bridge-utils and iptables with the kernel i'm using.

based on everything i've seen, it seems like there has to be some step i'm missing that activates the ip tables rules. however, like i've said before, i don't see any step that i'm leaving out in any of the how-to's on the subject (or on iptables in general) that i've been able to find. anybody? anything?
Back to top
View user's profile Send private message
UncleTom
Apprentice
Apprentice


Joined: 20 Aug 2003
Posts: 194
Location: Bern, Switzerland

PostPosted: Thu Apr 15, 2004 1:09 pm    Post subject: Reply with quote

Have you compiled your kernel with bridging support?

From the how-to thread you mentioned earlier:
kmasaryk wrote:
The bridge-nf kernel patch, which is required for a bridging firewall if you want iptables to see any of the traffic, for kernel 2.4 is included in 2.6 as a config option when you build the kernel - it's part of "ebtables."

_________________
bug, n: A son of a glitch.
Back to top
View user's profile Send private message
jwalcik
n00b
n00b


Joined: 22 Sep 2003
Posts: 27
Location: austin, tx

PostPosted: Thu Apr 15, 2004 1:46 pm    Post subject: Reply with quote

i enabled bridging, and i enabled iptables, but the kernel source i used was the stock gentoo-sources package for 2.4.25. since the options were present, it appeared to me that the patch had already been applied. if i emerge ebtables will that apply the patch you mention? if not, is there any chance you could get me pointed in the right direction to download it?
Back to top
View user's profile Send private message
UncleTom
Apprentice
Apprentice


Joined: 20 Aug 2003
Posts: 194
Location: Bern, Switzerland

PostPosted: Thu Apr 15, 2004 3:58 pm    Post subject: Reply with quote

I'm sorry, I have never done this myself, so I cannot help you much there. It's just something that's been sitting in my List of Extremely Cool Things To Try for quite some time and I happened upon your post because I'm interested in this myself.

Further reading on [url]bridge.sourceforge.net[/url] and [url]ebtables.sourceforge.net[/url] should clarify these issues, but it seems that 2.4.21 and up include the bridging code and do not need to be patched any more. So that particular idea of mine was useless.

Reading your post it just seemed to me that you don't really have an iptables problem, because your rules are simple enough and should work. The post by kmasaryk sounded to me like a good explanation of that (iptables not seeing the traffic because the kernel doesn't hand the traffic over to iptables).

If nobody else has any better ideas, I would suggest that you investigate further along these lines. Does your kernel configuration include everything that needs to be included and leaves out everything else? For example, I just read in the kernel menuconfig help screen on packet filtering:
Quote:
Make sure to say N to "Fast switching" below if you intend to say Y here, as Fast switching currently bypasses netfilter.

Have you enabled something in your kernel that prevents iptables from getting the traffic?[/quote]
_________________
bug, n: A son of a glitch.
Back to top
View user's profile Send private message
jwalcik
n00b
n00b


Joined: 22 Sep 2003
Posts: 27
Location: austin, tx

PostPosted: Thu Apr 15, 2004 5:46 pm    Post subject: Reply with quote

the same reading on the bridge site also let me to believe i didn't need a patch.

here's what i've got enabled in my kernel as far as networking options go:

    Packet Socket
    Network Packet Filtering
    Network Packet Filtering debugging
    Unix domain sockets
    TCP/IP Networking
    802.1d Ethernet Bridging


and then under the IP: Netfilter Configuration:

    Connection tracking
    FTP Protocol Support
    IP Tables Support (and all of it's children)
    ARP Tables Support (and all of it's children)


i believe that's correct. i don't actually see the "Fast Switching" option referred to in the Packet Filtering documentation. any chance somebody who has this working could post their setup?
Back to top
View user's profile Send private message
jwalcik
n00b
n00b


Joined: 22 Sep 2003
Posts: 27
Location: austin, tx

PostPosted: Thu Apr 15, 2004 8:36 pm    Post subject: Reply with quote

alright, i've got it working now. i emerged the development sources (2.6.6-rc1) and built a new kernel with all of the bridging, iptables, ebtables stuff enabled. so, there may in fact be a patch of some sort required, even if you're using a kernel newer than 2.4.21.

the rules that appear in the how-to still don't appear to work for me. i can add two rules now that block all traffic:
Code:

iptables -A FORWARD -j REJECT
iptables -A INPUT -j REJECT


however if i try to specify an interface, it doesn't work:
Code:

iptables -A FORWARD -i eth0 -j REJECT
iptables -A INPUT -i eth0 -j REJECT


so, things still aren't perfect, but i have a much clearer picture of what i need to work on now. here's a copy of my kernel config, just in case it may help somebody else in the same boat out: http://www.laits.utexas.edu/~jwalcik/bridging_firewall_kernel.txt
Back to top
View user's profile Send private message
UncleTom
Apprentice
Apprentice


Joined: 20 Aug 2003
Posts: 194
Location: Bern, Switzerland

PostPosted: Fri Apr 16, 2004 7:20 am    Post subject: Reply with quote

Glad to hear you got it working now.

Have you tried to specify the rules that don't work with iptables using ebtables?
Code:

ebtables -A FORWARD -i eth0 -j REJECT
ebtables -A INPUT -i eth0 -j REJECT

_________________
bug, n: A son of a glitch.
Back to top
View user's profile Send private message
jwalcik
n00b
n00b


Joined: 22 Sep 2003
Posts: 27
Location: austin, tx

PostPosted: Fri Apr 16, 2004 8:03 pm    Post subject: Reply with quote

i can write ebtables rules against the eth0 and eth1 interfaces, very similar to what you've suggested (except using DROP, as ebtables doesn't have a REJECT target), however i'm not sure it will do exactly what i'm ultimately trying to accomplish.

basically, i want to use this bridging firewall to help protect the segment of our department's LAN that my servers are on. i need to be able to filter by port (or more ideally by protocol), which iptables appears to support, but ebtables doesn't necessarily. the protocols it's talking about aren't like "ssh" or "http", they're, um... i'll say "ethernet protocols" (they're referred to as EtherTypes in the document linked below), because i don't know the correct term. you can see the list here: http://www.iana.org/assignments/ethernet-numbers

i think i'll probably be able to sort something out with iptables by filtering based on destination address as opposed to interface, however being able to set a few default rules across the bridge by interface, and fine tune by destination address would be ideal.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
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