Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

To enable port 7070 on my server I've run

iptables -A INPUT -p tcp -m tcp --dport 7070 -j ACCEPT

through SSH and then

service iptables save

which saved rules to /etc/sysconfig/iptables file.

However, when I reboot the server, saved rule is not applied. How can I auto-apply this rule when server restarts?

share|improve this question

1 Answer 1

up vote 2 down vote accepted

This will list state of iptables startup:

chkconfig --list iptables

"Standard" configuration looks like this:

iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off

This command set up the defaults:

chkconfig --level 2345 iptables on

If it did not help that there is something wrong with Your OS.

One more thing to try. Please input this command:

iptables -I INPUT -p tcp -m tcp --dport 7070 -j ACCEPT

(-A is replaced with -I - this will add this rule to the begining of the input chain) Save iptables state one more time and please test if that helped.

share|improve this answer
    
Can you explain what you meant? What chkconfig --level 2345 iptables on is supposed to do ? because before and after I run this command chkconfig --list iptables still returns iptables 0:off 1:off 2:on 3:on 4:on 5:on 6:off –  Stephane Kouakou Apr 1 '13 at 12:50
1  
chkconfig - updates and queries runlevel information for system services - simply speaking chkconfig is used for setting which service should be start automaticaly (at system startup). You can also use "ntsysv" command (if there is no such command installed - yum install ntsysv). –  RJS Apr 1 '13 at 13:02
1  
chkconfig --list - list all services and their state (start/stop levels). chkconfig --level 2345 iptables on - tells that iptables script (from /etc/init.d/iptables) should be started at startup levels 2,3,4 and 5. /etc/init.d/iptables read it's config from file /etc/sysconfig/iptables. –  RJS Apr 1 '13 at 13:03
    
well but my issue is it doesnt load /etc/sysconfig/iptables on startup so I run your command and it's still not loading config –  Stephane Kouakou Apr 1 '13 at 13:10
    
see my edits in the above answer. And after restart please attach "iptables -L -n" output in your question –  RJS Apr 1 '13 at 13:14

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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