Skip to content

Conversation

@nickrw
Copy link

@nickrw nickrw commented Apr 26, 2013

This adds an option, :drop_nat_interface_default_route, to the bridged virtualbox configuration hash. If enabled the bridged interface will have the following options set in /etc/network/interfaces:

post-up route del default if eth0
pre-down route add default if eth0

This has the effect that all traffic, apart from vagrant's ssh via the NAT, will go over the bridge, rather than the NAT, once it has come up.

I have found the default route via the NAT problematic when operating in networks with multiple subnets. If I try to point someone on another subnet at an application accessible via my bridged interface it will fail because the return traffic attempts to route via the wrong interface.

Removes the default route on the NAT interface (eth0) when the bridged
interface comes up, replaces it when the bridged interface goes down.
@jsirex
Copy link

jsirex commented Jul 16, 2013

For me it only works when i use:

<% if options[:drop_nat_interface_default_route] %>
    pre-up route del default dev eth0
    post-down route add default dev eth0
<% end %>

Before vagrant up eth1 it should remove default router to eth0. And after eth1 down restore eth0s' route.
Anyway, thank for the patch!

@mitchellh
Copy link
Contributor

After thinking about these sorts of problems, I think they're best left for the shell provisioner. I even regret the use_dhcp_assigned_default_route option. I think the shell provisioner is better for this.

@mitchellh mitchellh closed this Nov 26, 2013
@ghost ghost locked and limited conversation to collaborators Apr 12, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants