Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.

When used with "public_network" default gateway is missing on boot. #46

Open
GR360RY opened this issue Oct 3, 2015 · 0 comments
Open

Comments

@GR360RY
Copy link

GR360RY commented Oct 3, 2015

Example Vagrantfile:

Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  config.vm.box = "boxcutter/ubuntu1404-desktop"
  config.vm.network "public_network"
end

Routing table with route -n after vagrant up:

vagrant@vagrant:~$ route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
10.100.200.0    0.0.0.0         255.255.255.0   U     0      0        0 eth1
169.254.0.0     0.0.0.0         255.255.0.0     U     1000   0        0 eth0

The box is missing 0.0.0.0 destination.
vagrant reload or reboot fixes this issue. If provisioning is required, default gateway should be fixed with explicit provisioning script. Here is my workaround:

$ grep vagrant_fix_default_gw.sh Vagrantfile
config.vm.provision :shell, path: "scripts/vagrant_fix_default_gw.sh"

Script contents:

$ cat scripts/vagrant_fix_default_gw.sh
route del default || true
route -n | grep -qe '^0.0.0.0' || sudo route add default gw `grep routers /var/lib/dhcp/dhclient.eth1.leases | sort -u | awk '{print $3}' | awk -F";" '{print $1}'`

This behaviour exists only with boxcutter/ubuntu1404-desktop. ubuntu/trusty64 box works as expected. Probably related to NetworkManager.

It would be nice to fix it in box itself.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant