To be more precise than some of the other answers here. I ended up doing the following:
I backup up my current iptables rules:
sudo iptables-save > original-iptables.save
I created a new session using tmux:
tmux
I split the tmux session into two panes using:
<C>-b %
In the first pane I executed: (run this as root user sudo su
)
sleep 5m && sudo iptables-restore original-iptables.save
This will reset your iptables rules after 5 minutes. This command actually ensures that you cannot lock yourself out of your server by accident.
You can use the other pane in order to try out any new rules. (switch panes using <C>-b o
) If the new rules work you can always cancel the original command using -c to ensure that the new rules stay active and are not reset.
You can find a nice & simple cheatsheet about tmux here.