Alpine Two Nodes

1 Overview


Container               VM1                  VM2
192.0.0.2            192.0.0.10           192.0.0.20
   br0                  eth1                 eth1
    +                    +                    +
    +--------------------+--------------------+

2 Setup

2.1 Setup Container

host$ git clone https://github.com/thachmpham/lab.git
host$ cd lab/alpine/use/two-nodes
host$ docker compose build
host$ docker compose up --detach
host$ docker exec -it apk bash

2.2 Setup VM1

Create VM1.

container$ ./create_vm1.sh
vm1$ setup-alpine
# - hostname:   vm1
# - interface:  eth0
# - ipv4 addr:  dhcp
# - ipv6 addr:  auto
# - manual network config:  no
# - password:
# - timezone:   UTC
# - proxy:      none
# - ntp:        busybox
# - apk mirror: 1
# - setup user: no
# - ssh server: openssh
# - allow root ssh: yes
# - ssh key:    none
# - disk:       sda, sys

vm1$ poweroff
container$ ./start_vm1.sh

Configure static IP.

vm1$ cat /etc/network/interfaces
# -------------------- #
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
hostname alpine-test

auto eth1
iface eth1 inet static
    address 192.0.0.10/24
# -------------------- #
vm1$ rc-service networking restart

vm1$ ip addr show
eth1: inet 192.0.0.10

2.3 Setup VM2

Create VM2.

container$ ./create_vm2.sh
vm2$ setup-alpine
# - hostname:   vm2
# - interface:  eth0
# - ipv4 addr:  dhcp
# - ipv6 addr:  auto
# - manual network config:  no
# - password:
# - timezone:   UTC
# - proxy:      none
# - ntp:        busybox
# - apk mirror: 1
# - setup user: no
# - ssh server: openssh
# - allow root ssh: yes
# - ssh key:    none
# - disk:       sda, sys

vm2$ poweroff
container$ ./start_vm2.sh

Configure static IP.

vm2$ cat /etc/network/interfaces
# -------------------- #
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet dhcp
hostname alpine-test

auto eth1
iface eth1 inet static
    address 192.0.0.20/24
# -------------------- #
vm2$ rc-service networking restart

vm2$ ip addr show
eth1: inet 192.0.0.20

2.4 Check

Check SSH.

container$ ssh root@192.0.0.10
container$ ssh root@192.0.0.20

Check ping.

# vm1 -> vm2
vm1$ ping 192.0.0.20
# vm2 -> vm1
vm2$ ping 192.0.0.10

3 Shortcuts

QEMU keys:

4 References