Skip to contentSkip to conversation

How to get VM IP address through XenStore

DISCUSSION jian zhang 3 participants 3 messages Jun 10, 2008

lore
Share & tools
lore
#1 lore raw
Quoted 3 lines

Hi all:
I am wondering how to get current VM IP address in XenStore, does it contains such information??

No, it does not. xenstore keeps layer 2 (eg MAC address) information, but has no visibility to layer 3 (IP) and above.

What you need to do is:
1. get the mac address from xenstore
2. watch IP traffic on your network with that src or dst mac address
3. extract the IP address from that packet
4. repeat 2-3 if you suspect that there is more than one IP address attached to that mac address.

If the mac address belongs to a router then you'll see heaps of IP addresses attached to it, so the exercise may be futile... you should only see one on the 'local' subnet though.

You could also try a scan of the network subnet to figure it out.

I just did a google search for "ip address from mac address" and there are lots of people asking much the same question but I didn't come across any useful answers.

James

#2 lore raw
Quoted 5 lines · James Harper

I just did a google search for "ip address from mac address" and there are lots of people asking much the same question but I didn't come across any useful answers.

My favourite method is "ping -b -c 1 <broadcast-addr>" and then look for the MAC address in /proc/net/arp. There are numerous cases where it doesn't work, but it works often enough to be useful. If you're using DHCP and you can get to the DHCP server you can also ask it about the mapping.

Finally, there's reverse ARP and rarpd which could be made to be useful if you could watch for ARP requests and use them to build up a /etc/ethers file.

jch