Jump to content
busa1

VM's should show their assigned IP address

10 posts in this topic Last Reply

Recommended Posts

It would be so convenient for users who run multiple VM's if their local IP would just show up right next to the VM image, so when a user boots it up, it would just show it. 

Also would like to see ipv6 support, and automatic assignment for such vm's within unraid.

Share this post


Link to post

I'm not sure the host os can determine the IP address of the virtual Nic that is passing through the bridge to an external router acquired via dhcp in the manner you are asking, especially since the ip can change if you aren't using static assignments in the vm. Even if it could, it wouldn't be able to show it at boot and would have to update after the vm has checked in with the router.

 

but I could also be way wrong.

Share this post


Link to post

Maybe it should just get the last known IP of the VM then. IPs for the VMs change not that frequently

 

Share this post


Link to post

This would be nice to have, especially if the IP is dynamic. I was curious about this and we already know the mac address for each VM as it is in each vm's xml file, so we can probably get the ip using arp command or something similar.

Share this post


Link to post

I do the same, but I would still love to know what the IP is. Right now I have the last group in the description. 

Ie - Gaming VM with IP 192.168.1.112 gets a description of " 112 | A VM for games".

 

So +1, would definitely be nice to have a more automatic solution for this.

Edited by -Daedalus

Share this post


Link to post
Posted (edited)

+1 to this suggestion, would be very handy, whether you use DHCP reservations or not.

 

There are supposed to be a couple of methods via virsh or qemu-guest, but they're not working for me or seem to be disabled.

I found a bash script that works well for me though and should be generic enough.

HOSTNAME=YOURVMNAMEHERE
MAC=$(virsh domiflist $HOSTNAME | awk '{ print $5 }' | tail -2 | head -1)
arp -a | grep $MAC | awk '{ print $2 }' | sed 's/[()]//g'

Or seeing as we already now the mac address from the vm template the script can be simplified further:

MAC=YOUR:MAC:ADDRESS:HERE
arp -a | grep $MAC | awk '{ print $2 }' | sed 's/[()]//g'

 

Edited by tjb_altf4

Share this post


Link to post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.