* Question about /etc/iptables.down.rules
@ 2007-08-27 1:51 TinyApps.Org
2007-08-27 7:52 ` Покотиленко Костик
0 siblings, 1 reply; 4+ messages in thread
From: TinyApps.Org @ 2007-08-27 1:51 UTC (permalink / raw)
To: netfilter
I have a very simple set of iptables rules:
# iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
# iptables -A INPUT -p tcp -i eth0 --dport ssh -j ACCEPT
# iptables -I INPUT -i lo -j ACCEPT
# iptables -A INPUT -j DROP
which has been saved to /etc/iptables.up.rules .
I have also modified /etc/network/interfaces to use the ruleset:
iface eth0 inet static
address x.x.x.x
[.. interface configuration ..]
pre-up iptables-restore < /etc/iptables.up.rules
I understand that it is best to setup a set of rules to be applied
when the network interface is down, saving it to:
/etc/iptables.down.rules
and applying in /etc/network/interfaces via:
post-down iptables-restore < /etc/iptables.down.rules
What should this set of rules look like? The exact opposite
of /etc/iptables.up.rules ? Or just a simple flush command?
Or something else altogether?
Sincerely,
Miles
^ permalink raw reply [flat|nested] 4+ messages in thread* Re: Question about /etc/iptables.down.rules
2007-08-27 1:51 Question about /etc/iptables.down.rules TinyApps.Org
@ 2007-08-27 7:52 ` Покотиленко Костик
2007-08-27 8:01 ` TinyApps.Org
0 siblings, 1 reply; 4+ messages in thread
From: Покотиленко Костик @ 2007-08-27 7:52 UTC (permalink / raw)
To: TinyApps.Org; +Cc: netfilter
В Вск, 26/08/2007 в 15:51 -1000, TinyApps.Org пишет:
> I have a very simple set of iptables rules:
>
> # iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
> # iptables -A INPUT -p tcp -i eth0 --dport ssh -j ACCEPT
> # iptables -I INPUT -i lo -j ACCEPT
> # iptables -A INPUT -j DROP
>
> which has been saved to /etc/iptables.up.rules .
>
> I have also modified /etc/network/interfaces to use the ruleset:
>
> iface eth0 inet static
> address x.x.x.x
> [.. interface configuration ..]
> pre-up iptables-restore < /etc/iptables.up.rules
>
> I understand that it is best to setup a set of rules to be applied
> when the network interface is down, saving it to:
>
> /etc/iptables.down.rules
>
> and applying in /etc/network/interfaces via:
>
> post-down iptables-restore < /etc/iptables.down.rules
>
> What should this set of rules look like? The exact opposite
> of /etc/iptables.up.rules ? Or just a simple flush command?
> Or something else altogether?
You can do a simple flush, but this is not required, since all rules
will be overwritten by iptables-restore when you bring network interface
up next time.
--
Покотиленко Костик <casper@meteor.dp.ua>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Question about /etc/iptables.down.rules
2007-08-27 7:52 ` Покотиленко Костик
@ 2007-08-27 8:01 ` TinyApps.Org
2007-08-27 8:42 ` Покотиленко Костик
0 siblings, 1 reply; 4+ messages in thread
From: TinyApps.Org @ 2007-08-27 8:01 UTC (permalink / raw)
To: casper; +Cc: netfilter
Thanks for your reply, Покотиленко! (I hope that is the correct name
to use.)
My reply is at the bottom of this message:
>> I understand that it is best to setup a set of rules to be applied
>> when the network interface is down, saving it to:
>>
>> /etc/iptables.down.rules
>>
>> and applying in /etc/network/interfaces via:
>>
>> post-down iptables-restore < /etc/iptables.down.rules
>>
>> What should this set of rules look like? The exact opposite
>> of /etc/iptables.up.rules ? Or just a simple flush command?
>> Or something else altogether?
>
> You can do a simple flush, but this is not required, since all rules
> will be overwritten by iptables-restore when you bring network
> interface
> up next time.
I had stumbled across the following comment:
"But to do this really clean, we need to have a script that removes
the rules as well for when the interface goes down. Just to make sure
the rules are never added twice."
on this site:
http://my.opera.com/Jada0007/blog/show.dml/1213354
and therefore wondered if there were ever a case in which
the rules could be applied twice... by creating a /etc/
iptables.down.rules
file, I hoped to avoid such a possibility.
Sincerely,
Miles
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: Question about /etc/iptables.down.rules
2007-08-27 8:01 ` TinyApps.Org
@ 2007-08-27 8:42 ` Покотиленко Костик
0 siblings, 0 replies; 4+ messages in thread
From: Покотиленко Костик @ 2007-08-27 8:42 UTC (permalink / raw)
To: TinyApps.Org; +Cc: netfilter
В Вск, 26/08/2007 в 22:01 -1000, TinyApps.Org пишет:
> Thanks for your reply, Покотиленко! (I hope that is the correct name
> to use.)
> My reply is at the bottom of this message:
>
> >> I understand that it is best to setup a set of rules to be applied
> >> when the network interface is down, saving it to:
> >>
> >> /etc/iptables.down.rules
> >>
> >> and applying in /etc/network/interfaces via:
> >>
> >> post-down iptables-restore < /etc/iptables.down.rules
> >>
> >> What should this set of rules look like? The exact opposite
> >> of /etc/iptables.up.rules ? Or just a simple flush command?
> >> Or something else altogether?
> >
> > You can do a simple flush, but this is not required, since all rules
> > will be overwritten by iptables-restore when you bring network
> > interface
> > up next time.
>
> I had stumbled across the following comment:
>
> "But to do this really clean, we need to have a script that removes
> the rules as well for when the interface goes down. Just to make sure
> the rules are never added twice."
>
> on this site:
> http://my.opera.com/Jada0007/blog/show.dml/1213354
>
> and therefore wondered if there were ever a case in which
> the rules could be applied twice... by creating a /etc/
> iptables.down.rules
> file, I hoped to avoid such a possibility.
man iptables-restore states:
...
-n, --noflush
don't flush the previous contents of the table. If not specified,
iptables-restore flushes (deletes) all previous contents
of the
respective IP Table.
...
So, make sure you won't use "-n" option when calling iptables-restore.
--
Покотиленко Костик <casper@meteor.dp.ua>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-08-27 8:42 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-27 1:51 Question about /etc/iptables.down.rules TinyApps.Org
2007-08-27 7:52 ` Покотиленко Костик
2007-08-27 8:01 ` TinyApps.Org
2007-08-27 8:42 ` Покотиленко Костик
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox