この記事は約74分14秒で読むことができます。

vagrantで複数台の仮想ゲストOSを立ち上げた時の話

まえがき

とりあえず、複数立ち上げたらどうなるかみてみた。

参考文献

Vagrantで複数の仮想マシンを立ち上げる マルチマシン(Malti-Machine)設定  

Vagrantfile

コード表示

[oracle@centos vx]$ cat V*e
# -*- mode: ruby -*-
# vi: set ft=ruby :

Vagrant.configure("2") do |config|
  config.vm.box = "centos/7"
  
  config.vm.define "node1" do |centos_on_kvm|
    centos_on_kvm.vm.hostname = "node1"
    centos_on_kvm.vm.provider "libvirt" do |spec|
      spec.memory = 2048
      spec.cpus = 2
    end
  end
  config.vm.define "node2" do |centos_on_kvm|
    centos_on_kvm.vm.hostname = "node2"
    centos_on_kvm.vm.provider "libvirt" do |spec|
      spec.memory = 2048
      spec.cpus = 2
    end
  end
  config.vm.define "node3" do |centos_on_kvm|
    centos_on_kvm.vm.hostname = "node3"
    centos_on_kvm.vm.provider "libvirt" do |spec|
      spec.memory = 2048
      spec.cpus = 2
    end
  end
end

実行ログ

コード表示

[oracle@centos vx]$ vagrant up
Bringing machine 'node1' up with 'libvirt' provider...
Bringing machine 'node2' up with 'libvirt' provider...
Bringing machine 'node3' up with 'libvirt' provider...
==> node1: Creating image (snapshot of base box volume).
==> node1: Creating domain with the following settings...
==> node1:  -- Name:              vx_node1
==> node1:  -- Domain type:       kvm
==> node3: Creating image (snapshot of base box volume).
==> node2: Creating image (snapshot of base box volume).
==> node1:  -- Cpus:              2
==> node2: Creating domain with the following settings...
==> node1:  -- Feature:           acpi
==> node3: Creating domain with the following settings...
==> node2:  -- Name:              vx_node2
==> node3:  -- Name:              vx_node3
==> node1:  -- Feature:           apic
==> node3:  -- Domain type:       kvm
==> node2:  -- Domain type:       kvm
==> node3:  -- Cpus:              2
==> node1:  -- Feature:           pae
==> node3:  -- Feature:           acpi
==> node2:  -- Cpus:              2
==> node3:  -- Feature:           apic
==> node1:  -- Memory:            2048M
==> node2:  -- Feature:           acpi
==> node3:  -- Feature:           pae
==> node1:  -- Management MAC:    
==> node2:  -- Feature:           apic
==> node3:  -- Memory:            2048M
==> node1:  -- Loader:            
==> node2:  -- Feature:           pae
==> node3:  -- Management MAC:    
==> node2:  -- Memory:            2048M
==> node1:  -- Nvram:             
==> node3:  -- Loader:            
==> node2:  -- Management MAC:    
==> node1:  -- Base box:          centos/7
==> node3:  -- Nvram:             
==> node1:  -- Storage pool:      default
==> node2:  -- Loader:            
==> node3:  -- Base box:          centos/7
==> node1:  -- Image:             /var/lib/libvirt/images/vx_node1.img (41G)
==> node3:  -- Storage pool:      default
==> node2:  -- Nvram:             
==> node1:  -- Volume Cache:      default
==> node2:  -- Base box:          centos/7
==> node3:  -- Image:             /var/lib/libvirt/images/vx_node3.img (41G)
==> node1:  -- Kernel:            
==> node2:  -- Storage pool:      default
==> node1:  -- Initrd:            
==> node3:  -- Volume Cache:      default
==> node2:  -- Image:             /var/lib/libvirt/images/vx_node2.img (41G)
==> node1:  -- Graphics Type:     vnc
==> node3:  -- Kernel:            
==> node2:  -- Volume Cache:      default
==> node3:  -- Initrd:            
==> node1:  -- Graphics Port:     -1
==> node3:  -- Graphics Type:     vnc
==> node2:  -- Kernel:            
==> node1:  -- Graphics IP:       127.0.0.1
==> node3:  -- Graphics Port:     -1
==> node1:  -- Graphics Password: Not defined
==> node2:  -- Initrd:            
==> node3:  -- Graphics IP:       127.0.0.1
==> node1:  -- Video Type:        cirrus
==> node3:  -- Graphics Password: Not defined
==> node2:  -- Graphics Type:     vnc
==> node1:  -- Video VRAM:        9216
==> node3:  -- Video Type:        cirrus
==> node1:  -- Sound Type:	
==> node2:  -- Graphics Port:     -1
==> node3:  -- Video VRAM:        9216
==> node1:  -- Keymap:            en-us
==> node2:  -- Graphics IP:       127.0.0.1
==> node3:  -- Sound Type:	
==> node1:  -- TPM Path:          
==> node2:  -- Graphics Password: Not defined
==> node3:  -- Keymap:            en-us
==> node1:  -- INPUT:             type=mouse, bus=ps2
==> node2:  -- Video Type:        cirrus
==> node3:  -- TPM Path:          
==> node3:  -- INPUT:             type=mouse, bus=ps2
==> node2:  -- Video VRAM:        9216
==> node2:  -- Sound Type:	
==> node2:  -- Keymap:            en-us
==> node2:  -- TPM Path:          
==> node2:  -- INPUT:             type=mouse, bus=ps2
==> node1: Creating shared folders metadata...
==> node3: Creating shared folders metadata...
==> node3: Starting domain.
==> node1: Starting domain.
==> node3: Waiting for domain to get an IP address...
==> node1: Waiting for domain to get an IP address...
==> node2: Creating shared folders metadata...
==> node2: Starting domain.
==> node2: Waiting for domain to get an IP address...
==> node3: Waiting for SSH to become available...
==> node1: Waiting for SSH to become available...
==> node2: Waiting for SSH to become available...
    node1: 
    node1: Vagrant insecure key detected. Vagrant will automatically replace
    node1: this with a newly generated keypair for better security.
    node3: 
    node3: Vagrant insecure key detected. Vagrant will automatically replace
    node3: this with a newly generated keypair for better security.
    node2: 
    node2: Vagrant insecure key detected. Vagrant will automatically replace
    node2: this with a newly generated keypair for better security.
    node3: 
    node3: Inserting generated public key within guest...
    node1: 
    node1: Inserting generated public key within guest...
    node2: 
    node2: Inserting generated public key within guest...
    node3: Removing insecure key from the guest if it's present...
    node1: Removing insecure key from the guest if it's present...
    node2: Removing insecure key from the guest if it's present...
    node3: Key inserted! Disconnecting and reconnecting using new SSH key...
    node1: Key inserted! Disconnecting and reconnecting using new SSH key...
    node2: Key inserted! Disconnecting and reconnecting using new SSH key...
