1
I want to keep some iptables
rules permanence, so I just only add the rules manually:
/sbin/iptables -I OUTPUT -p tcp --sport 80 -j QUEUE
I am sure that the command works, because I could see it after executing iptables -vnL
. Unfortunately, I find it disappearing without rebooting or restarting iptables
after an hour or so because I could not see it after executing iptables -vnL
later on.
First of all, I am sure there is no one executing command like iptables -F
. I also find one related row in /var/log/message
:
Dec 18 10:10:50 zt_21_23 kernel: ip_tables: (C) 2000-2006 Netfilter Core Team
I find this is a kernel behavior completely after Google. Someone said iptables
would rebuild the rules, but he didn't tell me the triggering condition. and I check the iptables configuration file (/etc/sysconfig/iptables-config
), but I could not find any configuration item that could make iptables
rebuilding the rules.
I have to add the rules at set intervals by using crontab if I want to keep it permanence.
To sum up:
- How to stop iptables from reverting the rules I add?
- When will
iptables
rebuild its rules and what is the triggering condition? - Which rule would be reloaded when iptables rebuilt and where these rules are saved?
PS. Modifying /etc/sysconfig/iptables
, or using iptables-save
and iptables-restore
could work, but the rules still disappear after an hour or so.
I am using Linux (2.6.18-308.24.1.el5 x86_64).
obviously somebody else is changing the rules. Do ypu stop iptables service, make the change and then restart each time? – mdpc – 2014-12-18T07:55:48.817
there is no one change the rules(because nobody but me know the password). and I don't restart iptables, and I don't reboot. – Mark – 2014-12-18T09:38:26.287
I think @mdpc means you should stop the service, make your changes then start the service which basically saves those changes. Maybe it has a problem saving your changes while it's running and if the service is stopped, then you can make the changes without worrying about anything currently running and conflicting. – Andrew – 2014-12-18T11:17:44.053
I have tried, but it still didn't work. I add the rules in /etc/sysconfig/iptables, reboot, restart iptables, then I found the rules existed, but it would disappear after an hour. – Mark – 2014-12-18T11:40:22.017