I always hated remote firewall changes.
I usually had two terminals open. In one, I'd run my "cya" script that slept for a minute, restored the old firewall rules, slept another minute, then did a reboot. In the other terminal, I'd run the new firewall rules. If I didn't screw up, I'd go back to the other terminal to stop the "cya" script. If I did screw up, the worst case was a few minutes of downtime that I'd hope nobody would notice.
You could also just save the current firewall config, and then have the script restore the saved config after a minute. No need to reboot.
The script was: sleep 1 minute, then restore rules, sleep 1 more minute, then reboot.
That first rule restore was so I could conceivably get things back in order before the reboot. I had the final reboot there in case the new firewall rules somehow killed my ssh session. This never happened, and I might have been able to ssh in again at that point, but I wasn't going to count on it.
I use either `at(1)` or a 5 min cron job that restores the firewall rules.
> Another favourite is typing "shutdown -h now" into the wrong terminal: I know a few people who have admitted to doing that.
http://packages.debian.org/sid/molly-guard is a good remedy for this :)
Re:My 10 UNIX Command Line Mistakes
by xiongchiamiov on Sunday February 27, 2011 @08:57PM
(#2269704)
Another favourite is typing "shutdown -h now" into the wrong terminal: I know a few people who have admitted to doing that.
I do that less now that the machine's hostname is prominently displayed in my prompt.
Not done that exact one, but I've added firewall rules that cut me out in exactly the same way.
Another favourite is typing "shutdown -h now" into the wrong terminal: I know a few people who have admitted to doing that.