==> node3: Setting hostname...
==> node1: Setting hostname...
==> node2: Setting hostname...
==> node3: Configuring and enabling network interfaces...
==> node1: Configuring and enabling network interfaces...
==> node2: Configuring and enabling network interfaces...
    node3: SSH address: 192.168.121.209:22
    node3: SSH username: vagrant
    node3: SSH auth method: private key
    node1: SSH address: 192.168.121.32:22
    node1: SSH username: vagrant
    node1: SSH auth method: private key
    node2: SSH address: 192.168.121.99:22
    node2: SSH username: vagrant
    node2: SSH auth method: private key
==> node3: Rsyncing folder: /home/oracle/vx/ => /vagrant
==> node1: Rsyncing folder: /home/oracle/vx/ => /vagrant
==> node2: Rsyncing folder: /home/oracle/vx/ => /vagrant

起動確認

コード表示

[oracle@centos vx]$ vagrant status
Current machine states:

node1                     running (libvirt)
node2                     running (libvirt)
node3                     running (libvirt)

This environment represents multiple VMs. The VMs are all listed
above with their current state. For more information about a specific
VM, run `vagrant status NAME`.

ネットワーク確認

コード表示

[oracle@centos vx]$ sudo virsh net-list
[sudo] oracle のパスワード:
 名前               状態     自動起動  永続
----------------------------------------------------------
 default              動作中  はい (yes)  はい (yes)
 vagrant-libvirt      動作中  いいえ (no) はい (yes)

ブリッチ設定確認

コード表示

[root@centos networks]# brctl show
bridge name	bridge id		STP enabled	interfaces
docker0		8000.0242b22c2a85	no		
virbr0		8000.525400bad5c4	yes		virbr0-nic
virbr1		8000.52540042696d	yes		virbr1-nic
							vnet0
							vnet1
							vnet2

仮想ホストOS側のNIC設定確認

コード表示

[oracle@centos vx]$ ip a show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 00:d8:61:2c:f1:5b brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.109/24 brd 192.168.1.255 scope global noprefixroute eno1
       valid_lft forever preferred_lft forever
    inet6 fe80::865a:b7c8:6a76:1722/64 scope link noprefixroute 
       valid_lft forever preferred_lft forever
3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
    link/ether 02:42:b2:2c:2a:85 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
    inet6 fe80::42:b2ff:fe2c:2a85/64 scope link 
       valid_lft forever preferred_lft forever
4: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
    link/ether 52:54:00:ba:d5:c4 brd ff:ff:ff:ff:ff:ff
5: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN group default qlen 1000
    link/ether 52:54:00:ba:d5:c4 brd ff:ff:ff:ff:ff:ff
90: virbr1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 52:54:00:42:69:6d brd ff:ff:ff:ff:ff:ff
    inet 192.168.121.1/24 brd 192.168.121.255 scope global virbr1
       valid_lft forever preferred_lft forever
91: virbr1-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr1 state DOWN group default qlen 1000
    link/ether 52:54:00:42:69:6d brd ff:ff:ff:ff:ff:ff
96: vnet0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master virbr1 state UNKNOWN group default qlen 1000
    link/ether fe:54:00:14:54:0f brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:fe14:540f/64 scope link 
       valid_lft forever preferred_lft forever
97: vnet1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master virbr1 state UNKNOWN group default qlen 1000
    link/ether fe:54:00:4f:71:b5 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:fe4f:71b5/64 scope link 
       valid_lft forever preferred_lft forever
98: vnet2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master virbr1 state UNKNOWN group default qlen 1000
    link/ether fe:54:00:82:1d:03 brd ff:ff:ff:ff:ff:ff
    inet6 fe80::fc54:ff:fe82:1d03/64 scope link 
       valid_lft forever preferred_lft forever

仮想ホストOSと仮想ゲストOSのマスカレ設定確認

コード表示

[root@centos networks]# sudo iptables -t nat -L -n | grep -A 16 "Chain POSTROUTING (policy ACCEPT)"
Chain POSTROUTING (policy ACCEPT)
target     prot opt source               destination         
RETURN     all  --  192.168.121.0/24     224.0.0.0/24        
RETURN     all  --  192.168.121.0/24     255.255.255.255     
MASQUERADE  tcp  --  192.168.121.0/24    !192.168.121.0/24     masq ports: 1024-65535
MASQUERADE  udp  --  192.168.121.0/24    !192.168.121.0/24     masq ports: 1024-65535
MASQUERADE  all  --  192.168.121.0/24    !192.168.121.0/24    
RETURN     all  --  192.168.122.0/24     224.0.0.0/24        
RETURN     all  --  192.168.122.0/24     255.255.255.255     
MASQUERADE  tcp  --  192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
MASQUERADE  udp  --  192.168.122.0/24    !192.168.122.0/24     masq ports: 1024-65535
MASQUERADE  all  --  192.168.122.0/24    !192.168.122.0/24    
MASQUERADE  all  --  172.17.0.0/16        0.0.0.0/0           
POSTROUTING_direct  all  --  0.0.0.0/0            0.0.0.0/0           
POSTROUTING_ZONES_SOURCE  all  --  0.0.0.0/0            0.0.0.0/0           
POSTROUTING_ZONES  all  --  0.0.0.0/0            0.0.0.0/0           

libvirt管理のネットワーク確認

コード表示

[root@centos vx]# cd /etc/libvirt/qemu/networks
[root@centos networks]# ll
合計 12
drwx------. 2 root root 4096  5月 15 06:08 autostart
-rw-------. 1 root root  576  5月 12 16:11 default.xml
-rw-------. 1 root root  603  5月 24 06:45 vagrant-libvirt.xml
[root@centos networks]# cat default.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
  virsh net-edit default
or other application using the libvirt API.
-->

<network>
  <name>default</name>
  <uuid>431ebd86-8c41-4a77-91be-9dc7e8cb097e</uuid>
  <forward mode='nat'/>
  <bridge name='virbr0' stp='on' delay='0'/>
  <mac address='52:54:00:ba:d5:c4'/>
  <ip address='192.168.122.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.122.2' end='192.168.122.254'/>
    </dhcp>
  </ip>
</network>
[root@centos networks]# cat vagrant-libvirt.xml
<!--
WARNING: THIS IS AN AUTO-GENERATED FILE. CHANGES TO IT ARE LIKELY TO BE
OVERWRITTEN AND LOST. Changes to this xml configuration should be made using:
  virsh net-edit vagrant-libvirt
or other application using the libvirt API.
-->

<network ipv6='yes'>
  <name>vagrant-libvirt</name>
  <uuid>a86854f5-a240-42c6-b7da-ecd457aea19e</uuid>
  <forward mode='nat'/>
  <bridge name='virbr1' stp='on' delay='0'/>
  <mac address='52:54:00:42:69:6d'/>
  <ip address='192.168.121.1' netmask='255.255.255.0'>
    <dhcp>
      <range start='192.168.121.1' end='192.168.121.254'/>
    </dhcp>
  </ip>
</network>

仮想ゲストOSノード1にssh接続

コード表示

[oracle@centos vx]$ vagrant ssh node1
[vagrant@node1 ~]$ ip a show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:4f:71:b5 brd ff:ff:ff:ff:ff:ff
    inet 192.168.121.32/24 brd 192.168.121.255 scope global noprefixroute dynamic eth0
       valid_lft 3384sec preferred_lft 3384sec
    inet6 fe80::5054:ff:fe4f:71b5/64 scope link 
       valid_lft forever preferred_lft forever
