Server Fault is a question and answer site for system and network administrators. 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've got several VMs set up here, all running linux (mostly centos but 1 ubuntu). I connect to them over SSH, but it's annoying having to go back to the VM server to check on IP addresses. Also, on reboot they usually get a different IP due to the network setup here, which I have no control over.

What's the easiest way for me to track all the IPs that my VMs are using?

share|improve this question
up vote 1 down vote accepted

Is it a requirement that you use bridge mode, versus NAT mode? Cause of course if you have NAT enabled, then you could forward various different ports for your ssh access, and the IP (and of course port) would remain constant through reboots.

You can find details on this in the VirtualBox 3.1.2 user manual, section #6.3.1 "Configuring port forwarding with NAT".

Another thought: I cannot help but notice that my IP address shows up in my virtual machine's XML file:

        value="" timestamp="1261587087753023000"

(On linux, you can find this in ~/.VirtualBox/Machines/MyVMName/MyVMName.xml)

So especially if you are using vboxmanage to start/stop your VMs, you could grep the machine's xml and update "something" -- like a web page, or a text file? -- so you'd always know the IP address of each VM. I'm guessing this will work regardless of whether you're using NAT or bridged networking, though I haven't personally tried it...I have a static IP in my VM. I don't know who/when/where this value gets updated in the XML file. Presumably VBox updates it when it detects a DHCP reply it needs to redirect to the VM.

share|improve this answer

A lot of your options depend on your exact network configuration. Most of the easy options involve some network modification, which you indicate is not the case. Here are some options given that constraint:

  • If you use a Microsoft DHCP server integrated with Active Directory, then you may be able to register the hostname with the Active Directory, and inherit a DNS name. Check out I believe that DHCP_HOSTNAME needs to be set. I've never actually done this, so there may be additional steps to make this work within a Microsoft context (perhaps having all the machines joining the domain, etc).
  • If your looking for a pure Linux solution, you may want to look at the avahi daemons. It uses multicast DNS to push hostnames and services on a local network. Assuming avahi is running on all your boxes, you should be able to edit /etc/nsswitch.conf, verify that mdns4 or mdns4_minimal is included on the hosts line, and should be able to resolve the hostname for all your servers directly. Again, I've not set this up in a production environment, so there might be other configuration that is required.

Both of these are pretty messy, so your much better off working with whomever manages your network to get static IPs and DNS names, as Chopper3 mentions. You might even be able to get away with static DHCP assignments, and then modify the hosts files, but again requires cooperation of your network team.

share|improve this answer
+1 to everything said here. Absent any possibility of cooperation from your netops team, I'd say that mDNS is probably going to be your least-worst option. – womble Dec 30 '09 at 2:15
I wish I could mark more than 1 item as accepted answer - this is a great solution... both this and the NAT solution work. – Jon Haddad Feb 5 '10 at 22:42

Setup a cronjob that makes a wget to a .php file that tells the hostname of the machine and the ip and you done.

share|improve this answer
I would only get it at boot time, but yeah, good idea. – David Mackintosh Dec 30 '09 at 1:49

When the machines get an IP address via DHCP on the network, do they not get DNS as well? eg. you should be able to connect to them via their hostname, which would stay static.

You could run all the virtual machines within their own "Virtual Network" and run your own DHCP/DNS/router which connects to the real network, but you'd still need your network admin to add route/dns forwarding which he might not like.

The other way of doing it, and which would leave you in some control, would be to cheat and use one of those external dns services. eg: is a free service that lets you have a static hostname that gets mapped to a dynamic IP address. They also have a tonne of clients for various OS's to keep this upto date. Usually, you'd have this set to an external address (eg your home router) so you can just remember rather than or whatever its changed to recently.

In your situation, I would do similar for each of your virtual machines. Set yourself up an account and get a hostname for each machine. Install the client tell them to keep updates. So you end up with and it points to 192.168.x.x or whatever IP you've just been given.

-saying that, could you not just ask your network admin for a block of static address's?

share|improve this answer

Static IP's and a text editor

share|improve this answer
I don't have the option to use static IPs, as I mentioned above. – Jon Haddad Dec 29 '09 at 23:48
Ah, sorry, kind of misread/musunderstood that. – Chopper3 Dec 30 '09 at 1:02

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.