I'm using iptables on Ubuntu 10.04 and whenever I set iptables rules they will revert after a while. I set them with iptables -I INPUT or iptables -D INPUT and they work immediately and I see them in iptables -L INPUT but after a while the rules revert.

I even exported the rules

iptables-save > /etc/firewall.conf

I even created a script /etc/network/if-up.d/iptables

#!/bin/sh
iptables-restore < /etc/firewall.conf

and I even checked firewall.conf and it has the rules I want in it.

So why would iptables be reverting?

UPDATE:

I found this in /etc/cron.daily/apf

#!/bin/bash
/etc/apf/apf -f >> /dev/null 2>&1
/etc/apf/apf -s >> /dev/null 2>&1

Would this be flushing the iptables rules?

link|improve this question

33% accept rate
feedback

2 Answers

The wiki page references feisty etc. so may be out of date but I would guess its still relevant:

https://help.ubuntu.com/community/IptablesHowTo#Configuration%20on%20startup suggests that NetworkManager may be the culprit...

https://help.ubuntu.com/community/IptablesHowTo#Configuration%20on%20Startup%20for%20NetworkManager then suggests how to get NetworkManager to play nice.

link|improve this answer
There is no /etc/NetworkManager on my system and man -k Network Manager doesn't show anything which looks like it... I think Network Manager isn't installed on my system – David Jun 2 '11 at 10:14
Are you sure? The capitalisation of the 'N' & 'M' is important. – PriceChild Jun 2 '11 at 10:23
yes. very sure ls /etc/N* ls: cannot access /etc/N*: No such file or directory – David Jun 2 '11 at 11:04
feedback

I'm not familiar with apf, but it's easy enough to check if that's the culprit. Remove it from cron.

I'd also do something like grep -ri --color iptables /etc and also check /var/log/messages and /var/log/syslog for anything that could be doing this.

link|improve this answer
Yeah I had already grepped for iptables under etc but there is nothing (other then my above-mentioned script). Good idea with grepping the logs too but there was nothing there either. I've confirmed that the apf script flushes the iptables rules so I'Ve removed it. Now I just have to wait until the daily cron goes... This was a tricky one since the script flushing the iptables rules doesn't have the word "iptables" in it – David Jun 3 '11 at 10:24
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.