How to get the ip address of an VM in Xen without logging in?

2

I'm using xen virtualization with a dhcp server. Whenever I create a new VM an ipaddress is assigned by the dhcp server. I'm working remotely and have to use only command line, so logging into the VMs I create is a pain without knowing the ipaddress (static ip is not allowed). Is there an elegant way to find the ipaddress of the vm before logging into it?

Currently I use nmap to scan the port and take my best guess at the open ssh ports.

0x0

Posted 2012-06-19T18:05:20.427

Reputation: 267

Answers

3

If you're assigning IP addresses with a DHCP server then you can read the leases file to see which addresses have been leased to which MAC addresses. You can set a static MAC address for the Xen domain in its config file.

For example, with ISC DHCP on Debian you will find the leases file at /var/lib/dhcp3/dhcpd.leases

On many DHCP server implementations you can also have it send a DNS update when it acknowledges a lease, so if you configure your DNS infrastructure properly you can just connect by host name.

Also on some DHCP server implementations you can have a script execute when a lease is acknowledged, so you could work something out with that.

grifferz

Posted 2012-06-19T18:05:20.427

Reputation: 676

0

I run Xen with Fedora Domain0 and use libvirt managed dnsmasq for dhcp. My leases are found in /var/lib/libvirt/dnsmasq/default.leases

J J

Posted 2012-06-19T18:05:20.427

Reputation: 111