Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I am using CentOS.

I have a management server which has password-less ssh access to four other servers. I don't have physical access to these servers. In other words, I have to make all configurations over ssh.

I want to create a bash script on the management server to change the IP address for the other servers, but if I give a wrong IP (ex. the IP used in network), the management server will lose access to the other server.

What can I do to prevent or mitigate this problem?

share|improve this question
    
Have you tried running the script with nohup? –  terdon May 9 at 13:27
1  
Sounds like a perfect use case for dns, or a a systems management software like: puppet, ansible, chef or salt stack. –  spuder May 9 at 19:49
1  
Good practice is to have at least 2 network interfaces on each server, one of which is on a dedicated management network. If you need to change IP addresses, change just one interface's address at a time, so that you never lose connectivity. –  Mark Plotnick May 10 at 0:48

1 Answer 1

up vote 7 down vote accepted

Assuming I'm reading correctly, your problem isn't that you want to know how to change the IP address, it's that you want to prevent changing it to something that stops future access.

This isn't necessarily a technical problem, it's a quality issue. However, you might try something like this (you'll need to work out how to achieve it in detail).

  • Write a script that you run on the remote host.
  • That script changes the IP address, and then pings the management_server.
  • If the ping works, the script exits.
  • If the ping fails, the script sets the IP address back to the original and then exits.

If you're actually asking 'I can't get to my server because it's got the wrong IP address, what can I do?' then that's significantly different, and you'll need to speak to whoever does have physical access so they can fix it.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.