4

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

2 Answers 2

6

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.

1
  • 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. Jul 23, 2016 at 19:51
0

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .