Today I learnt about iptables-apply. It undoes firewall rule changes if you've accidentally locked yourself out. Replaces my custom scripts!