Status Quo Ante: bringing your server back online

Working on a remote system is always risky, especially when changing network settings. Every sysadmin has at least once locked himself out of the system, leading to a reboot or a lengthy car drive to get the server back into a working state.

A common solution is scheduling an automatic reboot 10 minutes after beginning the work on the system. When everything goes right, the shutdown sequence is cancelled and the new configuration is fixated, if anything goes wrong, the system restart restores the network configuration - while terminating all running processes of course.

Status Quo Ante (or for short) is a script that tries to save the complete network configuration to a dump directory and can restore this saved state at a later time. Dumped items include:

  • configured IP addresses and netmasks
  • routing table entries and gateways
  • advanced routing rules
  • iptables firewall configuration

What do I need?

All you need is the package iproute to access your network configuration and the SQA script itself.

How do I dump my network configuration?

Simply call the script with the command save and the directory you wish to place your configuration into, e.g. save /tmp/netdump.

How do I restore that?

Call the script with the command restore: restore /tmp/netdump

You can also just display the commands SQA would use to restore the configuration; use the command simulate for that.

How does that keep me from locking myself out?

It probably won't, but you can use the script to reopen the door once you closed it accidently. Simply dump your configuration, open a second ssh session and run this command: sleep 600 && restore /tmp/netdump. If things turn out bad, network settings will be back to normal in 10 minutes, otherwise just hit ctrl-c to avoid restoration.

How can I use an advanced countdown script?

The script is a bash script that takes a timespan (in seconds) as command line argument and counts down towards zero. Pressing any key during that process will reset the countdown back to its starting value, buying you more time to complete your work on the server. To abort the countdown, just press Ctrl-c to terminate the script: 600 && restore /tmp/netdump. To get your attention, the last 10 seconds will be acompanied by sounding of the terminal bell.