Alvaro,
This thread is very helpful(!), but I'm still unable to access my apache http server on my guest VM.
( I'm running Vagrant 1.5.3, on a mac osx 10.9.2 host machine. )
I'm running a centos 65 image
config.vm.box = "https://developer.nrel.gov/downloads/vagrant-boxes/CentOS-6.5-x86_64-v20140311.box"
and I'm provisioning using puppet.
Note that when I started with vagrant up I got one warning:
Warning: Could not retrieve fact fqdn
and when I start apache httpd I get
[root@localhost vagrant]# service httpd start
Starting httpd: httpd: Could not reliably determine the server's fully qualified domain name, using localhost.localdomain for ServerName
[ OK ]
root@localhost vagrant]# service httpd status
httpd (pid 2751) is running...
My hosts file:
[root@localhost etc]# cat hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
I have the following port forwarding configuration:
config.vm.network :forwarded_port, host: 4567, guest: 80
config.vm.network :forwarded_port, host: 4568, guest: 8080
I can access the apache server from the guest vm of course:
* About to connect() to localhost port 80 (#0)
* Trying ::1... connected
* Connected to localhost (::1) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/
3.16.2.3 Basic ECC zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: localhost
> Accept: */*
>
< HTTP/1.1 403 Forbidden
< Date: Wed, 25 Mar 2015 12:13:53 GMT
< Server: Apache/2.2.15 (CentOS)
< Accept-Ranges: bytes
< Content-Length: 4954
< Connection: close
< Content-Type: text/html; charset=UTF-8
<
...
but not from the host machine (Mac osx 10.9.2)
* Adding handle: conn: 0x7fb52380aa00
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fb52380aa00) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 4567 (#0)
* Trying 127.0.0.1...
I've followed your troubleshooting suggestions, but have not yet figured out the problem:
[root@localhost vagrant]# netstat -anp | grep ':80'
tcp 0 0 :::80 :::* LISTEN 2751/httpd
I'm not sure how to interpret this, but I note that the 0 :::80 might indicate a problem since you in your troubleshooting advice suggested it should look like:
*:80 LISTEN
or
0.0.0.0:80 LISTEN
yes? Therefore, It appears that all ips cannot connect and that might be my problem.
Next you advise to try
iptables -L
( But I don't understand how this might help, or diagnose. )
root@localhost vagrant]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
ACCEPT all -- anywhere anywhere state RELATED,ESTABLISHED
ACCEPT icmp -- anywhere anywhere
ACCEPT all -- anywhere anywhere
ACCEPT tcp -- anywhere anywhere state NEW tcp dpt:ssh
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
Chain FORWARD (policy ACCEPT)
target prot opt source destination
REJECT all -- anywhere anywhere reject-with icmp-host-prohibited
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
If I clean the iptables
[root@localhost vagrant]# iptables -F
[root@localhost vagrant]# iptables -L
Chain INPUT (policy ACCEPT)
target prot opt source destination
Chain FORWARD (policy ACCEPT)
target prot opt source destination
Chain OUTPUT (policy ACCEPT)
target prot opt source destination
It has no effect.
[root@localhost vagrant]# netstat -anp | grep ':80'
tcp 0 0 :::80 :::* LISTEN 2751/httpd
* Adding handle: conn: 0x7fe9fb804000
* Adding handle: send: 0
* Adding handle: recv: 0
* Curl_addHandleToPipeline: length: 1
* - Conn 0 (0x7fe9fb804000) send_pipe: 1, recv_pipe: 0
* About to connect() to localhost port 4567 (#0)
* Trying 127.0.0.1...
Note that when I run vagrant reload
➜ vagrant-centos65 git:(master) ✗ vagrant reload
==> default: Attempting graceful shutdown of VM...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
default: Adapter 1: nat
==> default: Forwarding ports...
default: 80 => 4567 (adapter 1)
default: 8080 => 4568 (adapter 1)
default: 22 => 2222 (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
default: SSH username: vagrant
default: SSH auth method: private key
default: Warning: Connection timeout. Retrying...
default: Warning: Remote connection disconnect. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Mounting shared folders...
default: /vagrant => /Users/.../vagrant-centos65
default: /tmp/vagrant-puppet-1/manifests => /Users/../vagrant-centos65/manifests
default: /tmp/vagrant-puppet-1/modules-0 => /Users/.../vagrant-centos65/modules
==> default: VM already provisioned. Run `vagrant provision` or use `--provision` to force it
So, I've provided a lot of information, because it seems you might be able to advise further.
Thanks and I look forward to your reply.
Ed