Configuration private network with Vagrant -


i'm configuring 3 virtual machines on desktop vagrant. , wanna build cluster these 3 vms. , wanna configure ip of these 3 machines in private network , access each vm in desktop only. reason of configuration i'll use these 3 vms development only.

so answer questions how shall configure ip of vm vagrant purpose? cannot understand how configure ip address of private network.

create vagrant file name vagrantfile , add:

# -*k mode: ruby -*- # vi: set ft=ruby :  vagrant.configure("2") |config|          config.vm.provider :libvirt |libvirt|          libvirt.driver = "kvm"          libvirt.host = 'localhost'          libvirt.uri = 'qemu:///system'          end #         config.vm.define "test1" |vm1|          vm1.vm.box = "ubuntu/trusty64"          vm1.vm.hostname="vm1.example.com"           vm1.vm.provider :libvirt |domain|          domain.memory = 1024          domain.cpus = 1          end         vm1.vm.network :private_network,                         :ip => '192.168.1.10',                         :libvirt__netmask => '255.255.255.0',                         :libvirt__network_name => 'mynetwork',                         :libvirt__forward_mode => 'none'  end  config.vm.define "test2" |vm2|          vm2.vm.box = "ubuntu/trusty64"          vm2.vm.hostname="vm2.example.com"          vm2.vm.provider :libvirt |domain|          domain.memory = 1024          domain.cpus = 1          end          vm2.vm.network :private_network, :ip => '192.168.1.11', :libvirt__network_name => 'mynetwork' end  config.vm.define "test3" |vm3|          vm3.vm.box = "ubuntu/trusty64"          vm3.vm.hostname="vm3.example.com"           vm3.vm.provider :libvirt |domain|          domain.memory = 1024          domain.cpus = 1          end          vm3.vm.network :private_network, :ip => '192.168.1.12', :libvirt__network_name => 'mynetwork'  end  end 

according provider can change. libvirt provider. in first test1 block

vm1.vm.network :private_network,                             :ip => '192.168.1.10',                             :libvirt__netmask => '255.255.255.0',                             :libvirt__network_name => 'mynetwork',                             :libvirt__forward_mode => 'none'  

this create isolated private network 192.168.1.0/24 name mynetwork. can change else. in second test2 , third test3 using network mynetwork. if don't give network name assign other name better add networkname more understandable. use command up:

vagrant test1  vagrant test2 vagrant test3 

if using virtualbox vagrantfile below many syntax same.

vagrantfile_api_version = "2" vagrant.configure(vagrantfile_api_version) |config| config.vm.box = "ubuntu/trusty64" config.vm.network "private_network", ip: "192.168.33.10" config.vm.provider "virtualbox" |vb| vb.customize ["modifyvm", :id, "--memory", "1024"] end 

Comments

Popular posts from this blog

javascript - Chart.js (Radar Chart) different scaleLineColor for each scaleLine -

apache - Error with PHP mail(): Multiple or malformed newlines found in additional_header -

java - Android – MapFragment overlay button shadow, just like MyLocation button -