Score:0

Restore Iptable Rules on Ubuntu20

br flag

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.

Score:0
fr flag

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.

Score:0
in flag

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.

PGBRULES avatar
br flag
What are the basic rules in order to allow me to be able to access my server again?
in flag
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`
A.B avatar
cl flag
A.B
@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.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.