how to change network subnet 10.0.2.0/24 for network created by vagrant by default ?

282 views
Skip to first unread message

Bruno Ricci

unread,
Oct 12, 2016, 10:29:06 AM10/12/16
to Vagrant
Hello
when I create a new VM with vagrant for VirtualBox, Vagrant create a forwarded port 22 -> 2222 in subnet 10.0.2.0/24. it is a problem for me since 10.0.2.0/16 is already is the current subnet of my local network

Is there a way/parameter  to change the subnet in which the first network (to communicate via ssh with the guest) is created ?

Thanks in advance

Alvaro Miranda Aguilera

unread,
Oct 12, 2016, 12:50:16 PM10/12/16
to vagra...@googlegroups.com
hello

Vagrant doesn't create the network, its VirtualBox.

Try this:

Vagrant.configure(2) do |config|

  config.vm.box = "hashicorp/precise64"

  config.vm.provider "virtualbox" do |v|

    v.customize ["modifyvm", :id, "--natnet1", "10.0.3/24"]

  end

end


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/435162ab-3721-4e6f-ab0b-4f1b11b1a42f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Bruno Ricci

unread,
Oct 12, 2016, 2:28:34 PM10/12/16
to Vagrant
Thanks a lot  Alvaro
that works fine.

I've read the doc and the ebook 'Vagrant Up and Running" but I didn't find this configuration option

Have a nice day

Bruno



Le mercredi 12 octobre 2016 18:50:16 UTC+2, Alvaro Miranda Aguilera a écrit :
hello

Vagrant doesn't create the network, its VirtualBox.

Try this:

Vagrant.configure(2) do |config|

  config.vm.box = "hashicorp/precise64"

  config.vm.provider "virtualbox" do |v|

    v.customize ["modifyvm", :id, "--natnet1", "10.0.3/24"]

  end

end


Alvaro.

On Wed, Oct 12, 2016 at 4:29 PM, Bruno Ricci <br91...@gmail.com> wrote:
Hello
when I create a new VM with vagrant for VirtualBox, Vagrant create a forwarded port 22 -> 2222 in subnet 10.0.2.0/24. it is a problem for me since 10.0.2.0/16 is already is the current subnet of my local network

Is there a way/parameter  to change the subnet in which the first network (to communicate via ssh with the guest) is created ?

Thanks in advance

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



--
Alvaro

Alvaro Miranda Aguilera

unread,
Oct 13, 2016, 4:49:22 AM10/13/16
to vagra...@googlegroups.com
Hello,

Well, basically is on the virtualbox manual.

Vagrant can execute commandas using VBoxManage after the VM has been created, before is turned on.

So, if you were doing this without vagrant, you would hit the same network collision, you will dig into the options of virtualbox using that network and would find the same information, and the command:

VBoxManage modifyvm <vm_name> --natnet1 10.0.3/24

So the question would be, how I using vagrant can make vagrant run that command.. and is on the Vagrant Virtualbox part of the manual.

having said all that, if you think is information is useful, and you could share where you would expect having it on vagrant documentation, we can put a note there.

perhaps here?

Thanks
Alvaro.



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/9a41f03c-cfb9-4bd0-8de2-db0615076eff%40googlegroups.com.

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



--
Alvaro

Reply all
Reply to author
Forward
0 new messages