Using CIDR notation for IP assignment

20 views
Skip to first unread message

Tyler Auerbeck

unread,
Nov 26, 2017, 12:17:39 PM11/26/17
to Vagrant
I have a few projects that I work on locally that require hosts having a few NIC's assigned. Currently I'm creating these manually and then just assigning static IP addresses to these hosts in my Vagrantfile. What I'm curious about is whether there is any functionality in Vagrant that exists that would just allow me to use a cidr block to do something like this:

  config.vm.define "x" do |x| 
      x.vm.box = "centos"
      x.vm.hostname = "k8sc1.localdomain"
      x.vm.network "private_network", ip: "192.168.0.12"
      x.vm.network "private_network", cidr: "10.240.0.0/24"
  end

This way my Vagrantfile can become more generalized because I really don't care what the IP address is, just that it gets different NIC's assigned within certain blocks. If this is something that is already possible, let me know what I missed.


Alvaro Miranda Aguilera

unread,
Nov 26, 2017, 3:05:29 PM11/26/17
to vagra...@googlegroups.com
hello

what about you create a network in virtualbox say mynetwork, enable dhcp and give it a range.

then you can just use:


config.vm.network "private_network",
    virtualbox__intnet: "mynetwork"

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/e482a94c-94ff-4ab5-b2d2-afd6840a86ef%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Alvaro

Reply all
Reply to author
Forward
0 new messages