I dug in to some different configurations in VVV today and decided to write them up as I went. This will be posted in some form to the VVV wiki as well. There are other networking configurations available in Vagrant, though I’m not sure that any would be useful in development with VVV.
I would recommend using default settings for initial provisioning as things can get quirky inside the VM when trying to access outside sources. Run
vagrant reload to process any network configuration changes.
Private Network (default)
config.vm.network :private_network, ip: “192.168.50.4”
This is the default configuration provided in VVV. A private network is created by VirtualBox between your host machine and the guest machine. The guest is assigned an IP address of
192.168.50.4 and your host machine is able to access it on that IP. VVV is configured to provide access to several default domains on this IP address so that browser requests from your host machine just work.
Outside access from other devices to this IP address is not available as the network interface is private to your machine.
config.vm.network “forwarded_port”, guest: 80, host: 8080
One option to provide other devices access to your guest machine is port forwarding. Uncommenting or adding this line in VVV’s
Vagrantfile and then running
vagrant reload will cause any traffic on port 8080 directed at your host machine to instead communicate with port 80 on the guest machine.
This configuration will work with private or public IP configurations as it deals with port forwarding rather than the IP of the virtual machine itself.
An immediate way to test this once configured would be to type your host machine’s IP address into a browser followed by
:8080. With port forwarding enabled, something like
http://192.168.1.119:8080 would bring up the default VVV dashboard.
Of course, this doesn’t do you much good with the default WordPress sites, as you’ll be stuck adding port 8080 to every request you make.
The easiest hack around this is to setup port forwarding on your router. Point incoming requests for port 80 to port 8080 on the IP address of your host machine. Requests through the router will then traverse ports
80 (public IP) -> 8080 (host) -> 80 (guest) and your development work can be shared with devices inside and outside of your network.
Say my router’s public IP is
18.104.22.168 and my computer’s local IP is
- Enable port forwarding in
- Configure router to forward incoming port 80 to port 8080 on 192.168.1.100.
src.wordpress-develop.22.214.171.124.xip.ioon my phone, connected through LTE.
There are other things you can do on your local machine to reroute traffic from 80 to 8080 so that it forwards properly without the use of a router. Sal Ferrallelo has posted steps to take advantage of port forwarding directly in OSX using
Replacing our default private network configuration with a public network configuration immediately provides access to other devices on your local network. Using this configuration without specifying an IP address causes the guest machine to request an address dynamically from an available DHCP server—likely your router. During
vagrant up, an option may be presented to choose which interface should be bridged. I chose my AirPort interface as that is what my local machine is using.
==> default: Available bridged network interfaces: 1) en0: Wi-Fi (AirPort) 2) en1: Thunderbolt 1 3) p2p0 4) bridge0 5) vnic0 6) vnic1 default: What interface should the network bridge to? 1
Once the guest machine receives an IP address, access is immediately available to other devices on the network.
vagrant sshand type
ifconfigto determine the IP address of the guest – mine was 192.168.1.141.
src.wordpress-develop.192.168.1.141.xip.ioon my phone, connected to the wireless network.
To me this is most desirable as it provides access to devices on the local network, not to the outside. If you are using public wifi or another insecure network, be aware–this does open your machine up to other devices on that network.
config.vm.network “public_network”, ip: “192.168.1.141”
The same configuration would be available without DHCP by specifying the IP address to use. If you know what subnet your network is on, this may be a shortcut for providing access without having to use
ifconfig inside the guest machine.
The only requirement for your mention to be recognized is a link to this post in your post's content. You can update or delete your post and then re-submit the URL in the form to update or remove your response from this page.
Learn more about Webmentions.