[Network] VirtualBox 네트워크 본딩(Network Bonding) 예제 및 테스트

네트워크 본딩(Network Bonding)을 해보고 실제 본딩된 slave 인터페이스를 끊어도 네트워크가 잘 되는지 확인해보자.


환경

  • CentOS 7.7.1908
  • Ubuntu 18.04
  • VirtualBox
  • Bash shell(/bin/bash)


기본 네트워크 구조

  • NIC 2개를 본딩
  • 호스트 전용 어댑터(Host-only Adapter)를 통해 각 VM의 2개의 NIC는 vboxnet0에 연결됨
  • VirtualBox에서 설정-네트워크에서 어댑터1에는 기존 NAT를 연결
  • VirtualBox에서 설정-네트워크에서 어댑터2와 어댑터3를 새로 연결


시나리오

  1. Client에서 Server에 Bonding된 IP주소로 Ping을 보낸다.
  2. Server의 active slave를 Down으로 만든다.
  3. 끊기지 않고 Ping이 계속 가는지 확인한다.


네트워크 본딩 설정

CentOS

centos-client

  • bond0
  • /etc/sysconfig/network-scripts/ifcfg-bond0
TYPE=Bond
BOOTPROTO=static
DEFROUTE=no
NAME=bond0
DEVICE=bond0
ONBOOT=yes
PREFIX=24
IPADDR=192.168.99.101
BONDING_OPTS="mode=1 miimon=100 fail_over_mac=1"
  • enp0s8
  • /etc/sysconfig/network-scripts/ifcfg-enp0s8
NAME=enp0s8
DEVICE=enp0s8
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
  • enp0s9
  • /etc/sysconfig/network-scripts/ifcfg-enp0s9
NAME=enp0s9
DEVICE=enp0s9
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes

centos-server

  • bond0
  • /etc/sysconfig/network-scripts/ifcfg-bond0
TYPE=Bond
BOOTPROTO=static
DEFROUTE=no
NAME=bond0
DEVICE=bond0
ONBOOT=yes
PREFIX=24
IPADDR=192.168.99.102
BONDING_OPTS="mode=1 miimon=100 fail_over_mac=1"
  • enp0s8
  • /etc/sysconfig/network-scripts/ifcfg-enp0s9
NAME=enp0s8
DEVICE=enp0s8
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
  • enp0s9
  • /etc/sysconfig/network-scripts/ifcfg-enp0s9
NAME=enp0s9
DEVICE=enp0s9
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes


Ubuntu

  • 18.04는 netplan을 이용해 네트워크를 세팅한다.
  • yaml 파일을 만들고 sudo netplan apply를 통해서 네트워크 설정들을 적용

ubuntu-client

  • /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        enp0s3:
            dhcp4: true
        enp0s8:
            dhcp4: false
        enp0s9:
            dhcp4: false
    version: 2
    bonds:
        bond0:
            dhcp4: false
            addresses:
                - 192.168.225.101/24
            gateway4: 192.168.225.1
            interfaces:
                - enp0s8
                - enp0s9
            parameters:
                mode: active-backup
                primary: enp0s8
                fail-over-mac-policy: active
                mii-monitor-interval: 100

ubuntu-server

  • /etc/netplan/50-cloud-init.yaml
# This file is generated from information provided by
# the datasource.  Changes to it will not persist across an instance.
# To disable cloud-init's network configuration capabilities, write a file
# /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg with the following:
# network: {config: disabled}
network:
    ethernets:
        enp0s3:
            dhcp4: true
        enp0s8:
            dhcp4: false
        enp0s9:
            dhcp4: false
    version: 2
    bonds:
        bond0:
            dhcp4: false
            addresses:
                - 192.168.225.102/24
            gateway4: 192.168.225.1
            interfaces:
                - enp0s8
                - enp0s9
            parameters:
                mode: active-backup
                primary: enp0s8
                fail-over-mac-policy: active
                mii-monitor-interval: 100


테스트

각각 active slave 확인

  • 명령어: cat /proc/net/bonding/bond0
  • 왼쪽이 Client 오른쪽이 Server
  • Active slave: enp0s8


Client -> Server ping 시작



Ping이 끊기지 않고 제대로 가는지 확인


Server에서 active slave가 누군지 확인

  • enp0s8 -> enp0s9


참고자료