{"id":12301,"date":"2023-04-09T21:46:55","date_gmt":"2023-04-09T16:46:55","guid":{"rendered":"https:\/\/alexeyka.zantsev.com\/?p=12301"},"modified":"2023-05-19T14:50:03","modified_gmt":"2023-05-19T09:50:03","slug":"virtualbox-mastering-console-usage-starting-stopping-restarting-vms-getting-vms-ip-addresses","status":"publish","type":"post","link":"https:\/\/alexeyka.zantsev.com\/?p=12301","title":{"rendered":"VirtualBox: mastering console usage, starting\/stopping\/restarting VMs, getting VM&#8217;s IP addresses"},"content":{"rendered":"\n<p>A new post after nearly a year of lull!<\/p>\n\n\n\n<p>Imagine the situation when there is some remote host machine with several VMs. You have an SSH access to host machine, but no VNC to manage easily those VMs, even doing the most elementary actions.<\/p>\n\n\n\n<p>Listing all your VMs:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-vivid-red-color has-text-color\">alexey@amd:~$ vboxmanage list vms\n\"centos7-orig\" {e4077fae-1be5-42f4-ae40-b399f98c6e3d}\n\"debian9.rtpengine\" {d2fb6655-29ab-4103-a70c-b7234c835a79}\n\"debian9.opensips1\" {757f6235-27d4-470d-a461-c12fbfe0cfd7}\n\"debian9.opensips2\" {09b11945-d696-409d-b90b-e5f2b5af6c4a}\n\"centos7-ast-16\" {21eaceac-f85e-4622-a52b-c586352aa9eb}\n\"centos7-rtpengine8\" {935a0191-a17e-4c95-8cf4-022f7ad1a398}\n\"centos7.osips3.2\" {e39ddc59-70cc-4bcb-8f6d-3b6bd9e78d3d}\n\"centos7.osips3.2_node2\" {ecb64a86-aa90-4f53-bd12-5bb253d02058}\n<\/pre>\n\n\n\n<p id=\"block-2c2d6a7b-e8aa-4e2f-b845-79a6d021ae46\">Listing all your <em>running<\/em> VMs:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-vivid-red-color has-text-color\">alexey@amd:~$ vboxmanage list runningvms<\/pre>\n\n\n\n<p id=\"block-2c2d6a7b-e8aa-4e2f-b845-79a6d021ae46\">Starting VM (vm remains working even if you log out from host machine):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-vivid-red-color has-text-color\">alexey@amd:~$ vboxmanage startvm centos7-ast-16\nWaiting for VM \"centos7-ast-16\" to power on...\nVM \"centos7-ast-16\" has been successfully started.<\/pre>\n\n\n\n<p>Stopping VM:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-vivid-red-color has-text-color\">alexey@amd:~$ vboxmanage controlvm centos7-ast-16 poweroff\n0%...10%...20%...30%...40%...50%...60%...70%...80%...90%...100%<\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p><\/p>\n\n\n\n<p>The more the better.<\/p>\n\n\n\n<p>Now I would like to get the IP address of some VM. But there is no any way to do it until we use <a rel=\"noreferrer noopener\" href=\"https:\/\/www.virtualbox.org\/manual\/ch04.html\" target=\"_blank\">GuestAdditions<\/a>. I mean that you&#8217;ve already started your VM with the appropriate console command and now need to log in via SSH, but you don&#8217;t know it&#8217;s IP address (e.g. in case of <a rel=\"noreferrer noopener\" href=\"https:\/\/www.virtualbox.org\/manual\/ch06.html#network_bridged\" target=\"_blank\">bridged network<\/a> settings of the VM).<\/p>\n\n\n\n<p>To be able to see VM&#8217;s IP address from host&#8217;s machine console, you have to install VitualBox to your <em>guest<\/em> machine. Then you need to &#8220;insert&#8221; an .iso containing GuestAdditions to your <em>guest<\/em> machine (the easiest way is to do it using VirtualBox GUI, but I&#8217;m sure there is also a console command). <\/p>\n\n\n\n<p>If the VM&#8217;s cd-rom with this .iso is not mounted automatically, do it manually:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-vivid-red-color has-text-color\">[root@flexisip ~]# mount \/dev\/cdrom \/mnt\/cdrom\/<\/pre>\n\n\n\n<p>After that the .iso&#8217;s files are available:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-vivid-red-color has-text-color\">[root@flexisip cdrom]# ls -l \/mnt\/cdrom\/\ntotal 47008\n-r--r--r--. 1 root root      763 feb 20  2020 AUTORUN.INF\n-r-xr-xr-x. 1 root root     6384 jan 14  2022 autorun.sh\ndr-xr-xr-x. 2 root root      792 jan 14  2022 cert\ndr-xr-xr-x. 2 root root     1824 jan 14  2022 NT3x\ndr-xr-xr-x. 2 root root     2652 jan 14  2022 OS2\n-r-xr-xr-x. 1 root root     4821 jan 14  2022 runasroot.sh\n-r--r--r--. 1 root root      592 jan 14  2022 TRANS.TBL\n-r--r--r--. 1 root root  4029558 jan 14  2022 VBoxDarwinAdditions.pkg\n-r-xr-xr-x. 1 root root     3949 jan 14  2022 VBoxDarwinAdditionsUninstall.tool\n-r-xr-xr-x. 1 root root  7474611 jan 14  2022 VBoxLinuxAdditions.run\n-r--r--r--. 1 root root  9439232 jan 14  2022 VBoxSolarisAdditions.pkg\n-r-xr-xr-x. 1 root root 16895432 jan 14  2022 VBoxWindowsAdditions-amd64.exe\n-r-xr-xr-x. 1 root root   270840 jan 14  2022 VBoxWindowsAdditions.exe\n-r-xr-xr-x. 1 root root 10000520 jan 14  2022 VBoxWindowsAdditions-x86.exe\n-r--r--r--. 1 root root      259 oct  4  2021 windows11-bypass.reg<\/pre>\n\n\n\n<p>Now we need to install GuestAdditions to the <em>guest<\/em> machine (VM):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-vivid-red-color has-text-color\">[root@flexisip ~]# cd \/mnt\/cdrom\n[root@flexisip cdrom]# sh .\/VBoxLinuxAdditions.run \nVerifying archive integrity... All good.\nUncompressing VirtualBox 6.1.32 Guest Additions for Linux........\nVirtualBox Guest Additions installer\nCopying additional installer modules ...\nInstalling additional modules ...\nVirtualBox Guest Additions: Starting.\nVirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel \nmodules.  This may take a while.\nVirtualBox Guest Additions: To build modules for other installed kernels, run\nVirtualBox Guest Additions:   \/sbin\/rcvboxadd quicksetup &lt;version&gt;\nVirtualBox Guest Additions: or\nVirtualBox Guest Additions:   \/sbin\/rcvboxadd quicksetup all\nVirtualBox Guest Additions: Building the modules for kernel \n3.10.0-1160.88.1.el7.x86_64.<\/pre>\n\n\n\n<p>And now you can see VM&#8217;s IP address from your <em>host<\/em> machine console (NAT network settings):<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-vivid-red-color has-text-color\">alexey@amd:~$ VBoxManage guestproperty get centos-flexisip \"\/VirtualBox\/GuestInfo\/Net\/0\/V4\/IP\"\nValue: 10.0.2.15<\/pre>\n\n\n\n<p>The same for bridged networking:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-vivid-red-color has-text-color\">alexey@amd:~$ VBoxManage guestproperty get centos-flexisip \"\/VirtualBox\/GuestInfo\/Net\/0\/V4\/IP\"\nValue: 192.168.88.239<\/pre>\n\n\n\n<p>More VM properties:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-vivid-red-color has-text-color\">alexey@amd:~$ VBoxManage guestproperty enumerate centos-flexisip<\/pre>\n\n\n\n<p>But this command still does not show the IP address of the VM, though it shows its MAC:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted has-vivid-red-color has-text-color\">alexey@amd:~$ vboxmanage showvminfo centos-flexisip<\/pre>\n\n\n\n<p>After this you may unattach an .iso from your VM cd-rom.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>A new post after nearly a year of lull! Imagine the situation when there is some remote host machine with several VMs. You have an SSH access to host machine, but no VNC to manage easily those VMs, even doing the most elementary actions. Listing all your VMs: alexey@amd:~$ vboxmanage list vms &#8220;centos7-orig&#8221; {e4077fae-1be5-42f4-ae40-b399f98c6e3d} &#8220;debian9.rtpengine&#8221; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[47],"class_list":["post-12301","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-virtualbox"],"_links":{"self":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/12301","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=12301"}],"version-history":[{"count":13,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/12301\/revisions"}],"predecessor-version":[{"id":12318,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=\/wp\/v2\/posts\/12301\/revisions\/12318"}],"wp:attachment":[{"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=12301"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=12301"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/alexeyka.zantsev.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=12301"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}