Can't set VM private IP address. Centos 7. VirtualBox 5.0.12. Vagrant 1.8.1. Windows 10.

160 views
Skip to first unread message

Deaton

unread,
Jan 18, 2016, 12:49:53 PM1/18/16
to Vagrant
Hello,

I've been setting up Vagrant VMs for a WordPress build that works fine when I just have the one VM using an auto assigned IP. What I want to do is have the ability to fire up multiple VMs and I need each VM to have a separate IP that I can manage.
The IP address assignment is controlled via a batch file that creates the Vagrant file. However, I can't set the private IP of the VM.
This is the line in my Vagrant file: config.vm.network "private_network", ip: "192.168.99.2", :netmask => '255.255.255.0', auto_config: false
I get a VirtualBox host only network created with IP 192.168.99.1/24, but the Centos VM gets an IP address of 10.0.2.15/24.

Completely stuck.

Any help appreciated,

David.

Here's my vagrant file:


Vagrant.configure("2") do |config|

 

                vagrant_version = Vagrant::VERSION.sub(/^v/, '') 

                config.vm.box = "wordpress.php7" 

                config.vm.box_url = "http://mysite.local/vagrant/" + config.vm.box + ".box"


                config.vm.network :forwarded_port, guest: 22, host: 22, id: 'ssh'

                config.vm.hostname = "wordpress.local"

                config.vm.network "private_network", ip: "192.168.99.2", :netmask => '255.255.255.0', auto_config: false


               

                config.ssh.host = "192.168.99.2"

                config.ssh.port = "22"


 


                config.vm.synced_folder "../../", "/vagrant",  nfs: true

                config.vm.synced_folder "../../www/", "/var/www/html", :mount_options => [ "dmode=777", "fmode=777" ]

                config.vm.synced_folder "../../dbbackup/", "/dbbackup", :mount_options => [ "dmode=777", "fmode=777" ]

                config.vm.synced_folder "../../dbupload/", "/dbupload", :mount_options => [ "dmode=777", "fmode=777" ]

                config.vm.synced_folder "../../wwwbackup/", "/wwwbackup", :mount_options => [ "dmode=777", "fmode=777" ]

                config.vm.synced_folder "../../wwwupload/", "/wwwupload", :mount_options => [ "dmode=777", "fmode=777" ]

                config.vm.synced_folder "../../scripts/", "/scripts", :mount_options => [ "dmode=777", "fmode=777" ]


               

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


                    v.name = "[2]wordpress.local"

                                v.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]

                                v.customize ["modifyvm", :id, "--cpus", "2"]

                                v.memory = 1024

                end

               


                config.vm.provision "shell", inline: "yum clean all"

                config.vm.provision "shell", inline: "yum update -y"


                config.vm.provision "puppet" do |puppet|

                                puppet.manifests_path = ["vm", "/vagrant/server/vagrant/manifests"]

                                puppet.manifest_file = "default.pp"

                end

end




Deaton

unread,
Jan 19, 2016, 6:35:27 AM1/19/16
to Vagrant

It seems that VirtualBox won't let you set the IP address directly. I've only managed to set the subnet using Vagrant :(

I'll change the way I do things...... 

Walid

unread,
Jan 20, 2016, 2:28:05 PM1/20/16
to vagra...@googlegroups.com
I am having similar issues with RHEL7

On 19 January 2016 at 14:35, Deaton <deato...@gmail.com> wrote:

It seems that VirtualBox won't let you set the IP address directly. I've only managed to set the subnet using Vagrant :(

I'll change the way I do things...... 

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/bc9b97dc-ac37-4811-8a15-0bef00493e1f%40googlegroups.com.

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

Alvaro Miranda Aguilera

unread,
Jan 21, 2016, 4:40:45 AM1/21/16
to vagra...@googlegroups.com

Walid

unread,
Jan 27, 2016, 12:18:09 PM1/27/16
to vagra...@googlegroups.com
Thanks Alvaro, will test it tomorrow at work

Reply all
Reply to author
Forward
0 new messages