I have VMWare workstation 12:
HOST $ vmware --version
VMware Workstation 12.0.0 build-2985596
And vagrant-vmware-workstation 4.0.1:
HOST $ vagrant plugin list
vagrant-libvirt (0.0.30)
vagrant-share (1.1.4, system)
vagrant-vmware-workstation (4.0.1)
The guest is running:
HOST $ vagrant status
Current machine states:
default running (vmware_workstation)
The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down, or you can run `vagrant suspend` to simply suspend
the virtual machine. In either case, to restart it again, run
`vagrant up`.
I have forwarded port 80 on the host to port 80 on the guest:
HOST $ grep ' 80,' Vagrantfile
config.vm.network "forwarded_port", guest: 80, host: 80, auto_correct: true
However, I have a web server on the host, so Vagrant has allocated another port for the forward. In this case it is port 2201:
HOST $ cat .vagrant/machines/default/vmware_workstation/forwarded_ports
{"5280":5280,"5222":5222,"9001":9001,"9002":9002,"9003":9003,"9004":9004,"9999":9999,"5555":5555,"2200":27017,"2201":80,"8083":8083,"8086":8086,"3000":3000,"2222":22}
This seems to be true:
HOST $ sudo netstat -lnpt --inet|grep 2201
tcp 0 0 0.0.0.0:2201 0.0.0.0:* LISTEN 5706/vmnet-natd
However, I get a connection but no data on that port:
HOST $ timeout 5 HEAD http://localhost:2201 || echo "Timed out"
Timed out
But the port is available and quite chatty from inside the guest:
HOST $ vagrant ssh
Last login: Wed Sep 9 12:36:39 2015 from 172.16.203.1
[vagrant@localhost ~]$ HEAD http://localhost:80
200 OK
Connection: close
Date: Wed, 09 Sep 2015 12:39:06 GMT
Server: Apache/2.2.15 (CentOS)
Content-Type: text/html; charset=UTF-8
Client-Date: Wed, 09 Sep 2015 12:39:06 GMT
Client-Peer: 127.0.0.1:80
Client-Response-Num: 1
X-Powered-By: PHP/5.3.3
[vagrant@localhost ~]$
Looking into VMWare Virtual Network Editor at the NAT device I see an empty list of port forwards both for my user and for root.
As we saw, we can ssh to the machine, so the 2222 port is forwarded fine:
HOST $ nc localhost 2222
SSH-1.99-OpenSSH_5.3
How do I debug this further?
Also, why is vmnet-natd bound to
0.0.0.0:2201 when no host_ip was specified in the Vagrantfile? Shouldn't it default to localhost only?
- Robert