2014-04-07 7 views
10

Ich kann keine Verbindung mit dem Internet über eine von mir eingerichtete virtuelle Vagrant-Maschine herstellen.Ausgehende HTTP-Anforderungen von vagrant VM können nicht erstellt werden.

Zum Beispiel an der Wurzel, wenn ich schreibe:

curl http://google.com 

Es mit der Meldung fehlschlägt:

curl: (6) Couldn't resolve host 'google.com' 

Ich bin nicht sicher, ob es eine Firewall-Einstellung, obwohl so weit wie Ich weiß, dass ich keine Firewall-Regeln für Port 80 oder einen anderen Port erstellt habe.

Hier ist der relevante Abschnitt meiner Vagrantfile. Wenn es weitere Informationen gibt, die ich zur Verfügung stellen kann, lassen Sie es mich in den Kommentaren wissen:

Vagrant.configure("2") do |config| 
    # All Vagrant configuration is done here. The most common configuration 
    # options are documented and commented below. For a complete reference, 
    # please see the online documentation at vagrantup.com. 


    # Let Vagrant manage the hostname at boot 
    config.vm.hostname = "devbox" 

    # Create a forwarded port mapping which allows access to a specific port 
    # within the machine from a port on the host machine. In the example below, 
    # accessing "localhost:8080" will access port 80 on the guest machine. 
    # config.vm.network :forwarded_port, guest: 80, host: 8080 

    # Create a private network, which allows host-only access to the machine 
    # using a specific IP. 
    config.vm.network :private_network, ip: "10.0.0.10" 

    # Create a public network, which generally matched to bridged network. 
    # Bridged networks make the machine appear as another physical device on 
    # your network. 
    # config.vm.network :public_network 

    # Create a public network with a given hardware address. You can 
    # configure your DHCP server (on your router) to assign a particular IP 
    # address to the VM. Update your hosts file accordingly. 
    # config.vm.network :public_network, mac: "0a00251010101" 

    # Share an additional folder to the guest VM. The first argument is 
    # the path on the host to the actual folder. The second argument is 
    # the path on the guest to mount the folder. And the optional third 
    # argument is a set of non-required options. 
    #config.vm.synced_folder "vagrant/logs", "/logs", 
    # owner: "root", group: "root" 

    # Base box to use with Virtualbox provider 
    config.vm.box = "debian-7.0.0-amd64-base" 
    config.vm.box_url = "http:/mysite.com/debian-7.0.0-amd64-base.box" 

Antwort

14

Das sieht wie ein DNS-Konfigurationsproblem aus. Machen Sie eine nslookup google.com und sehen Sie, was das Ergebnis ist.

Versuchen Sie, den folgenden Block in Ihrem Vagrantfile hinzuzufügen, setzen --natdnshostresolver1 auf, um die VirtualBox NAT-Engine zu zwingen, DNS-Anfragen abfangen und leiten sie die

config.vm.provider :virtualbox do |vb| 

    vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"] 

end 

BTW Host Resolver: Ohne vagrant reload, können Sie direkt in die /etc/resolv.conf in der VM schauen, kann es manuell auf den DNS-Server Ihres Netzwerks einstellen, wahrscheinlich wird es gut funktionieren.