I'm about to change iptables configuration and interface speed and duplex settings over SSH. What are the possibilities to rollback the changes in case of host becomes unreachable? I guess simple:ip addr add 10.10.10.1/24 dev eth0; ping -c1 8.8.8.8 || ip addr add 192.168.1.1/24 dev eth0..is bit risky because if SSH connection drops immediately after the IP address change, then shell should be also killed and ping -c1 8.8.8.8 || ip addr add 192.168.1.1/24 dev eth0 part is never executed? Should one use crontab in case of dangerous changes on a remote host? Any other clever method?
How to rollback network configuration changes done over SSH in case of failure?
networking;ssh;command line;remote
In a screen or tmux session, set up a shell that will reverse your changes after a delay. I don't know anything about iptables, so can't help with that, but something like this has saved my proverbial bacon on numerous occasions while altering live firewall configs on FreeBSD:# In one `screen` or `tmux` window% sleep 60 && <command to reverse changes>In another window, you can now make your changes, and if they work you can kill the sleep. Note that because we're using &&, the command to back out your changes won't be run when you kill sleep.If your changes don't work, wait a few seconds and your back out command will run.