Advertisement: Linux VPS from $4/month - contact support for custom offer.
 
+ Post New Thread
Results 1 to 2 of 2

Thread: How to iptables save and restore & make iptables-persistent

  1. #1
    Administrator
    Join Date
    Mar 2013
    Posts
    2,724

    How to iptables save and restore & make iptables-persistent

    When doing some changes in iptables, one can first save the rules so it can be restored if something go wrong.

    SAVE

    iptables-save > /etc/iptables/rules.v4-datehere-working;ip6tables-save > /etc/iptables/rules.v6-datehere-working

    RESTORE

    iptables-restore < /etc/iptables/rules.v4-datehere-working;ip6tables-restore < /etc/iptables/rules.v6-datehere-working

    ----

    After rules are changed and verified to be working/not blocking valid traffic, it needs to be saved to survive reboot:

    Make it persistent:

    On CentOS, its done by command:
    "service iptables save" or "iptables-save > /etc/sysconfig/iptables"

    On Debian/Ubuntu, one may try:
    sudo apt install iptables-persistent && sudo iptables-save|sudo tee -a /etc/iptables/rules.v4 && sudo ip6tables-save|sudo tee -a /etc/iptables/rules.v6
    (system will then load that files during boot)

    NOTE: some services add iptables rules upond start and so you may consider adjusting your exported /etc/iptables/rules.v* files in case you find that after reboot there are duplicate rules.

  2. #2


    Is this useful / helpfull? Yes | No
    The actual iptables rules are created and customized on the command line with the command iptables for IPv4 and ip6tables for IPv6. These can be saved in a file with the command iptables-save for IPv4. These files can be loaded again with the command iptables-restore for IPv4.

+ Post New Thread

Similar Threads

  1. How to restore softaculous backup manually
    By Fli in forum Control Panels
    Replies: 3
    Last Post: 04-17-2017, 06:53 AM
  2. Replies: 0
    Last Post: 02-03-2015, 11:47 AM
  3. Replies: 0
    Last Post: 11-30-2014, 08:23 PM
  4. How to restore WHM after IP change
    By Fli in forum Reseller Hosting
    Replies: 0
    Last Post: 11-30-2014, 06:59 PM
  5. Replies: 0
    Last Post: 04-27-2014, 08:48 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
 Protected by : ZB BLOCK  &  StopForumSpam