How to disable DNS nameservers from DHCP Vagrant's internal interface?

1,044 views
Skip to first unread message

tec...@gmail.com

unread,
Feb 10, 2016, 10:47:07 PM2/10/16
to Vagrant
I've been trying to prevent dhclient from getting nameserver settings on eth0 interface.

I could supersede DNS settings with a static nameserver.

I could change settings for eth1 by adding interface "eth1" { ... } section to dhclient.conf


I found however problems with setting the eth0 interface:
  1. The first problem is that removing domain-name and domain-name-servers has no effect, it still gets the values from DHCP.
  2. The second problem is that adding a interface "eth1" { ... } section to the dhclient.conf causes Vagrant machine to freeze on reboot at this moment:
==> client: Configuring and enabling network interfaces...

What can I do to stop dhclient from supplying Vagrant's DHCP settings to resolvconf, while retaining this for other interfaces than eth0?

Alvaro Miranda Aguilera

unread,
Feb 12, 2016, 4:01:24 AM2/12/16
to vagra...@googlegroups.com
Hello,

eth0 use dhcp to get the IP, and dhcp provide the dns information.

on my experience, is easier you use a shell provisioner script to override the dns settings and lets things go default.

What's the os for the guest?

with vagrant, you can have `run: "always"` to run the provisioner all the time.

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/82cc2aa1-53c2-4f20-8a34-bc861ad3d090%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

tec...@gmail.com

unread,
Feb 12, 2016, 10:07:02 AM2/12/16
to Vagrant
I use ubuntu/trusty64 now.

By default dhclient.conf contains:

request subnet-mask, broadcast-address, time-offset, routers,
        domain
-name, domain-name-servers, domain-search, host-name,
        dhcp6
.name-servers, dhcp6.domain-search,
        netbios
-name-servers, netbios-scope, interface-mtu,
        rfc3442
-classless-static-routes, ntp-servers,
        dhcp6
.fqdn, dhcp6.sntp-servers;

When changed to:

request subnet-mask, broadcast-address, time-offset, routers,
        host
-name, netbios-name-servers, netbios-scope,
       
interface-mtu, rfc3442-classless-static-routes,
        ntp
-servers, dhcp6.fqdn, dhcp6.sntp-servers;

and machine restarted nameserver on eth0 gets populated into resolv.conf.


The second problem is when I surround this section with:

interface "eth0" {
        request subnet
-mask, broadcast-address, time-offset, routers,
                domain
-name, domain-name-servers, domain-search, host-name,
                dhcp6
.name-servers, dhcp6.domain-search,
                netbios
-name-servers, netbios-scope, interface-mtu,
                rfc3442
-classless-static-routes, ntp-servers,
                dhcp6
.fqdn, dhcp6.sntp-servers;
}

Vagrant freezes on restart.


Yes, I actually have no other choice but to provision each time, but I was interested in a more canonical solution.

--tr

Alvaro Miranda Aguilera

unread,
Feb 12, 2016, 7:36:56 PM2/12/16
to vagra...@googlegroups.com
Hello, it's possible to stop the dns setting in RedHat and friends (Centos/fedora/OL), but as you have found in ubuntu is not easy. I havent been able to find something that works

in RH is easy as adding "PEERDNS=no" to the nic that you want to stop from grabing the dns over dhcp.

A provision script can be like this:

$conf = <<-EOF

cat > /etc/resolv.conf <<EOF2

search yourdomain.tld

nameserver 192.168.1.1

EOF2

EOF

  #resolv.conf and hosts

  config.vm.provision "shell", inline: $conf, run: "always"


Alvaro.


Reply all
Reply to author
Forward
0 new messages