Can't get Bridge only to work, no NAT

140 views
Skip to first unread message

synack

unread,
May 15, 2014, 11:13:16 AM5/15/14
to vagra...@googlegroups.com
Hi All

I'm trying to get a Bridge only setup going, no NAT. I've posted my question on superuser, but I thought I would post the link here for a bit more exposure as I'm really struggling to get this right.


Thanks for any help

Alvaro Miranda Aguilera

unread,
May 15, 2014, 7:39:44 PM5/15/14
to vagra...@googlegroups.com
Vagrant requires the first network to be nat, and connect over a forward port to setup the vm.

So you have a chicken egg, with no nat on eth0, vagrant can't connect to the guest to setup the 2nd nic.

Without the nat, vagrant will be able to only turn the guest on, and shutdown force.

Alvaro


--
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.
For more options, visit https://groups.google.com/d/optout.

synack

unread,
May 20, 2014, 12:08:05 PM5/20/14
to vagra...@googlegroups.com
So in otherwords, vagrant isn't going to work correctly, or is there something else I can do to get my dev box, which is on a different subnet, to be able to connect/see the vagrant box?

Alvaro Miranda Aguilera

unread,
May 20, 2014, 4:42:49 PM5/20/14
to vagra...@googlegroups.com
What I recall is, if you network have dhcp, you public network / bridge will get an IP and you will be able to use that ip to access from other network

eth0 will be nat
eth1 will be this bridged network.

however, if you use public network / bridge for a fixed ip, then you need to check if the gateway can be set from vagrant, if I remember correctly at some point wasnt avaliable, and the option was left to do it on the guest side (say start up script rc.local, etc)

http://docs.vagrantup.com/v2/networking/public_network.html

Setup a bridge.

Let me know if you have questions around this.

Alvaro

synack

unread,
May 21, 2014, 10:25:11 AM5/21/14
to vagra...@googlegroups.com
My current setup is DHCP, eth0 is Nat and eth1 is Bridge. The DHCP address which get's assigned is pingable from my host machine, from other developers machines, but not from our dev boxes, which are on different subnets.

If I boot the machine up via VirtualHost and disable the Nat before bootup in the config, it all works fine.

Alvaro Miranda Aguilera

unread,
May 21, 2014, 5:17:51 PM5/21/14
to vagra...@googlegroups.com
can you paste the following output from a vagrant up (which doesn't work) and one that work:

ifconfig -a
route -n

synack

unread,
May 22, 2014, 10:45:52 AM5/22/14
to vagra...@googlegroups.com
There is no 'vagrant up' that works. It only works when I boot it up via VirtualBox and disabling the Nat in the VirtualBox config. The output for the vagrant up that doesn't work is in the link I posted in the original post.

This is the ifconfig and route when booted up via vagrant.

ifconfig -a
eth0      Link encap:Ethernet  HWaddr 08:00:27:cd:d6:98
          inet addr:10.0.2.15  Bcast:10.0.2.255  Mask:255.255.255.0
          inet6 addr: fe80::a00:27ff:fecd:d698/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:545 errors:0 dropped:0 overruns:0 frame:0
          TX packets:377 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:64103 (64.1 KB)  TX bytes:48519 (48.5 KB)

eth1      Link encap:Ethernet  HWaddr 08:00:27:97:13:b2
          inet addr:10.0.24.118  Bcast:10.0.31.255  Mask:255.255.248.0
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:269 errors:0 dropped:0 overruns:0 frame:0
          TX packets:9 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:31544 (31.5 KB)  TX bytes:2058 (2.0 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)


route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.2.2        0.0.0.0         UG    100    0        0 eth0
10.0.2.0        0.0.0.0         255.255.255.0   U     0      0        0 eth0
10.0.24.0       0.0.0.0         255.255.248.0   U     0      0        0 eth1

ifconfig and route via the VirtualBox bootup with NAT disabled.
eth0      Link encap:Ethernet  HWaddr 08:00:27:97:13:b2
          inet addr:10.0.24.118  Bcast:10.0.31.255  Mask:255.255.248.0
          inet6 addr: fe80::a00:27ff:fe97:13b2/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:4098 errors:0 dropped:0 overruns:0 frame:0
          TX packets:178 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:481579 (481.5 KB)  TX bytes:16702 (16.7 KB)

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:2 errors:0 dropped:0 overruns:0 frame:0
          TX packets:2 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:172 (172.0 B)  TX bytes:172 (172.0 B)


Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         10.0.24.1       0.0.0.0         UG    0      0        0 eth0
10.0.24.0       0.0.0.0         255.255.248.0   U     0      0        0 eth0

By the looks of things, I need to make the vagrant bootup use 10.0.24.1 as the gateway and not 10.0.2.2 - Is there a way I can do that via the vagrant file, or do I have to run a script to do it on start up?

Alvaro Miranda Aguilera

unread,
May 22, 2014, 5:48:58 PM5/22/14
to vagra...@googlegroups.com

On Fri, May 23, 2014 at 2:45 AM, synack <synd...@gmail.com> wrote:
10.0.24.1

hello,

Yes this is the thing i was trying to explain in my first email.

Seems there is a parameter, you can try before going the guest path.

use_dhcp_assigned_default_route

but according to this, mitchell push for shell provisioner or guest side




so I am not sure if can be done by vagrant (a way that works)

simple approach will be remove with an script in say /etc/rc.local the default gw and put the route you want.

What OS do you use?

synack

unread,
May 23, 2014, 11:16:18 AM5/23/14
to vagra...@googlegroups.com
The vagrant box is ubuntu and my host is a mac. I'm going to try a provision script for boot up and see it works.

Phillip White

unread,
Jan 9, 2020, 5:31:47 PM1/9/20
to Vagrant
Did you ever get this figured out?  I have a similar issue with Vagrant in that the network starts up great if starting it within VirtualBox but as soon as Vagrant starts it it wants to add a NAT interface and then adds another interface assigning it a 10.0.2.15 IP.  It seems to me that you can't instruct Vagrant to "bridge" with DHCP or static without it also adding a NAT interface.

.

unread,
Jan 10, 2020, 3:18:03 PM1/10/20
to vagra...@googlegroups.com
The 10.0.2.15 is the default network Virtualbox sets up to allow access to the virtual box i.e. vagrant ssh. Vagrant is just a proxy for what Virtualbox is doing under the hood.

You might have something like this in your Vagrant file:

remote.vm.provider "virtualbox" do |v|
        v.customize ["modifyvm", :id, "--memory", mem]
        v.customize ["modifyvm", :id, "--cpus", cpus]
        v.customize ['modifyvm', :id, '--natnet1', '10.0.15.0/24']
end

v.customize ['modifyvm', :id, '--natnet1', '10.0.15.0/24'] set's the internal Virtualbox network to 10.0.15.0. This can be modified to be anything you'd like v.customize ['modifyvm', :id, '--natnet1', '10.0.16.0/24'], v.customize ['modifyvm', :id, '--natnet1', '192.168.0/24'], etc. But this is Vagrant telling Virtualbox what to do.

If you want to remove this Vagrant convenience device/network, this is the place to do so.

https://www.vagrantup.com/docs/networking/public_network.html#default-router Explains how to deal with what is listening and where by altering routes. Which appears to be the most popular option as pointed out here - https://github.com/hashicorp/vagrant/issues/8601#issuecomment-302655791

You may want to add something like:

# remove default route
remote.vm.provision "shell",
 run: "always",
 inline: "ip route del default"

--
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.


--
Dan Morgan
Reply all
Reply to author
Forward
0 new messages