Specifying use of the new "NAT Network" option in Vagrantfile

6,024 views
Skip to first unread message

Chris Almond

unread,
May 19, 2015, 4:21:42 PM5/19/15
to vagra...@googlegroups.com
Can anyone share examples that show how to specify use of the new "NAT Network" option for network type?

Virtualbox doc ref: 6.4. Network Address Translation Service (experimental)  https://www.virtualbox.org/manual/ch06.html#network_nat_service 

The goal is to use Vagrant to provision a cluster of boxes, all members of the same custom defined NAT service, with DHCP providing address within a set range for that NAT segment.

Is this possible via vagrant?  In my (minimal) research and experimentation with Vagrant so far I'm finding that I need to use the new NAT service type for this setup (instead of standard "NAT"). 

Learn how WANdisco Fusion solves Hadoop data protection and scalability challenges

Listed on the London Stock Exchange: WAND

THIS MESSAGE AND ANY ATTACHMENTS ARE CONFIDENTIAL, PROPRIETARY, AND MAY BE PRIVILEGED.  If this message was misdirected, WANdisco, Inc. and its subsidiaries, ("WANdisco") does not waive any confidentiality or privilege.  If you are not the intended recipient, please notify us immediately and destroy the message without disclosing its contents to anyone.  Any distribution, use or copying of this e-mail or the information it contains by other than an intended recipient is unauthorized.  The views and opinions expressed in this e-mail message are the author's own and may not reflect the views and opinions of WANdisco, unless the author is authorized by WANdisco to express such views or opinions on its behalf.  All email sent to or from this address is subject to electronic storage and review by WANdisco.  Although WANdisco operates anti-virus programs, it does not accept responsibility for any damage whatsoever caused by viruses being passed.

Chris Almond

unread,
May 19, 2015, 5:05:23 PM5/19/15
to vagra...@googlegroups.com
More clarification. For the custom NAT Network definition shown below (vbox preferences -> network), how do I specify using in Vagrantfile?

Would it be something like this?  config.vm.network :forwarded_port, :adapter => "2"  (...for the second (custom) NAT adapter?)

vbox adapter type:          vagrant network type:
"Host-only Adapter"     =      "private_network"
"Bridged Adapter"       =      "public_network"
         "NAT"          =      "forwarded_port"
?--> "NAT Network1"     =       "    ?    "

Alvaro Miranda Aguilera

unread,
May 19, 2015, 7:36:48 PM5/19/15
to vagra...@googlegroups.com
Hello,

Maybe I am missing something, but I think with normal networks you can do the same..

What do you need that the normal vagrant networking doesn't provide?

Check this:


Because this is how you usually work with Vagrant and virtualbox:

Out of the box, you get the normal nat for eth0 connection

Then, using a mix of shell provisioner and network configuration you can

add a 2nd interface (any config.vm.network line create a new nic on top of eth0.. you can't change eth0 this way)
remove the default gw that goes over the normal nat on eth0
add a new default gw over the eth1 nic

That is how you can do a multi vm setup that talk internally and optionally use this eth1 network for routing too.


So, in the clusters I do I end with something like this:


and you can also forward a port to each VM 

So, not sure if that particular natservices is really needed, 

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.

Peter Ferriola

unread,
Jul 15, 2015, 6:19:58 PM7/15/15
to vagra...@googlegroups.com
The solution you present does work, but does not utilize a feature VirtualBox added to create a NAT network behind which all the VMs in a given NAT network reside.  For example, I've used it to create (outside of Vagrant) a Puppet test environment with a Puppet Master and five clients without any particular complexity to the configuration.  Just straightforward IPs and they can all access each other and the Internet just fine, with a single IP per system.  Much closer to the reality of the production environments some tests are meant to reflect.

Your solution does work, but it adds complexity to what should be a very simple setup, and what Oracle has already integrated into VirtualBox itself.

Andy Wang

unread,
Sep 26, 2016, 10:38:09 PM9/26/16
to Vagrant
hi, have you found solution for this issue ? I came across same issue when I try to setup two guest VM which can communicate each other . 

andy

Alvaro Miranda Aguilera

unread,
Sep 27, 2016, 2:24:45 PM9/27/16
to vagra...@googlegroups.com
hello

Vagrant currently is hard coded on first interface to traditional NAT for Virtualbox.

Options at the moment are add private_network, and set hostnames.

If there is not an open issue for this, could you open one on github and share some words on how this would be beneficial ?

Thanks
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/79cbe2a0-561f-47d7-a547-5c913bb1468f%40googlegroups.com.

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



--
Alvaro

st3b4n 4lvin0

unread,
May 7, 2020, 3:22:15 AM5/7/20
to Vagrant
Peter,
Difficult to find material how to configure 'Nat Network' with virtual box, when I add private network to vagrant file it added in one machine but other one failed the first time. Any procedure that I can study to understand and configured.

Alvaro Miranda Aguilera

unread,
May 9, 2020, 1:32:29 AM5/9/20
to vagra...@googlegroups.com
hello

you did reply to a email from 2015, i would suggest send a new email to the group and describe what you need or how we can help

vagrant and virtualbox have changed a lot since 2015 so things may be different

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


--
Alvaro

Reply all
Reply to author
Forward
0 new messages