VM's should show their assigned IP address


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.

  • Upvote 4
Link to comment

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.

  • Like 1
Link to comment
  • 1 month later...

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
Link to comment
  • 7 months later...

+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
Link to comment
  • 8 months later...
  • 2 years later...

arp -n should provide a list of Mac addresses know to Unraid. Issue is if the server is not talking directly to the guest then there will not be an Arp entry.

 

brctl showmacs br0 will show all of the MAC-ADDR the bridge knows about, but there is no easy way to map MAC to IP, i.e. RARP or INAPR i have been able to find a way to do in linux.

 

Also I can get the MAC addresses for the VM via Virsh but its the MAC to IP address which is the challenge without pinging every IP on the local sbnet to create arp entries.

 

 

Link to comment
44 minutes ago, SimonF said:

Also I can get the MAC addresses for the VM via Virsh but its the MAC to IP address which is the challenge without pinging every IP on the local sbnet to create arp entries.

If you've got a recent version of qemu-agent installed on the VM, try this one

virsh qemu-agent-command MYDOMAIN '{"execute":"guest-network-get-interfaces"}' --pretty

 

  • Like 1
Link to comment
  • 2 months later...
On 1/23/2022 at 1:20 PM, tjb_altf4 said:

If you've got a recent version of qemu-agent installed on the VM, try this one

virsh qemu-agent-command MYDOMAIN '{"execute":"guest-network-get-interfaces"}' --pretty

 

Added a PR using the guest agent to get IP addresses for guest

 

image.thumb.png.afe69fc87fb421845dc7b8fa511b6214.png

Edited by SimonF
  • Like 1
Link to comment
  • 3 weeks later...

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.