Last night I was trying to undo some ip table changes I did and I ended up doing iptables -F, Is there anyway to get back to normal? I'm on an ubuntu server.

2 Answers 2


After you flushed all rules, this is your new "normal"...

If you have installed iptables-persistent you might be able to restore the last saved state with iptables-restore /etc/iptables/rules.v4

Otherwise you have to "restore" the rules by typing them in again.

  • What are the basic rules in order to allow me to be able to access my server again?
    Feb 5 at 5:19
  • Set the default to "accept" with iptables --policy INPUT ACCEPT, then insert your rules and as LAST rule you should drop evrything else: iptables -A INPUT -j DROP
    – Virsacer
    Feb 5 at 9:06
  • @Virsacer I think if the policies or INPUT or OUTPUT were DROP, OP cut its own remote access, but forgot to mention it in the question but only in last comment: "be able to access my server again". So it's all about out of band remote access: remote console, remote reboot etc.
    – A.B
    Feb 5 at 12:16

Once you delete IPtables rules, you cannot get them back.

Run these commands to delete all IPtables rules:

iptables -t raw -F
iptables -t mangle -F
iptables -t nat -F
iptables -t filter -F
iptables -t raw -X
iptables -t mangle -X
iptables -t nat -X
iptables -t filter -X

-t is the flag for the table, there are 4 tables in IPtables. -F flushes the specified table. -X deletes all chains except the defaults in a given table.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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