Detect and disable DNS settings that break on Ubuntu 12.04.
This commit is contained in:
parent
13a27eb723
commit
6f5a9d13f3
|
@ -28,13 +28,34 @@ module Vagrant
|
||||||
]
|
]
|
||||||
attempt_and_log(command, "Enabling the Host I/O cache on the SATA controller...")
|
attempt_and_log(command, "Enabling the Host I/O cache on the SATA controller...")
|
||||||
|
|
||||||
# Enable the DNS proxy while in NAT mode. This shields the guest
|
enable_dns_proxy = true
|
||||||
# VM from external DNS changs on the host machine.
|
begin
|
||||||
|
contents = File.read("/etc/resolv.conf")
|
||||||
|
|
||||||
|
if contents =~ /^nameserver 127\.0\.0\.1$/
|
||||||
|
# The use of both natdnsproxy and natdnshostresolver break on
|
||||||
|
# Ubuntu 12.04 that uses resolvconf with localhost. When used
|
||||||
|
# VirtualBox will give the client dns server 10.0.2.3, while
|
||||||
|
# not binding to that address itself. Therefore disable this
|
||||||
|
# feature if host uses the resolvconf server 127.0.0.1
|
||||||
|
@logger.info("Disabling DNS proxy since resolv.conf contains 127.0.0.1")
|
||||||
|
enable_dns_proxy = false
|
||||||
|
end
|
||||||
|
rescue Errno::ENOENT; end
|
||||||
|
|
||||||
|
# Enable/disable the NAT DNS proxy as necessary
|
||||||
|
if enable_dns_proxy
|
||||||
command = [
|
command = [
|
||||||
"modifyvm", env[:vm].uuid,
|
"modifyvm", env[:vm].uuid,
|
||||||
"--natdnsproxy1", "on"
|
"--natdnsproxy1", "on"
|
||||||
]
|
]
|
||||||
attempt_and_log(command, "Enable the NAT DNS proxy on adapter 1...")
|
attempt_and_log(command, "Enable the NAT DNS proxy on adapter 1...")
|
||||||
|
else
|
||||||
|
command = [ "modifyvm", env[:vm].uuid, "--natdnsproxy1", "off" ]
|
||||||
|
attempt_and_log(command, "Disable the NAT DNS proxy on adapter 1...")
|
||||||
|
command = [ "modifyvm", env[:vm].uuid, "--natdnshostresolver1", "off" ]
|
||||||
|
attempt_and_log(command, "Disable the NAT DNS resolver on adapter 1...")
|
||||||
|
end
|
||||||
|
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue