Ubuntu 24.04 LTS netfilter-persistent service is not restoring iptables config

can someone help me understand why netfilter-persistent service is not restoring iptables configuration after reboot of Ubuntu 24.04 LTS server?

  1. I installed (I also tried to reinstall) the netfilter-persistent service:
    apt install netfilter-persistent
  2. I saved my iptables rules:
    iptables-save > /etc/iptables/rules.v4
  3. I rebooted my Ubuntu server and after restart my iptables are empty.
  4. I checked the state of the service but everything seems okay:
    systemctl status netfilter-persistent
  5. I checked that the file rules.v4 is is not empty.
    It’s not empty.
  6. I read something about delaying the service with network.target property inside the service config.
    Didn’t help.

I really don’t have any idea why it’s not working.

Straight answer:

The problem is that Ubuntu 24.04 uses nftables by default, not iptables.

Even though netfilter-persistent is installed and your /etc/iptables/rules.v4 file exists, the system is using nftables as the default backend, so iptables rules aren’t applied after reboot.


How to fix:

  1. Install iptables-legacy backend:
sudo update-alternatives --set iptables /usr/sbin/iptables-legacy
sudo update-alternatives --set ip6tables /usr/sbin/ip6tables-legacy
  1. Reboot the server:
sudo reboot
  1. After reboot, check:
sudo iptables -L

You should now see your restored rules.


Let me know if you’re using nftables on purpose — the fix would be different.