Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a few Ubuntu server boxes set up on ESX, and I changed the IP addresses via SSH. The moment I changed it, it dropped me off of SSH (as expected).

After a restart it works 100% as expected and I can SSH in on the new IP.

However, as much as this works and I know it is a solution, I am trying to learn Linux and would like to restart/bind SSH to the new IP without restarting.

I have attempted /etc/init.d/ssh restart (and stop then start), and services ssh restart (and stop then start), but, nothing seems to work.

However, the weird thing is that from my other server (running on the same ESX box) I can SSH in on the new IP, but, I just can't seem to SSH in from anywhere else until the box is restarted.

I can't work out what I am doing wrong.

Has anyone seen this or can they offer any advice?

(if it changes anything, the IPs I was moving from/to are all internet/public directly routed IPs)

share|improve this question
Cannot it be an issue related to ESX? – enzotib Nov 25 '11 at 8:07
should work. I would netstat -plant after the service restart and see where ssh is bound to just to confirm both of our sanities. then try a nc ip <newport> banner grab. then ssh in. – jedijf Mar 3 '12 at 1:37
Did you restart the network interface? I'm not sure, but it seems like the SSH server is simply bound to a port, not an IP (although it may need to be restarted after the network to get a new socket). I think you can probably just disconnect/reconnect from the panel GUI (I usually do it that way successfully), or if you want to use the terminal, use a command such as 'sudo ifconfig eth0 down', then 'sudo ifconfig eth0 up'. – Marty Fried Mar 6 '12 at 18:12

I have a hunch this is related to ARP, which can be sometimes funky with virtual machines. From another virtual server on the same box, you can connect, as you're not going through the switch.

To test this, first try clearing the ARP tables on the machine from which you're trying (and failing) to connect:

sudo arp -d <ip-of-failing-virtual-machine>

If that doesn't help, try resetting the ARP table on your switch (one easy way to do it: reset the switch :)

share|improve this answer

It the configuration of openssh-server is untouched (the default one) then you don't even need to restart ssh in order for him to listen onto the new IP you set.

Your trouble is more like how you change your IP.

I don't know how you do it so I'll cover all cases

I advise you to not use the GUI : network-manager. It's very poor in functionality and does not fit your need for remote changes. (any graphical interface is quite a bad idea on a server because it adds you potential risks and consume constantly resources for 5 minutes of use)

My advice would be to edit /etc/network/interface

See this help : Network Configuration on Ubuntu 11.10 and most importantly the "IP Addressing" part.

Be sure to not use the hotplug statement witch can leads you in trouble.

changing the IP with ifconfig is a bad idea : it's temporary and it do directly the change so you can't set/unset other network settings

Now the real trick :

(ifconfig appart) : The very act of changing the same IP of your SSH session is in fact two procedures for Ubuntu : Stop the interface and then Start the interface.

So what you use is a script, and when the interface stops your ssh session closed .... and so your script. So your interface never start again.

in order to avoid your script being closed you must the script in background :

sudo -i
nohup service networking restart &

It'll send your script to the background and so it'll not be closed when your ssh session close.

You'll loose then your ssh session, but you'll be able to connect again into your server without restarting. (leave it a little time if you are defining a new dhcp ip or if it's wifi)

If this doesn't work for you please give us more details on how you proceed.

Best regards.

share|improve this answer

When you change your ip address, do you add the default route? Seems to me like because you didn't add the default route, the computer is unable to access, and be accessed from, outside. Lets say you changed your ip address so, as root:

ip addr del <old ip/netmask> iface
ip addr add <new ip/netmask> iface

After you do this, you need to add the default route, which, if not done, won't let your server connect to the internet. To be accessible outside, the default route needs to be added:

route add default gw <gateway ip address>

Hope that solves the problem.

share|improve this answer

Do your iptables rules prohibit any incoming connections to any IP other than your own? It might be updated automatically on reboot - it would be unusual I think, I've never seen it done, but it would explain this behaviour.


iptables -L

and see if any of the rules in there look responsible for filtering incoming connections to the IP your machine has(had).

share|improve this answer
IPTables looks blank :( – wilhil Nov 24 '11 at 10:54

Check you sshd_config in /etc/ssh

and check if there is a listen adres in config for example:


If thats there change to right adres and do a service ssh restart

share|improve this answer
Because rebooting solves the issue, but restarting sshd does not, we know that the user either has his configuration set up to run on any ip, or he is manually changing it correctly. – earthmeLon Mar 28 '12 at 2:18

Your Answer


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.