I'm using the VirtualBox NatNetwork type to connect most of my VMs to the host (with the required ports set up for forwarding). I'd like to know how I can connect to the local loopback ("localhost") of the host from inside the VM (e.g. use apt-cacher-ng inside the VM).

The usage of NAT with connections to IPs of interfaces of the host is clear for me and works.

I'm using VirtualBox 4.3.10 on Ubuntu 14.04 with Linux 3.11.13.


Try on the Virtual Machine. It should hit on your Host Machine. is gateway IP on the Virtual Machine in NAT mode since the Host Machine provides the networking for the Virtual Machine. (Similar to how your gateway IP is the IP to your router, and is the IP you use to bring up the router management page)

|improve this answer|||||
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post. - From Review – Ramhound Sep 26 '16 at 16:35
  • Yes this answers the question. Maybe I wasn't clear but on the VM will hit on the Host, in NAT mode. – byoungb Sep 26 '16 at 20:38
  • "ry (the gateway IP) on the Virtual Macing. It should hit on your Host Machine." - My automatic comment was because your original answer contained a single sentence. If you disagree with that comment just improve the answer. You don't need to reply to the comment. – Ramhound Sep 26 '16 at 20:44
  • Yeah I looked for documentation on this but couldn't find it otherwise I would have added a link. I did update my answer to be more complete – byoungb Sep 26 '16 at 20:53
  • The answer has improved slightly. – Ramhound Sep 27 '16 at 14:17

Use this forwarding rule: e.g., forwarding ssh traffic

Host IP:
Host Port: xxx
Guest IP : Blank
Guest Port: 22
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.