Just installed Arch Linux and saved some iptables rules using iptables-save but they won't load at startup. What does this mean?

The systemd unit file point to the location where the rule configuration will be saved

Where do I find that systemd unit file so I can write down the path to iptables.rules

up vote 3 down vote accepted

Preface: Getting IPTables to be persistent between reboots can be maddening since basic processes/procedures seem to vary greatly between Linux distros. So don’t sweat it if this seems confusing; it is.

According to what I know of IPTables and Arch Linux—and honestly, mainly from the official Arch Linux wiki—the default IPv4 rules should be stored here:

/etc/iptables/iptables.rules

So if you stored the iptables.rules file in your user’s home directory just copy it from the home directory to that destination like this:

sudo cp ~/iptables.rules /etc/iptables/iptables.rules

And once that is done, restart IPTables via systemctl like this:

sudo systemctl restart iptables

That will simply immediately restart IPTables, but you might want to reboot the machine to test if this works.

If somehow that doesn’t work, it might be because IPTables is not enabled as a startup service on your system. To enable it as a startup service, just run this command:

sudo systemctl enable iptables

And then restart and IPTables should be up and running with your rules in /etc/iptables/iptables.rules properly loaded.

  • I did just this (linked the arch wiki), I called the command iptables-save > /etc/iptables/iptables.rules, but when I reboot the rules won't load automatically. – ChiseledAbs Jul 23 '16 at 19:51
  • @ChiseledAbs Check my latest edit. I believe you might need to enable IPTables as a system service by running sudo systemctl enable iptables. – JakeGould Jul 23 '16 at 20:25

In RedHat family systemd unit /usr/lib/systemd/system/iptables.service

And default location to load /etc/sysconfig/iptables

How it found:

locate iptables | grep systemd

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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