lost and found ( for me ? )

Vagrant : run multiple VMs and configure a private network so that each VM can communicate with the other VMs

small tips.

$ vagrant version
Installed Version: 1.7.2
Latest Version: 1.7.2

$ virtualbox --help | head -1
Oracle VM VirtualBox Manager 4.3.10_Ubuntu

I have already downloaded two boxes.
I used a ‘trusty64’ box for virtualbox.
$ vagrant box list
trusty64 (libvirt, 0)
trusty64 (virtualbox, 0)

  • create a Vagrantfile.

build two VMs by using a box ‘trusty64’
$ cat Vagrantfile
Vagrant.configure(2) do |config|
 config.vm.box = "trusty64"
 config.vm.provider "virtualbox" do |v|
   v.memory = 512
   v.cpus = 2
 end

 config.vm.define :node01 do |node01|
   node01.vm.hostname = "node01"
   node01.vm.network :private_network, ip: "192.168.33.10"
 end

 config.vm.define :node02 do |node02|
   node02.vm.hostname = "node02"
   node02.vm.network :private_network, ip: "192.168.33.20"
 end
end

start VMs.
$ vagrant up node01
$ vagrant up node02

$ vagrant status
Current machine states:

node01                    running (virtualbox)
node02                    running (virtualbox)

access to the node01
$ vagrant ssh node01

$ free -m
            total       used       free     shared    buffers     cached
Mem:           489        337        152          0         12        209
-/+ buffers/cache:        114        374
Swap:            0          0          0

$ ifconfig eth1 | grep 192
         inet addr:192.168.33.10  Bcast:192.168.33.255  Mask:255.255.255.0

confirm that you can get a reply from the other VM.
$ ping 192.168.33.20 -c 1
PING 192.168.33.20 (192.168.33.20) 56(84) bytes of data.
64 bytes from 192.168.33.20: icmp_seq=1 ttl=64 time=0.948 ms

--- 192.168.33.20 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 0.948/0.948/0.948/0.000 ms


$ arp -an -i eth1
? (192.168.33.20) at 08:00:27:a0:fd:8b [ether] on eth1

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.