Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 can add the route like this:

iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT

--to-port 8080

But after rebooting, it resets. How do I make it permanent? Is the best practice to put it in the rc.local?

share|improve this question
up vote 3 down vote accepted

IPTables rules are loaded from a file when the service starts.

(The paths below are based on RHEL/CentOS, but the premise should work on other systems)

If you look in /etc/init.d there is an iptables init file, that includes the following lines:


This file will therefore, load the data from /etc/sysconfig/iptables when iptables is started.

Once you know which file is used, you can save your current IPTables ruleset to the file.

  1. Backup the existing file first
  2. Add the rule you want to IPTables

    iptables-save > /etc/sysconfig/iptables

Try to restart the service and see if the rules persist:

service iptables restart
share|improve this answer

Most distros will have something like "iptables save". Are you running RedHat/CentOS? Ubuntu?

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.