AWS CLI를 통해서 EC2 인스턴스를 생성, 나열 그리고 삭제를 해보자.


환경

  • Ubuntu 18.04
  • AWS CLI
  • Bash shell(/bin/bash)


과정

  1. AWS CLI 설치
  2. 기본 환경 설정(구성 및 자격 증명 설정)
  3. EC2 인스턴스 생성, 나열 그리고 삭제


AWS CLI 설치

패키지 업데이트 및 업그레이드

sudo apt-get update -y && sudo apt-get upgrade -y

pip3을 설치

sudo apt-get install python3-pip

AWS CLI 설치

  • aws 명령어를 인식하지 못하면 로그아웃하고 다시 로그인한다.
pip3 install awscli --upgrade --user

AWS CLI 버전 확인

$ aws --version
aws-cli/1.16.310 Python/3.6.9 Linux/4.15.0-72-generic botocore/1.13.46


기본 환경 설정(구성 및 자격 증명 설정)

사전 점검 사항

aws configure

$ aws configure
AWS Access Key ID [None]: [YOUR KEY]
AWS Secret Access Key [None]: [YOUR KEY]
Default region name [None]: ap-northeast-2
Default output format [None]: json

~/.aws/credentials 설정 확인

$ cat ~/.aws/credentials
[default]
aws_access_key_id = [YOUR KEY]
aws_secret_access_key = [YOUR KEY]

~/.aws/config 설정 확인

$ cat ~/.aws/config
[default]
region = ap-northeast-2
output = json


EC2 인스턴스 생성, 나열 그리고 삭제

사전 점검 사항

  • 만들어진 EC2 보안 그룹이 있다고 가정
  • 보안 그룹은 AWS에서 만들 수 있으며 테스트를 위해 만든 보안 그룹의 인바운드는 SSH 포트만 열고 아웃바운드는 모두 열어놓았다.

키 페어 생성

  • 아래 명령어로 만들어진 키 페어는 따로 보관
  • 기존에 있는 키 페어를 사용해도 무관하다. 단, 공개키는 AWS에 저장되어 있고 개인키는 보관하고 있어야 한다.
aws ec2 create-key-pair --key-name TestKeyPair --query 'KeyMaterial' --output text > TestKeyPair.pem

EC2 인스턴스 생성

  • --image-id : 인스턴스에 사용할 이미지 ID
  • ami-082bdb3b2d54d5a19 : Ubuntu Server 16.04 LTS (HVM), SSD Volume Type
  • --count : 생성할 인스턴스의 수
  • --key-name : 사용할 키 페어의 키
  • TestKeyPair : 위에서 만든 키 페어
  • --security-group-ids : 보안그룹 ID
aws ec2 run-instances --image-id ami-082bdb3b2d54d5a19 --count 1 --instance-type t2.micro --key-name TestKeyPair --security-group-ids [YOUR SECURITY GROUP ID]

EC2 인스턴스 나열

  • --filters : 인스턴스들을 불러올 때 사용할 필터로 예제에서는 instance-typet2.micro인 인스턴스들만 가져옴
  • --query : 인스턴스들을 불러와서 보여줄때 사용할 수 있는 옵션으로 예제에서는 인스턴스들의 ID만 나열하도록함
aws ec2 describe-instances --filters "Name=instance-type,Values=t2.micro" --query "Reservations[].Instances[].InstanceId"

EC2 인스턴스 연결

  • 키 파일 권한 설정
chmod 400 TestKeyPair.pem
  • ssh를 이용해 인스턴스에 접속
ssh -i "TestKeyPair.pem" [USER NAME]@[PUBLIC IP or PUBLIC AWS DNS]

EC2 인스턴스 삭제

  • --instance-ids : 인스턴스 ID를 이용해 삭제
aws ec2 terminate-instances --instance-ids [YOUR INSTANCE ID]


참고자료

Create, list and delete EC2 instance using AWS CLI


Environment and Prerequisite

  • Ubuntu 18.04
  • AWS CLI
  • Bash shell(/bin/bash)


Process

  1. Install AWS CLI
  2. Basic Setting(Configuration and Credential File Settings)
  3. EC2 Instance Create, List and Delete


Install AWS CLI

Package update and upgrade

sudo apt-get update -y && sudo apt-get upgrade -y

Install pip3

sudo apt-get install python3-pip

Install AWS CLI

  • Logout and login again if aws command is not work.
pip3 install awscli --upgrade --user

Check AWS CLI version

$ aws --version
aws-cli/1.16.310 Python/3.6.9 Linux/4.15.0-72-generic botocore/1.13.46


Basic Setting(Configuration and Credential File Settings)

Before setting

aws configure

$ aws configure
AWS Access Key ID [None]: [YOUR KEY]
AWS Secret Access Key [None]: [YOUR KEY]
Default region name [None]: ap-northeast-2
Default output format [None]: json

