Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-11-2015, 11:11 AM   #1
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?

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

Rep: Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116Reputation: 2116
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 11:20 AM.
1 members found this post helpful.
Old 03-11-2015, 02:42 PM   #3
Senior Member
Registered: Aug 2011
Location: Dublin
Distribution: Centos 5 / 6 / 7
Posts: 2,574

Rep: Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929Reputation: 929
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, 02:45 AM   #4
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...


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 06:48 PM
how to find the os of a remote machine through its ip address.. secretsayan Linux - Networking 7 03-04-2012 08: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 12:34 PM
data shift from 1 remote machine to another remote machine raheelch General 7 03-09-2010 09:44 AM
How to find an IP address from the MAC address of a remote machine ? jitz Linux - General 3 01-03-2006 08:55 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:53 AM.

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