LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 03-11-2015, 10:11 AM   #1
bangnagr
Member
 
Registered: Jan 2013
Posts: 48

Rep: Reputation: 4
How to change IP address of remote machine?


Hi all

This is bothering me too much, please tell me how to change IP address of remote machine while using ssh successfully.

I follow these steps:
1. connect to remote server using 'ssh root@server'
2. Edit '/etc/sysconfig/network-scripts/ifcfg-eth0' file
3. issue 'service network restart' command... (at this point ssh connection gets hanged)
4. Break from hanged ssh connection (<ENTER>~.)
5. Wait for some time to let service restart
6. Then finally, ssh with new ip address.

All is fine, but last time, i did something wrong while assigning new IP address, and after service restart, remote server didn't get new ip address - and now i cant connect to remote server.

Fortunately, i had a friend there, who helped me correct the problem so that i can connect again.

But what to do when there is no one to help? Is there other way i should approach this problem?

Thanks
 
Old 03-11-2015, 10:17 AM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
If your server includes IPMI you could use that as a back-door to access the system when it has no network access. Or if your system has two NICs you could wire them both up with different IP addresses, so if you break one you can still connect on the other.

Otherwise, yeah, if you screw up the config and bring down the network on the system, you can't connect over the network anymore. I suppose you could implement a little script to babysit things while you try to reconnect. So instead of modifying the config by hand, instead you invoke a script which makes a backup of the existing config, opens up the config for you to edit, and when you're done it issues a network restart, sleeps for 60 seconds, restores the backup, and issues a network restart again. Then it's up to you to reconnect within 60 seconds and kill the script, otherwise the settings will revert to their previous values.

Last edited by suicidaleggroll; 03-11-2015 at 10:20 AM.
 
1 members found this post helpful.
Old 03-11-2015, 01:42 PM   #3
TenTenths
Senior Member
 
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 3,475

Rep: Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553Reputation: 1553
Assign new IPs as aliases of the relevant adaptor first (e.g. as eth0:0) and test it. Only when you're happy then switch the new IP to eth0 and the old (current) IP to eth0:0

Or always have iLO/DRAC configured
 
1 members found this post helpful.
Old 03-12-2015, 01:45 AM   #4
bangnagr
Member
 
Registered: Jan 2013
Posts: 48

Original Poster
Rep: Reputation: 4
Thank you @suicidaleggroll and @TenTenths, I tried both. Thanks. I better be careful next time...
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Geting Remote IP address from Remote MAC Address hareshmv Linux - Networking 3 05-09-2012 05:48 PM
how to find the os of a remote machine through its ip address.. secretsayan Linux - Networking 7 03-04-2012 07:14 AM
How to change a line in a file and send to a remote machine with rsync danndp Linux - Server 4 11-20-2010 11:34 AM
data shift from 1 remote machine to another remote machine raheelch General 7 03-09-2010 08:44 AM
How to find an IP address from the MAC address of a remote machine ? jitz Linux - General 3 01-03-2006 07:55 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 09:45 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration