Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I want to make an iptable rule permanent so if the server is rebooted I won't have to add the rule again.

Specifically a rule I have related to nginx being reverse proxy of apache.

iptables -t nat -A PREROUTING -p tcp -s ! --dport 80 -j REDIRECT --to-ports 85

I tried iptables-save but either I didn't use the correct files or it doesn't work for me.

Note that I use directadmin control panel for the server as well as

So there is a possibility those interfere, since the rules were not there even though there wasn't any server reboot several times.

share|improve this question
up vote 8 down vote accepted

You can use the service iptables save command.

share|improve this answer

You can run /etc/init.d/iptables save.

This will write out the file /etc/sysconfig/iptables. Look at that file to verify that the contents has the rules that you want (it won't be in same format as iptables run from the command line, but you should be able to get the gist of it).

Make sure that iptables is set to run on reboot. Run chkconfig --list iptables to see if it's "on" for startup. If not, run chkconfig iptables on, and the run chkconfig --list iptables. You should see "on" in runlevels 2, 3, 4, 5.

share|improve this answer

Your Answer


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.