Skip to content

Instantly share code, notes, and snippets.

@kelvinji2009
Forked from lsloan/vagrant_host.md
Created June 15, 2018 05:30
Show Gist options
  • Save kelvinji2009/7a6a16e28a7078a0aac85951009e789b to your computer and use it in GitHub Desktop.
Save kelvinji2009/7a6a16e28a7078a0aac85951009e789b to your computer and use it in GitHub Desktop.
Vagrant: host IP address from guest perspective

Unless specified otherwise in Vagrantfile, the IP address of the host (the computer running Vagrant) from the perspective of the guest (the VM being run by Vagrant) is: 10.0.2.2

If that IP address doesn't work, then examination of Vagrantfile should reveal directives that changed it from its default value.

If an IP address can't be found in Vagrantfile, then the following command will probably reveal it:

route -A inet

For example, the output may be:

Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
default         10.0.2.2        0.0.0.0         UG    0      0        0 eth0
10.0.2.0        *               255.255.255.0   U     0      0        0 eth0
192.168.33.0    *               255.255.255.0   U     0      0        0 eth1

The desired IP address is the Gateway address of the default destination, which in this case is 10.0.2.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment