Linux Administration Cookbook
上QQ阅读APP看书,第一时间看更新

Getting ready

To begin, ensure that you have two VMs configured with a private network between each.

You can use the Vagrantfile in the Technical requirements section to accomplish this.

Connect to the first of your machines:

$ vagrant ssh centos1

Check that the IP address of centos1 is correctly configured, using the command ip a from Chapter 1, Introduction and Environment Setup.

We expect it to be 192.168.33.10, under the eth1 device:

[vagrant@centos1 ~]$ ip a
<SNIP>
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 08:00:27:ac:f2:12 brd ff:ff:ff:ff:ff:ff
inet 192.168.33.10/24 brd 192.168.33.255 scope global noprefixroute eth1
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:feac:f212/64 scope link
valid_lft forever preferred_lft forever

You can also use hostname -I to get the IP address of a box, as seen below, but you should note that you won't get an obvious interface designation:

$ hostname -I
10.0.2.15 192.168.33.10

Check that you can ping the IP address of centos2 from within centos1.

We set the second IP to 192.168.33.11:

$ ping 192.168.33.11
PING 192.168.33.11 (192.168.33.11) 56(84) bytes of data.
64 bytes from 192.168.33.11: icmp_seq=1 ttl=64 time=1.17 ms
64 bytes from 192.168.33.11: icmp_seq=2 ttl=64 time=0.997 ms
64 bytes from 192.168.33.11: icmp_seq=3 ttl=64 time=1.18 ms

We have network connectivity between our VMs!

If you're unable to ping between machines, start by checking your network settings within VirtualBox, and connect to each of your machines using the vagrant ssh command to check the assigned IP address.