New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Vagrant's 127.0.0.1 hostname alias overrides's hostmanager's IP #203
Comments
The above report is using a CentOS 7.2 guest on VirtualBox. |
Curl version:
|
Removing the Vagrant added alias results in the desired behavior:
|
FYi I've run into the same issue. I get around it by automating stripping out the offending entries with a shell provisioner. Something like this:
|
Yeah, I've had to use something similar. Would be nice if vagrant-hostmanager did it for us tho. |
I've lost yesterday because of this issue - I couldn't figure out why rancher/docker weren't working properly! IMO, the correct thing to do here is for vagrant to not add that line to /etc/hosts. I wonder if it can be disabled? |
I've been running into the same issue. I'm using Vagrant 1.8.6 and CentOS 7.2 based vagrant boxes. |
FWIW, I use a provisioning step to work around this issue:
|
Handy work around. Thank you. |
I ran into this problem and wasted nearly a day trying to figure out why a couple of my services (e.g., Spark and ZooKeeper) failed to work. In my case, I use Vagrant with Ansible as my provisioner. Here's the equivalent workaround for Ansible. Simply, add this to one of your Ansible roles:
|
Recent versions of Vagrant set the VM name and hostname as aliases to 127.0.0.1 at the top of
/etc/hosts
on CentOS. This seems to change the behavior of hostname resolution performed by Name Server Switch such that 127.0.0.1 is returned instead of the IP added by vagrant-hostmanager.Example:
In this dcos-vagrant example, there are several VMs, one of which is named
a1
with the hostnamea1.dcos
.Host resolution works fine for many tools, like
host
,nslookup
anddig
, but fails for tools that use NSS likeping
andcurl
.ping
hits127.0.0.1
instead of192.168.65.111
:curl a1.dcos
tries127.0.0.1
first and only tries192.168.65.111
if127.0.0.1
is refused:Rearranging
/etc/hosts
to put hostmanager aliases on top fixesping
:But curl still tried 127.0.0.1 first:
The text was updated successfully, but these errors were encountered: