Vagrant file - public network not getting dns

49 views
Skip to first unread message

rcpunc

unread,
Nov 3, 2017, 8:21:33 AM11/3/17
to Vagrant
Hi everyone

I have a vagrant file that has:

config.vm.box = "fso/xenial64-desktop"

config.vm.network "forwarded_port", guest: 80, host: 19721, host_ip: "127.0.0.1"

config.vm.network "public_network", bridge: "Intel(R) Ethernet Connection I217-LM"

There is also config.vm.provision with multiple sudo apt-get 

When I do vagrant up, it fails on the first apt-get as it can't resolve:  Err:1 http://us.archive.ubuntu.com/ubuntu xenial/universe amd64 sshpass amd64 1.05-1
==> default:   Temporary failure resolving 'us.archive.ubuntu.com'

I can see in virtual box that the box is running and it has got an ip from dhcp on the corporate network but the dns settings in /etc/resolv.conf are not correct.  It has nameserver as local host and the search as the corporate domain:

nameserver 127.0.1.1

The nics look like this:
lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:4a:c5:81 brd ff:ff:ff:ff:ff:ff
    inet 10.0.2.15/24 brd 10.0.2.255 scope global enp0s3
       valid_lft forever preferred_lft forever
    
3: enp0s8: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 08:00:27:15:b4:68 brd ff:ff:ff:ff:ff:ff
    inet 10.7.6.99/24 brd 10.2.7.255 scope global dynamic enp0s8
       valid_lft 172754sec preferred_lft 172754sec
    

If I  disable enp0s8 and reconnect it, it gets the correct dns in /etc/resolv.conf

and then I have to run vagrant provision to get all the packages that should be provisioned

Does anyone know what is wrong with the vagrant file that it is not doing this correctly when I run vagrant up?


Thanks

Alvaro Miranda Aguilera

unread,
Nov 3, 2017, 8:49:38 AM11/3/17
to vagra...@googlegroups.com
if you need or want to use a different dns

you could use a provisioning script to do that.

or check this :




--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/235ec2b4-b9a9-4474-a979-176a2c1e3102%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

rcpunc

unread,
Nov 3, 2017, 10:11:08 AM11/3/17
to Vagrant
I tried adding -  vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]  but it had no effect.
The vm should get its dns settings from the corporate network, but no idea why it doesn't
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.



--
Alvaro

Alvaro Miranda Aguilera

unread,
Nov 3, 2017, 10:22:59 AM11/3/17
to vagra...@googlegroups.com
why you think that?

VM usually uses host machine DNS.

If you know the corportate DNS, you can set those in the VM using a shell script and a vagrant provisioner



To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/5a241b69-2290-4fe8-bfa0-b73e59228765%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages