Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Baselayout and firewalling interfaces before they are up
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
Bad Penguin
Guru
Guru


Joined: 18 Aug 2004
Posts: 507

PostPosted: Fri May 05, 2006 4:27 am    Post subject: Baselayout and firewalling interfaces before they are up Reply with quote

I am curious how people might best handle a situation. I have a home firewall/router with two interfaces, private (eth0) and public (eth1). The public interface gets a dynamic IP address via dhcp from a cable modem. I need to be able to use the actual dynamic IP address in my firewall init script, but of course won't know it until dhcpd has completed its negotiations. But I don't want the interface to be unprotected before it gets the IP address and/or before my firewall script is run. Iptables can filter interfaces before they exist, so I know that is not an issue.

My question is this - where would the best place be to lock the interface down before it runs dhcpcd? In the net preup() function? In a separate init script that runs before the net.* and firewall init scripts? How do other people handle this situation?
Back to top
View user's profile Send private message
UberLord
Retired Dev
Retired Dev


Joined: 18 Sep 2003
Posts: 6835
Location: Blighty

PostPosted: Fri May 05, 2006 7:20 am    Post subject: Reply with quote

In a separate init script in the boot runlevel that has this dependency

Code:
depend() {
   before net
}


With baselayout-1.12 it's then guaranteed to start before any net stuff, including lo :)
_________________
Use dhcpcd for all your automated network configuration needs
Use dhcpcd-ui (GTK+/Qt) as your System Tray Network tool
Back to top
View user's profile Send private message
Bad Penguin
Guru
Guru


Joined: 18 Aug 2004
Posts: 507

PostPosted: Fri May 05, 2006 3:21 pm    Post subject: Reply with quote

UberLord wrote:
In a separate init script in the boot runlevel that has this dependency

Code:
depend() {
   before net
}


With baselayout-1.12 it's then guaranteed to start before any net stuff, including lo :)

Thanks Uber, I will give that a try. I assume that the "real" firewall init script would then need:
Code:
depend() {
   after net
}
Back to top
View user's profile Send private message
nevynxxx
Veteran
Veteran


Joined: 12 Nov 2003
Posts: 1123
Location: Manchester - UK

PostPosted: Fri May 05, 2006 4:06 pm    Post subject: Re: Baselayout and firewalling interfaces before they are up Reply with quote

Bad Penguin wrote:
I need to be able to use the actual dynamic IP address in my firewall init script


Out of interest....Why?

I have exactly the same set-up and do all the filtering I could want or need using just the interfaces.

What does the actual IP matter? Or rather, at what point is the actual IP something distinguishable from the interface name?
_________________
My Public Key

Wanted: Instructor in the art of Bowyery
Back to top
View user's profile Send private message
Bad Penguin
Guru
Guru


Joined: 18 Aug 2004
Posts: 507

PostPosted: Fri May 05, 2006 4:15 pm    Post subject: Re: Baselayout and firewalling interfaces before they are up Reply with quote

nevynxxx wrote:
Bad Penguin wrote:
I need to be able to use the actual dynamic IP address in my firewall init script


Out of interest....Why?

I have exactly the same set-up and do all the filtering I could want or need using just the interfaces.

What does the actual IP matter? Or rather, at what point is the actual IP something distinguishable from the interface name?

I am anal and don't want my firewall considering packets destined for any address other than the actual address it has been assigned on the public interface. I do a lot of port forwarding and feel that specifying the address and port is safer than applying rules by interface/port.
Back to top
View user's profile Send private message
nevynxxx
Veteran
Veteran


Joined: 12 Nov 2003
Posts: 1123
Location: Manchester - UK

PostPosted: Mon May 08, 2006 11:20 am    Post subject: Reply with quote

Then get a static IP?

Seriously, if it is not aimed at the correct IP anyway the network stack will ignore it. Or better still, put a switch between the internet and the interface, then the switch will do that filtering for you.

You are making something a whole load more difficult by "being anal", and when it comes to iptables, or security in general, more difficult = less secure.
_________________
My Public Key

Wanted: Instructor in the art of Bowyery
Back to top
View user's profile Send private message
Bad Penguin
Guru
Guru


Joined: 18 Aug 2004
Posts: 507

PostPosted: Mon May 08, 2006 1:37 pm    Post subject: Reply with quote

nevynxxx wrote:
Then get a static IP?

Seriously, if it is not aimed at the correct IP anyway the network stack will ignore it. Or better still, put a switch between the internet and the interface, then the switch will do that filtering for you.

You are making something a whole load more difficult by "being anal", and when it comes to iptables, or security in general, more difficult = less secure.

Well, no, as a matter of fact it won't ignore broadcast/multicast/unicast. Instead of accounting for every packet type known to man, it is easier and cleaner to:
Code:

$IPT -A INPUT -i $EXT_IF -d ! $EXT_IP -j DROP


Comcast also sends traffic from its internal networks (10.0.0.0) over that interface. Instead of filtering ingress traffic from all three private networks, same rule applies. So I'm lazy, instead of inserting 4 rules into the tables, I prefer 1 rule that takes care of all of it ;)
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