Tips December 9, 2006 at 2:27 am

Undoing the Undoable

Ever had to change the IP on a server that's without any local supervision, behind who knows how many firewalls, in another country, with only SSH accesss sticking out of it? Wouldn't it be nice if there was a function similar to the Displays preference pane, in which, if the settings turn out to be incorrect, it automatically reverts to the previous working setup? Well, here's one.

Before any critical conf change, I just re-define the current config into an at command:

&#36; sudo at now + 15 minute
&#36; changeip - newip oldip newhost oldhost
&#36; networksetup -setmanual networkport oldip oldnetmask oldrouter
&#36; Ctrl -D

Then, make your changes. If all does work out, don't forget to disable the safety harness:

&#36; sudo at -l
&#36; sudo at -r jobnumber

I used an IP change as an example here, but I'm sure you can think of other scenarios with potentially tragic consequences.

No Comments

  • Might want to make sure at is loaded first…

    sudo launchctl load -w

    and then check that at is working happily, but nice tip.

    In similar situations where I’ve only had access to hard rebooting the
    remote machine I’ve set up startup scripts that restore everything to the
    previous settings.

    Nothing like messing with network settings in these situations… 🙂

  • I too do something like this when changing network settings remotely.
    Particularly with ipfw settings.

    Make sure you set the timer long enough to
    have a beer and think about what you did wrong. 🙂

    Breaking my server to save yours.

    Josh Wisenbaker

Leave a reply

You must be logged in to post a comment.