Check ~/.aws/credentials setting

$ cat ~/.aws/credentials
[default]
aws_access_key_id = [YOUR KEY]
aws_secret_access_key = [YOUR KEY]

Check ~/.aws/config 설정 확인 setting

$ cat ~/.aws/config
[default]
region = ap-northeast-2
output = json


EC2 Instance Create, List and Delete

Before setting

  • Consider that there is already made EC2 security group
  • You can make security group in aws website. My security group opens only ssh port in inbound and opens all ports in outbound.

Create key pair

  • Store key pair in your computer which is made from below command.
  • You can use your own key pair. However, public key should be in AWS and private key should be kept in your computer.
aws ec2 create-key-pair --key-name TestKeyPair --query 'KeyMaterial' --output text > TestKeyPair.pem

Create EC2 instance

  • --image-id : Instance image ID
  • ami-082bdb3b2d54d5a19 : Ubuntu Server 16.04 LTS (HVM), SSD Volume Type
  • --count : Number of instances
  • --key-name : Key pair key
  • TestKeyPair : The key pair that we made above
  • --security-group-ids : Security group ID
aws ec2 run-instances --image-id ami-082bdb3b2d54d5a19 --count 1 --instance-type t2.micro --key-name TestKeyPair --security-group-ids [YOUR SECURITY GROUP ID]

List EC2 instances

  • --filters : It is filter for instances. In this example, it gets instances of which instance-type is t2.micro.
  • --query : It is option for showing results of instances. In this example, it shows only ID of instances.
aws ec2 describe-instances --filters "Name=instance-type,Values=t2.micro" --query "Reservations[].Instances[].InstanceId"

Connect to EC2 instance

  • Set key file permission
chmod 400 TestKeyPair.pem
  • Access to instance using ssh
ssh -i "TestKeyPair.pem" [USER NAME]@[PUBLIC IP or PUBLIC AWS DNS]

Delete EC2 instance

  • --instance-ids : Delete using instance ID
aws ec2 terminate-instances --instance-ids [YOUR INSTANCE ID]


Reference

네트워크 본딩(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


참고자료

Make network bonding and test if it is still work even though active slave is down.


Environment and Prerequisite

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


Basic Network Structure

  • Bond two NICs
  • By using Host-only Adapter, each VM’s two NICs are connected to vboxnet0
  • In VirtualBox Settings-Network, Adapter 1 is connected to default NAT.
  • In VirtualBox Settings-Network, add new two adapters Adapter 2 and Adapter 3.


Scenario

  1. Ping to bonding interface’s IP address from Client to Server.
  2. Make active slave to Down in Server.
  3. Check ping is still going well.


Network Bonding Setting

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 use netplan to set network.
  • Make yaml file and apply it using sudo netplan apply command

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


Test

Check each active slave

  • Command : cat /proc/net/bonding/bond0
  • Left is Client and right is Server
  • Active slave : enp0s8


Start ping Client -> Server



Check ping is going well


Check which one is active slave in Server

  • enp0s8 -> enp0s9


Reference

네트워크 본딩(Network Bonding)을 할 때 active-backup 모드에서 fail_over_mac 옵션에 대해 알아보자


환경

  • CentOS 7.7.1908
  • Bash shell(/bin/bash)
  • Network bonding


fail_over_mac 옵션

fail_over_mac 옵션이란


fail_over_mac 옵션 종류

  • none or 0 : (Default) bond된 인터페이스와 모든 slave 인터페이스들의 MAC이 같은 값으로 설정되는 옵션으로 보통 가장 첫번째 slave 인터페이스의 MAC 주소를 모든 bond된 인터페이스와 slave 인터페이스들이 갖는다.
  • active or 1 : active 상태인 slave 인터페이스의 MAC 주소를 bond된 인터페이스의 MAC으로 설정하는 옵션으로 failover된 상황에서 active 상태인 slave에 따라에 bond된 인터페이스의 MAC 주소가 달라진다.
  • follow or 2 : bond된 인터페이스의 MAC 주소는 고정이고(보통 첫번째 slave 인터페이스의 MAC 주소를 갖는다.) active 상태가 되는 slave 인터페이스 MAC 주소에 해당 MAC 주소를 부여하는 방식이다. failover가 일어날때 새로 active 상태가 될 인터페이스의 MAC 주소를 이전의 active 상태였던 인터페이스에 부여하고 bond된 인터페이스의 MAC을 받는다.


fail_over_mac 옵션 예제

예제 실행 환경

  • 해당 예제의 Bonding 설정은 하단 (참고) Bonding 설정에 있습니다.
  • Host OS : Mac OS
  • Guest OS : CentOS 7.7.1908
  • Hypervisor : VirtualBox


none or 0 옵션 예제

  • Default option
  • fail_over_mac=0
  • VirtualBox에서는 해당 옵션으로 설정하면 active-backup이 잘 안되는 이슈가 있음.
[root@centos-client ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0 | grep fail_over_mac
BONDING_OPTS="mode=1 miimon=100 fail_over_mac=0"
  • bond0와 slave들(enp0s8과 enp0s9)의 MAC 주소가 동일
[root@centos-client ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:2b:04:6e brd ff:ff:ff:ff:ff:ff
3: enp0s8: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:e8:26:58 brd ff:ff:ff:ff:ff:ff
4: enp0s9: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:e8:26:58 brd ff:ff:ff:ff:ff:ff
8: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:e8:26:58 brd ff:ff:ff:ff:ff:ff


active or 1 옵션 예제

  • fail_over_mac=1
[root@centos-client ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0 | grep fail_over_mac
BONDING_OPTS="mode=1 miimon=100 fail_over_mac=1"
  • bond0의 MAC 주소와 첫번째 slave인 enp0s8의 MAC 주소가 동일
[root@centos-client ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:2b:04:6e brd ff:ff:ff:ff:ff:ff
3: enp0s8: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:e8:26:58 brd ff:ff:ff:ff:ff:ff
4: enp0s9: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:27:a9:2d brd ff:ff:ff:ff:ff:ff
9: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:e8:26:58 brd ff:ff:ff:ff:ff:ff
  • enp0s8 인터페이스 Down
ip link set dev enp0s8 down
  • bond0의 MAC 주소가 enp0s9의 MAC 주소로 변경됨
[root@centos-client ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:2b:04:6e brd ff:ff:ff:ff:ff:ff
3: enp0s8: <BROADCAST,MULTICAST,SLAVE> mtu 1500 qdisc pfifo_fast master bond0 state DOWN mode DEFAULT group default qlen 1000
    link/ether 08:00:27:e8:26:58 brd ff:ff:ff:ff:ff:ff
4: enp0s9: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:27:a9:2d brd ff:ff:ff:ff:ff:ff
9: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:27:a9:2d brd ff:ff:ff:ff:ff:ff


follow or 2 옵션 예제

  • fail_over_mac=2
  • VirtualBox에서는 해당 옵션으로 설정하면 active-backup이 잘 안되는 이슈가 있음.
[root@centos-client ~]# cat /etc/sysconfig/network-scripts/ifcfg-bond0 | grep fail_over_mac
BONDING_OPTS="mode=1 miimon=100 fail_over_mac=2"
  • bond0의 MAC 주소와 첫번째 slave인 enp0s8의 MAC 주소가 동일
[root@centos-client ~]# ip link show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:2b:04:6e brd ff:ff:ff:ff:ff:ff
3: enp0s8: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:e8:26:58 brd ff:ff:ff:ff:ff:ff
4: enp0s9: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:27:a9:2d brd ff:ff:ff:ff:ff:ff
10: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:e8:26:58 brd ff:ff:ff:ff:ff:ff
  • enp0s8 인터페이스 Down
ip link set dev enp0s8 down
  • bond0의 MAC 주소는 이전과 동일
  • 새로 active 상태가 된 enp0s9 인터페이스에 bond0의 MAC 주소가 할당됨
  • fail이 일어난 enp0s8 인터페이스에는 새로 active 상태가 된 enp0s9 인터페이스의 예전 MAC 주소가 할당됨
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: enp0s3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:2b:04:6e brd ff:ff:ff:ff:ff:ff
3: enp0s8: <BROADCAST,MULTICAST,SLAVE> mtu 1500 qdisc pfifo_fast master bond0 state DOWN mode DEFAULT group default qlen 1000
    link/ether 08:00:27:27:a9:2d brd ff:ff:ff:ff:ff:ff
4: enp0s9: <BROADCAST,MULTICAST,SLAVE,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast master bond0 state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:e8:26:58 brd ff:ff:ff:ff:ff:ff
10: bond0: <BROADCAST,MULTICAST,MASTER,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 08:00:27:e8:26:58 brd ff:ff:ff:ff:ff:ff


(참고) Bonding 설정

  • 기본적인 본딩 설정은 아래와 같습니다.

Interfaces

  • Bonding Interface : bond0
  • Slave Interfaces : enp0s8, enp0s9

bond0

  • /etc/sysconfig/network-scripts/ifcfg-bond0
  • IPADDRPREFIX는 환경에 따라 다를 수 있습니다.
  • fail_over_mac 옵션은 0~2까지 다르게 설정 가능합니다.
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, enp0s9

  • /etc/sysconfig/network-scripts/ifcfg-enp0s8
NAME=enp0s8
DEVICE=enp0s8
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes
  • /etc/sysconfig/network-scripts/ifcfg-enp0s9
NAME=enp0s9
DEVICE=enp0s9
TYPE=Ethernet
BOOTPROTO=none
ONBOOT=yes
MASTER=bond0
SLAVE=yes


참고자료