[vagrant@node1 ~]$ su root
Password: vagrant
[root@node1 vagrant]# yum install -y net-tools
[root@node1 vagrant]# netstat -anp | grep -E "Active|Proto|ssh"
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2633/sshd           
tcp        0      0 192.168.121.32:22       192.168.121.1:38226     ESTABLISHED 5422/sshd: vagrant  
tcp6       0      0 :::22                   :::*                    LISTEN      2633/sshd           
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name     Path
unix  2      [ ]         DGRAM                    31193    5422/sshd: vagrant   
unix  3      [ ]         STREAM     CONNECTED     31196    5425/sshd: vagrant@  
unix  3      [ ]         STREAM     CONNECTED     31197    5422/sshd: vagrant   
unix  3      [ ]         STREAM     CONNECTED     21321    2633/sshd            
[root@node1 vagrant]# yum install -y lsof
[root@node1 vagrant]# lsof -i -nP | grep -E "COMMAND|ssh"
COMMAND   PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd     2633    root    3u  IPv4  21394      0t0  TCP *:22 (LISTEN)
sshd     2633    root    4u  IPv6  21403      0t0  TCP *:22 (LISTEN)
sshd     5422    root    3u  IPv4  31111      0t0  TCP 192.168.121.32:22->192.168.121.1:38226 (ESTABLISHED)
sshd     5425 vagrant    3u  IPv4  31111      0t0  TCP 192.168.121.32:22->192.168.121.1:38226 (ESTABLISHED)
[root@node1 vagrant]# yum install -y psmisc
[root@node1 vagrant]# pstree -p
systemd(1)-+-NetworkManager(4841)-+-dhclient(4861)
           |                      |-{NetworkManager}(4842)
           |                      `-{NetworkManager}(4844)
           |-agetty(1762)
           |-agetty(1932)
           |-auditd(1203)---{auditd}(1205)
           |-chronyd(1511)
           |-crond(1761)
           |-dbus-daemon(1471)---{dbus-daemon}(1587)
           |-gssproxy(1464)-+-{gssproxy}(1490)
           |                |-{gssproxy}(1491)
           |                |-{gssproxy}(1492)
           |                |-{gssproxy}(1493)
           |                `-{gssproxy}(1494)
           |-irqbalance(1437)
           |-master(2877)-+-pickup(2878)
           |              `-qmgr(2879)
           |-polkitd(1439)-+-{polkitd}(1538)
           |               |-{polkitd}(1619)
           |               |-{polkitd}(1632)
           |               |-{polkitd}(1643)
           |               |-{polkitd}(1645)
           |               `-{polkitd}(1648)
           |-rpcbind(1674)
           |-rsyslogd(2634)-+-{rsyslogd}(2639)
           |                `-{rsyslogd}(2641)
           |-sshd(2633)---sshd(5422)---sshd(5425)---bash(5426)---su(5448)---bash(5452)---pstree(5554)
           |-systemd-journal(1146)
           |-systemd-logind(1449)
           |-systemd-udevd(1179)
           `-tuned(2632)-+-{tuned}(2822)
                         |-{tuned}(2823)
                         |-{tuned}(2824)
                         `-{tuned}(2876)
[root@node1 vagrant]# yum install -y traceroute
[root@node1 vagrant]# traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
 1  gateway (192.168.121.1)  0.095 ms  0.074 ms  0.053 ms
 2  192.168.1.1 (192.168.1.1)  1.838 ms  1.820 ms  1.814 ms
 3  nas827.p-kanagawa.nttpc.ne.jp (210.153.251.235)  4.495 ms  5.015 ms  5.003 ms
 4  210.139.125.169 (210.139.125.169)  4.990 ms  5.083 ms  5.542 ms
 5  210.165.249.177 (210.165.249.177)  6.561 ms  5.832 ms  6.640 ms
 6  0-0-0-18.tky-no-acr01.sphere.ad.jp (210.153.241.89)  8.476 ms  8.465 ms  8.428 ms
 7  0-0-1-0--2025.tky-t4-bdr01.sphere.ad.jp (202.239.117.14)  9.317 ms  7.725 ms  7.701 ms
 8  72.14.202.229 (72.14.202.229)  7.327 ms  7.319 ms  7.663 ms
 9  * * *
10  google-public-dns-a.google.com (8.8.8.8)  7.740 ms  7.879 ms  7.931 ms
[root@node1 vagrant]# exit
[vagrant@node1 ~]$ logout
Connection to 192.168.121.32 closed.

仮想ゲストOSノード2にssh接続

コード表示

[oracle@centos vx]$ vagrant ssh node2
[vagrant@node2 ~]$ ip a show
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:82:1d:03 brd ff:ff:ff:ff:ff:ff
    inet 192.168.121.99/24 brd 192.168.121.255 scope global noprefixroute dynamic eth0
       valid_lft 2468sec preferred_lft 2468sec
    inet6 fe80::5054:ff:fe82:1d03/64 scope link 
       valid_lft forever preferred_lft forever
[vagrant@node2 ~]$ su root
Password: vagrant
[root@node2 vagrant]# yum install -y net-tools
[root@node2 vagrant]# netstat -anp | grep -E "Active|Proto|ssh"
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2630/sshd           
tcp        0      0 192.168.121.99:22       192.168.121.1:37726     ESTABLISHED 5421/sshd: vagrant  
tcp6       0      0 :::22                   :::*                    LISTEN      2630/sshd           
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name     Path
unix  3      [ ]         STREAM     CONNECTED     20384    2630/sshd            
unix  3      [ ]         STREAM     CONNECTED     31362    5424/sshd: vagrant@  
unix  2      [ ]         DGRAM                    31359    5421/sshd: vagrant   
unix  3      [ ]         STREAM     CONNECTED     31363    5421/sshd: vagrant   


[root@node2 vagrant]# yum install -y lsof
[root@node2 vagrant]# lsof -i -nP | grep -E "COMMAND|ssh"
COMMAND   PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd     2630    root    3u  IPv4  20470      0t0  TCP *:22 (LISTEN)
sshd     2630    root    4u  IPv6  20479      0t0  TCP *:22 (LISTEN)
sshd     5421    root    3u  IPv4  30566      0t0  TCP 192.168.121.99:22->192.168.121.1:37726 (ESTABLISHED)
sshd     5424 vagrant    3u  IPv4  30566      0t0  TCP 192.168.121.99:22->192.168.121.1:37726 (ESTABLISHED)
[root@node2 vagrant]# yum install -y psmisc
[root@node2 vagrant]# pstree -p
systemd(1)-+-NetworkManager(4838)-+-dhclient(4863)
           |                      |-{NetworkManager}(4839)
           |                      `-{NetworkManager}(4841)
           |-agetty(1844)
           |-agetty(1938)
           |-auditd(1203)---{auditd}(1205)
           |-chronyd(1556)
           |-crond(1862)
           |-dbus-daemon(1428)---{dbus-daemon}(1491)
           |-gssproxy(1550)-+-{gssproxy}(1577)
           |                |-{gssproxy}(1578)
           |                |-{gssproxy}(1579)
           |                |-{gssproxy}(1580)
           |                `-{gssproxy}(1581)
           |-irqbalance(1422)
           |-master(2873)-+-pickup(2875)
           |              `-qmgr(2876)
           |-polkitd(1499)-+-{polkitd}(1560)
           |               |-{polkitd}(1573)
           |               |-{polkitd}(1585)
           |               |-{polkitd}(1593)
           |               |-{polkitd}(1596)
           |               `-{polkitd}(1607)
           |-rpcbind(1430)
           |-rsyslogd(2633)-+-{rsyslogd}(2637)
           |                `-{rsyslogd}(2638)
           |-sshd(2630)---sshd(5421)---sshd(5424)---bash(5425)---su(5447)---bash(5451)---pstree(5520)
           |-systemd-journal(1145)
           |-systemd-logind(1528)
           |-systemd-udevd(1176)
           `-tuned(2629)-+-{tuned}(2826)
                         |-{tuned}(2827)
                         |-{tuned}(2831)
                         `-{tuned}(2877)
[root@node2 vagrant]# yum install -y traceroute
[root@node2 vagrant]# traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
 1  gateway (192.168.121.1)  0.095 ms  0.074 ms  0.053 ms
 2  192.168.1.1 (192.168.1.1)  1.838 ms  1.820 ms  1.814 ms
 3  nas827.p-kanagawa.nttpc.ne.jp (210.153.251.235)  4.495 ms  5.015 ms  5.003 ms
 4  210.139.125.169 (210.139.125.169)  4.990 ms  5.083 ms  5.542 ms
 5  210.165.249.177 (210.165.249.177)  6.561 ms  5.832 ms  6.640 ms
 6  0-0-0-18.tky-no-acr01.sphere.ad.jp (210.153.241.89)  8.476 ms  8.465 ms  8.428 ms
 7  0-0-1-0--2025.tky-t4-bdr01.sphere.ad.jp (202.239.117.14)  9.317 ms  7.725 ms  7.701 ms
 8  72.14.202.229 (72.14.202.229)  7.327 ms  7.319 ms  7.663 ms
 9  * * *
10  google-public-dns-a.google.com (8.8.8.8)  7.740 ms  7.879 ms  7.931 ms
[root@node2 vagrant]# exit
[vagrant@node2 ~]$ logout
Connection to 192.168.121.99 closed.

仮想ゲストOSノード3にssh接続

コード表示

[oracle@centos vx]$ vagrant ssh node3
[vagrant@node3 ~]$ ip a show
1: lo:  mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host 
       valid_lft forever preferred_lft forever
2: eth0:  mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:14:54:0f brd ff:ff:ff:ff:ff:ff
    inet 192.168.121.209/24 brd 192.168.121.255 scope global noprefixroute dynamic eth0
       valid_lft 2261sec preferred_lft 2261sec
    inet6 fe80::5054:ff:fe14:540f/64 scope link 
       valid_lft forever preferred_lft forever
[vagrant@node3 ~]$ su root
Password: 
[root@node3 vagrant]# yum install -y net-tools


[root@node3 vagrant]# netstat -anp | grep -E "Active|Proto|ssh"
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name    
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2614/sshd           
tcp        0      0 192.168.121.209:22      192.168.121.1:58210     ESTABLISHED 5404/sshd: vagrant  
tcp6       0      0 :::22                   :::*                    LISTEN      2614/sshd           
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   PID/Program name     Path
unix  3      [ ]         STREAM     CONNECTED     22553    2614/sshd            
unix  3      [ ]         STREAM     CONNECTED     31015    5407/sshd: vagrant@  
unix  3      [ ]         STREAM     CONNECTED     31016    5404/sshd: vagrant   
unix  2      [ ]         DGRAM                    31012    5404/sshd: vagrant   
[root@node3 vagrant]# yum install -y lsof
[root@node3 vagrant]# lsof -i -nP | grep -E "COMMAND|ssh"
COMMAND   PID    USER   FD   TYPE DEVICE SIZE/OFF NODE NAME
sshd     2614    root    3u  IPv4  21823      0t0  TCP *:22 (LISTEN)
sshd     2614    root    4u  IPv6  21835      0t0  TCP *:22 (LISTEN)
sshd     5404    root    3u  IPv4  31849      0t0  TCP 192.168.121.209:22->192.168.121.1:58210 (ESTABLISHED)
sshd     5407 vagrant    3u  IPv4  31849      0t0  TCP 192.168.121.209:22->192.168.121.1:58210 (ESTABLISHED)
[root@node3 vagrant]# yum install -y psmisc
[root@node3 vagrant]# pstree -p
systemd(1)-+-NetworkManager(4821)-+-dhclient(4844)
           |                      |-{NetworkManager}(4822)
           |                      `-{NetworkManager}(4824)
           |-agetty(1799)
           |-agetty(1987)
           |-auditd(1201)---{auditd}(1202)
           |-chronyd(1459)
           |-crond(1793)
           |-dbus-daemon(1413)---{dbus-daemon}(1472)
           |-gssproxy(1422)-+-{gssproxy}(1442)
           |                |-{gssproxy}(1443)
           |                |-{gssproxy}(1444)
           |                |-{gssproxy}(1445)
           |                `-{gssproxy}(1446)
           |-irqbalance(1375)
           |-master(2857)-+-pickup(2858)
           |              `-qmgr(2859)
           |-polkitd(1391)-+-{polkitd}(1470)
           |               |-{polkitd}(1491)
           |               |-{polkitd}(1501)
           |               |-{polkitd}(1514)
           |               |-{polkitd}(1515)
           |               `-{polkitd}(1532)
           |-rpcbind(1381)
           |-rsyslogd(2617)-+-{rsyslogd}(2621)
           |                `-{rsyslogd}(2622)
           |-sshd(2614)---sshd(5404)---sshd(5407)---bash(5408)---su(5431)---bash(5435)---pstree(5503)
           |-systemd-journal(1144)
           |-systemd-logind(1488)
           |-systemd-udevd(1175)
           `-tuned(2612)-+-{tuned}(2802)
                         |-{tuned}(2803)
                         |-{tuned}(2804)
                         `-{tuned}(2817)
[root@node3 vagrant]# yum install -y traceroute
[root@node3 vagrant]# traceroute 8.8.8.8
traceroute to 8.8.8.8 (8.8.8.8), 30 hops max, 60 byte packets
 1  gateway (192.168.121.1)  0.095 ms  0.074 ms  0.053 ms
 2  192.168.1.1 (192.168.1.1)  1.838 ms  1.820 ms  1.814 ms
 3  nas827.p-kanagawa.nttpc.ne.jp (210.153.251.235)  4.495 ms  5.015 ms  5.003 ms
 4  210.139.125.169 (210.139.125.169)  4.990 ms  5.083 ms  5.542 ms
 5  210.165.249.177 (210.165.249.177)  6.561 ms  5.832 ms  6.640 ms
 6  0-0-0-18.tky-no-acr01.sphere.ad.jp (210.153.241.89)  8.476 ms  8.465 ms  8.428 ms
 7  0-0-1-0--2025.tky-t4-bdr01.sphere.ad.jp (202.239.117.14)  9.317 ms  7.725 ms  7.701 ms
 8  72.14.202.229 (72.14.202.229)  7.327 ms  7.319 ms  7.663 ms
 9  * * *
10  google-public-dns-a.google.com (8.8.8.8)  7.740 ms  7.879 ms  7.931 ms
[root@node3 vagrant]# exit
[vagrant@node3 ~]$ logout
Connection to 192.168.121.209 closed.

あとがき

おもしろくなってきた!!

Leave a Reply

Your email address will not be published. Required fields are marked *