Homestead Vagrant Virtualbox не может разрешить DNS внутри гостевой ОС - PullRequest
2 голосов
/ 27 марта 2019

Мой ящик Homestead Vagrant не может разрешить DNS из гостевой ОС, хотя в противном случае сетевой трафик проходит нормально.

vagrant@homestead:~$ ping google.com
ping: google.com: Temporary failure in name resolution
vagrant@homestead:~$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=121 time=23.0 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=121 time=21.9 ms
^C
--- 8.8.8.8 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 21.956/22.516/23.077/0.580 ms

Связанные Вопросы имеют , указывающие на изменение флага natdnshostresolver1 Virtualbox (хотя мне сказали, что Homestead это уже включает); Я обновил свой Vagrantfile, как показано ниже, но безрезультатно:

# -*- mode: ruby -*-
# vi: set ft=ruby :

require 'json'
require 'yaml'

VAGRANTFILE_API_VERSION ||= "2"
confDir = $confDir ||= File.expand_path(File.dirname(__FILE__))

homesteadYamlPath = confDir + "/Homestead.yaml"
homesteadJsonPath = confDir + "/Homestead.json"
afterScriptPath = confDir + "/after.sh"
customizationScriptPath = confDir + "/user-customizations.sh"
aliasesPath = confDir + "/aliases"

require File.expand_path(File.dirname(__FILE__) + '/scripts/homestead.rb')

Vagrant.require_version '>= 2.1.0'

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|

    config.vm.provider :virtualbox do |v|
        v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
    end

    if File.exist? aliasesPath then
        config.vm.provision "file", source: aliasesPath, destination: "/tmp/bash_aliases"
        config.vm.provision "shell" do |s|
            s.inline = "awk '{ sub(\"\r$\", \"\"); print }' /tmp/bash_aliases > /home/vagrant/.bash_aliases && chown vagrant:vagrant /home/vagrant/.bash_aliases"
        end
    end

    if File.exist? homesteadYamlPath then
        settings = YAML::load(File.read(homesteadYamlPath))
    elsif File.exist? homesteadJsonPath then
        settings = JSON::parse(File.read(homesteadJsonPath))
    else
        abort "Homestead settings file not found in #{confDir}"
    end

    Homestead.configure(config, settings)

    if File.exist? afterScriptPath then
        config.vm.provision "shell", path: afterScriptPath, privileged: false, keep_color: true
    end

    if File.exist? customizationScriptPath then
        config.vm.provision "shell", path: customizationScriptPath, privileged: false, keep_color: true
    end

    if Vagrant.has_plugin?('vagrant-hostsupdater')
        config.hostsupdater.aliases = settings['sites'].map { |site| site['map'] }
    elsif Vagrant.has_plugin?('vagrant-hostmanager')
        config.hostmanager.enabled = true
        config.hostmanager.manage_host = true
        config.hostmanager.aliases = settings['sites'].map { |site| site['map'] }
    end


end

Что еще может помешать виртуальной машине разрешать DNS? Или я могу просто установить серверы имен в поле, которое будет сохраняться?


EDIT: В настоящее время я могу заставить его работать вручную , редактируя /etc/resolv.conf и добавляя серверы имен каждый раз, когда я раскручиваю его. Однако composer все еще требует DNS во время процесса запуска, так что это не исправление.

Вот мой Homestead.yaml для любопытных:

---
ip: "127.0.0.1"
memory: 2048
cpus: 1
provider: virtualbox

authorize: ~/.ssh/id_rsa.pub

keys:
    - ~/.ssh/id_rsa

folders:
    - map: ~/code
      to: /home/vagrant/code

sites:
    - map: erich.test
      to: /home/vagrant/code/snowman/public

databases:
    - homestead
...