參考資料:
https://stackoverflow.com/questions/62530575/vboxmanage-cant-get-vm-ip-address
https://superuser.com/questions/634195/how-to-get-ip-address-assigned-to-vm-running-in-background
沒有安裝VirtualBox Extension Pack時
$ VBoxManage list hostonlyifs
Name: vboxnet0
GUID: 786f6276-656e-4074-8000-0a0027000000
DHCP: Disabled
IPAddress: 192.168.56.1
NetworkMask: 255.255.255.0
IPV6Address: fe80::800:27ff:fe00:0
IPV6NetworkMaskPrefixLength: 64
HardwareAddress: 0a:00:27:00:00:00
MediumType: Ethernet
Wireless: No
Status: Up
VBoxNetworkName: HostInterfaceNetworking-vboxnet0
$ VBoxManage showvminfo ubuntu-20.04_x64 | grep "Host-only"
NIC 2: MAC: 080027B85F8A, Attachment: Host-only Interface 'vboxnet0', Cable connected: on, Trace: off (file: none), Type: 82540EM, Reported speed: 0 Mbps, Boot priority: 0, Promisc Policy: deny, Bandwidth group: none
$ arp -a | grep vboxnet0
? (192.168.56.100) at 08:00:27:52:5e:ae [ether] on vboxnet0
? (192.168.56.101) at 08:00:27:b8:5f:8a [ether] on vboxnet0
P.S. 缺點就是需要先ping通才會有arp table
安裝VirtualBox Extension Pack時
$ vboxmanage guestproperty enumerate virus_debug_win7x86 | grep IP
Name: /VirtualBox/GuestInfo/Net/0/V4/IP, value: 10.0.2.15, timestamp: 1691981523267435000, flags:
Name: /VirtualBox/GuestInfo/Net/1/V4/IP, value: 192.168.56.102, timestamp: 1691981528336005000, flags: