I made changes to iptables config file in /etc/iptables/filter in Ubuntu and want to reload them. I read the man page and also googled but couldn't find the information. Any help will be appreciated.

  • 1
    You have neither provided any information about the version of Ubuntu you are using, nor searched the web well, before posting this question.
    – Puspendu Banerjee
    Dec 6, 2010 at 18:35

6 Answers 6


Normally your firewall rules are in the config file /etc/iptables.firewall.rules

To activate the rules defined in your file you must send them to iptables-restore (you can use another file if you want):

sudo iptables-restore < /etc/iptables.firewall.rules

And you can check that they are activated with:

sudo iptables -L

If you want to activate the same rules each time you boot the computer create this file:

sudo nano /etc/network/if-pre-up.d/firewall

With this content:

/sbin/iptables-restore < /etc/iptables.firewall.rules

And give it permission of execution:

sudo chmod +x /etc/network/if-pre-up.d/firewall

Hope it helps you =)

Example file for /etc/iptables.firewall.rules:


#  Allow all loopback (lo0) traffic and drop all traffic to 127/8 that doesn't use lo0
-A INPUT -i lo -j ACCEPT

#  Accept all established inbound connections

#  Allow all outbound traffic - you can modify this to only allow certain traffic

#  Allow HTTP and HTTPS connections from anywhere (the normal ports for websites and SSL).
-A INPUT -p tcp --dport 80 -j ACCEPT
-A INPUT -p tcp --dport 443 -j ACCEPT

#  Allow SSH connections
#  The -dport number should be the same port number you set in sshd_config
-A INPUT -p tcp -m state --state NEW --dport 22 -j ACCEPT

#  Allow ping
-A INPUT -p icmp -j ACCEPT

#  Log iptables denied calls
-A INPUT -m limit --limit 5/min -j LOG --log-prefix "iptables denied: " --log-level 7

#  Drop all other inbound - default deny unless explicitly allowed policy


Edit 2021-08:

Just had an issue upgrading to Ubuntu 20.04.2 LTS. The location of iptables-restore changed from /sbin/iptables-restore to /usr/sbin/iptables-restore.

Be sure to check with whereis iptables-restore your system location or your network interface will not be raised.

If you don't have network after an upgrade, you can check the reason with sudo systemctl status networking.service -l, on my case:

Failed to start Raise network interfaces.
if-pre-up.d/firewall: 2: /sbin/iptables-restore: not found
  • 6
    On Ubuntu 14.10 I have no /etc/iptables.firewall.rules but sudo iptables-restore < /etc/iptables/rules.v4 worked for me.
    – timbo
    Jan 9, 2015 at 22:43

Easiest way is to reboot (also if below does not work, reboot, check if that made the change).

Second easiest is to restart the daemons using iptables configurations (google: restart daemon ubuntu).

examples (depends your configuration):

/etc/init.d/iptables restart  

/etc/init.d/networking restart  

/etc/init.d/firewall restart
  • 13
    There is no file by name /etc/init.d/iptables
    – Raccha
    Dec 6, 2010 at 18:19
  • 1
    what network related exists in /etc/init.d ? try to restart that.
    – Juha
    Dec 6, 2010 at 18:20
  • 3
    /etc/init.d/networking restart?
    – Juha
    Dec 6, 2010 at 18:22
  • 1
    Dead link is dead. Mar 14, 2014 at 17:45
  • 1
    none of these work on Ubuntu 16.04
    – chovy
    Dec 22, 2016 at 5:53

If you've executed your rules they are already running and no reloading is necessary. In case where you have a configuration file but it hasn't been executed best way I've seen so far is to use iptables-apply (an iptables extension).

iptables-apply -t 60 your_rules_file

This will apply the rules for 60 seconds (10 by default) and revert them if you don't confirm them. This will save you in case you are thrown out of the system because of the rules (ex. if you are operating through ssh).

You can use the following as a replacement:

iptables-restore < your_rules_file; sleep 60; iptables-restore < clean_rules
  • No, reloading is absolutely necessary for DDNS host resolution. If the IP of any referenced host changes, then iptables needs to be reloaded. Ideally you would do this every 30 minutes from cron. It is not convenient to reboot every 30 minutes.
    – mckenzm
    Mar 28, 2019 at 1:58

sudo ufw reload

Will reload firewall and its rules.

(Assuming you're using ufw on top of iptables.)


After googling a little, this is what i found to restart iptables. . . sudo /etc/init.d/firewall restart

  • 9
    There is no file by name /etc/init.d/firewall
    – Raccha
    Dec 6, 2010 at 18:16

If you want to reload IPtables to validate changes you have just made; you can also restart Apache with the command lines below:

/etc/init.d/apache2 stop

/etc/init.d/apache2 start

These command may vary depending on your flavor of Ubuntu, and eventual modifications that may have been made previously.

Hope this helps.


  • 3
    i doubt that the average user is running an apache 2 webserver and I strongly discourage from restarting apache2 for the sake of reloading firewall rules...
    – kaiya
    Mar 9, 2021 at 11:12
  • This answer makes absolutely zero sense at all.
    – xorinzor
    Dec 15, 2023 at 8:28

You must log in to answer this question.