DNS-setup for a host-only network

423 views
Skip to first unread message

Uli Schulze-Eyssing

unread,
Dec 31, 2015, 8:48:32 AM12/31/15
to Vagrant
Hi,
I would like to create a network of 4 VMs, connected through a private network.

 node.vm.network :private_network, ip: "10.211.55.10[1-n]"
 node
.vm.hostname = "vm[1-n]"


for every node did the job. It created a second private nic as expected.

I use the hostmanager plugin to exchange the hostnames in the /etc/hosts.

 
  config.hostmanager.enabled = false
  config
.hostmanager.manage_host = true
  config
.hostmanager.include_offline = true
  config
.hostmanager.ignore_private_ip = false

  
and
  
 
 node.vm.provision :hostmanager  


Now I can ping the boxes among themselves by hostname, but for some reason I need complete dns.
 
ping vm[1-n]

works, but

host vm[1-n]

doesn´t work.

Two points: 
I´m running vagrant on a windows box. (vagrant-dns wouldn´t work) 
I don´t wanna have too much dependencies into the host setup in respect to future deployments.

So I remove hostmanager and try to set up a dnsmasq and a proper /etc/hosts on one of the VMs and a proper nameserver setting on the others.
So here I´m stuck. I cannot configure the resolving properly.

So, what I need on the "client" VMs is something like:

iface eth1 inet static
      address
10.211.55.102
      netmask
255.255.255.0
      dns
-nameservers 10.211.55.100


 
in my /etc/networks/interfaces and disabling the nameserver for the first interface. The /etc/resolv.conf should look like:

# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
#     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver
10.211.55.100
search localnet


By default, the first interface in in here at the first position.

 
Here my questions:

Ist there a way to specify the nameservers for my private networks? For example a parameter witch sets "dns-nameservers" in my /etc/networks/interfaces.
Is there a possibility to disable the nameserver of my first (default!?!) interface? This is the nat/dhcp interface configured by vagrant by default.

Thanks,
Uli
 

 

Alvaro Miranda Aguilera

unread,
Jan 3, 2016, 5:02:58 AM1/3/16
to vagra...@googlegroups.com
Hello Uli.

1. On RedHat and Centos, you can stop the OS changing /etc/hosts, but in Ubuntu you can't.
So you can use a shell provisioner to set /etc/hosts.

Shell provisioner by default only run once, but you can specify to run always.

Have a look at his gist, I am not sure you need dnsmasq at all if you create the hosts in all the nodes.


If I did miss anything, please let me know :)


Alvaro.


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/a4d019b1-3fb7-4e22-aab4-91fb995f6281%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Uli Schulze-Eyssing

unread,
Jan 3, 2016, 11:06:32 AM1/3/16
to Vagrant
Hi Alvaro,
unfortunately I need dns-resolution. Only setting the /etc/host doesn't solve my problem. The reason is, that nslookup <name> or host <name> return nothing without dns.
But I solved is setting a dns-server in  /etc/dhcp/dhclient.conf.
The entry is:

supersede domain
-name-servers yyy.yyy.yyy.yyy;

Than I run a dnsmasq on the host with this address.
I use shell provosioning to set the entry. It looks like:

$slave_script = <<SCRIPT
cat
> /etc/dhcp/dhclient.conf <<EOF
supersede domain
-name-servers <Server>;
EOF
sudo dhclient
SCRIPT



This fixed the issue for me.
Tanks,
Uli

pixel fairy

unread,
Jan 3, 2016, 4:15:13 PM1/3/16
to Vagrant
in the past i did this,

echo nameserver yyy.yyy.yyy.yyy > /etc/resolv.conf

which always worked, but i never thought about if dhcpd would run in the background and overwrite that.
Reply all
Reply to author
Forward
0 new messages