Created
June 15, 2019 20:11
-
-
Save njregenwether/8a972519bf35bc69c1f792b8dbed6743 to your computer and use it in GitHub Desktop.
Very simple procedure for testing a network change without losing access to the server.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| If you are considering making a network change and don't want to risk a down machine that you would then have to console into... here's what to do. | |
| 1. Copy your working network configuration | |
| cp /etc/network/interfaces /etc/network/interfaces.working.bak | |
| 2. Make your changes to the network connection | |
| cat /etc/network/interfaces.withchanges > /etc/network/interfaces | |
| 3. Create a script to undo the change | |
| vi /root/reset_net.sh | |
| In the file | |
| #!/bin/bash | |
| cat /etc/network/interfaces.working.bak > /etc/network/interfaces | |
| systemctl restart networking.service | |
| 4. Change permissions | |
| chmod 750 /root/reset_net.sh | |
| 5. Run crontab -e | |
| */5 * * * * /root/reset_net.sh | |
| 6. Restart networking services (this will apply your changes from step 2. | |
| If your machine has no network after that, on the 5th minute, | |
| it will reapply the working configuration and restart networking services. | |
| systemctl restart networking.service | |
| 7. If you still have access to the system and everything is working okay, | |
| vi /root/reset_net.sh | |
| Comment out the line you added | |
| #*/5 * * * * /root/reset_net.sh | |
| Done. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment