I wrote the way to check host machine IP address from VirtualBox guest machine connected as NAT. Substantially speaking, it is the gateway address of the guest machine.
History
When I launched Kotlin API server in Host, Windows, and Launched Rails Web application in Guest Linux, I needed to know the host machine IP address for accessing to the API.
Environment
- Host: Windows 10
- Guest: Ubuntu 17.10
- VirtualBox version 5.1.30
Method
Use command, netstat -rn
, in the guest.
1 2 3 4 5 6 |
% netstat -rn Kernel IP routing table Destination Gateway Genmask Flags MSS Window irtt Iface 0.0.0.0 10.0.2.2 0.0.0.0 UG 0 0 0 enp0s3 10.0.2.0 0.0.0.0 255.255.255.0 U 0 0 0 enp0s3 |
The IP address appears in gateway section is the host OS IP address. In above case, 10.0.2.2.