CentOS7, network bonding 설정, 확인, Active 인터페이스 변경.

CentOS 7, Bonding 설정, 확인, Active 인터페이스 변경하기.

본딩 종류는 https://blog.boxcorea.com/wp/archives/788 아래 부분을 참고하면 된다.

여기에서는 active-standby 구성을 했다.

1. bonding 커널 모듈
커널 모듈이 사용중인지 확인한다.

[root@localhost ~]# lsmod | grep -i bond
[root@localhost ~]#

사용하지 않고 있으므로 사용하도록 해 둔다.

[root@localhost ~]# modprobe bonding
[root@localhost ~]# lsmod | grep -i bond
bonding               152656  0
[root@localhost ~]#

2. bonding 인터페이스를 만든다. 여기서 이름은 bond0로 설정한다. (다른 이름을 사용해도 된다.)

[root@localhost ~]# cd /etc/sysconfig/network-scripts/

[root@localhost network-scripts]# vi ifcfg-bond0

TYPE=Bond
DEVICE=bond0
NAME=bond0
BONDING_MASTER=yes
BOOTPROTO=none
onBOOT=yes
IPADDR=172.16.96.223
NETMASK=255.255.255.0
GATEWAY=172.16.96.1
DNS1=8.8.8.8
BONDING_OPTS="mode=active-backup million=100"

설정 저장하고 네트워크 인터페이스를 확인해 보면, ens32, ens33 두개의 랜카드와 bond0가 보인다.

[root@localhost network-scripts]# ip link
1: lo:  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: ens32:  mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:50:56:9d:da:8e brd ff:ff:ff:ff:ff:ff
3: ens33:  mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
    link/ether 00:50:56:9d:34:5a brd ff:ff:ff:ff:ff:ff
4: bond0:  mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
    link/ether ca:0b:93:09:2e:14 brd ff:ff:ff:ff:ff:ff

3. ens32, ens33 네트워크 인터페이스를 bonding 에 사용하도록 설정한다.

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens32
TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
EFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens32
UUID=f0c0eb60-248e-4f90-b86a-cbf9c37ad43c
DEVICE=ens32
ONBOOT=yes
MASTER=bond0
SLAVE=yes
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-ens33

TYPE=Ethernet
PROXY_METHOD=none
BROWSER_ONLY=no
BOOTPROTO=none
DEFROUTE=yes
IPV4_FAILURE_FATAL=no
IPV6INIT=yes
IPV6_AUTOCONF=yes
IPV6_DEFROUTE=yes
IPV6_FAILURE_FATAL=no
IPV6_ADDR_GEN_MODE=stable-privacy
NAME=ens33
UUID=8bbc7610-4f06-4105-8ca7-d089a1377b34
DEVICE=ens33
ONBOOT=yes
MASTER=bond0
SLAVE=yes

4. 네트워크 재 시작하고 확인.
네트워크 서비스를 재 시학한다.

[root@localhost ~]# systemctl restart network

ip addr 명령으로 확인해 보면, bond0 인터페이스에 ip 주소가 잘 설정되어 있으며, ens32, ens33 모두 up 상태인 것을 볼 수 있다.

[root@localhost ~]# ip addr
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: ens32:  mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000
    link/ether 00:50:56:9d:34:5a brd ff:ff:ff:ff:ff:ff
3: ens33:  mtu 1500 qdisc pfifo_fast master bond0 state UP group default qlen 1000
    link/ether 00:50:56:9d:34:5a brd ff:ff:ff:ff:ff:ff
4: bond0:  mtu 1500 qdisc noqueue state UP group default qlen 1000
    link/ether 00:50:56:9d:34:5a brd ff:ff:ff:ff:ff:ff
    inet 172.16.96.223/24 brd 172.16.96.255 scope global noprefixroute bond0
       valid_lft forever preferred_lft forever
    inet6 fe80::250:56ff:fe9d:345a/64 scope link
       valid_lft forever preferred_lft forever

5. 본딩에서 Primary 네트워크 인터페이스 확인과 변경.

bond0 상태를 확인 해 보면, ens32 인터페이스가 Primary slave(ACTIVE 인터페이스)로 지정되어 있는 것을 확인 할 수 있다.

[root@localhost ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: ens32 (primary_reselect always)
Currently Active Slave: ens32
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens33
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:50:56:9d:34:5a
Slave queue ID: 0

Slave Interface: ens32
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:50:56:9d:da:8e
Slave queue ID: 0
[root@localhost ~]#

primary slave 인터페이스를 변경하려면, BONDING_OPTS 에 primary 인터페이스를 지정해 주면 된다.
ens33을 active 인터페이스롤 사용하고 싶다면, 설정파일에 아래 내용을 추가해 준다.

[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-bond0

TYPE=Bond
DEVICE=bond0
NAME=bond0
BONDING_MASTER=yes
BOOTPROTO=none
onBOOT=yes
IPADDR=172.16.96.223
NETMASK=255.255.255.0
GATEWAY=172.16.96.1
DNS1=8.8.8.8
BONDING_OPTS="mode=active-backup million=100 primary=ens33"

네트워크 서비스를 재 실행하고, bonding 상태를 확인 해 본다.

[root@localhost ~]# systemctl restart network

[root@localhost ~]# cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: ens33 (primary_reselect always)
Currently Active Slave: ens33
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens32
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:50:56:9d:da:8e
Slave queue ID: 0

Slave Interface: ens33
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:50:56:9d:34:5a
Slave queue ID: 0

6. 링크를 끊어 active-standby 구성이 제대로 작동하는지 확인한다.

ip 명령어로 active 상태인 ens33의 링크를 다운시킨다.

[root@localhost ~]# ip link set ens33 down

[root@localhost ~]# ip link
1: lo:  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: ens32:  mtu 1500 qdisc pfifo_fast master bond0 state UP mode DEFAULT group default qlen 1000
    link/ether 00:50:56:9d:34:5a brd ff:ff:ff:ff:ff:ff
3: ens33:  mtu 1500 qdisc pfifo_fast master bond0 state DOWN mode DEFAULT group default qlen 1000
    link/ether 00:50:56:9d:34:5a brd ff:ff:ff:ff:ff:ff
4: bond0:  mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 00:50:56:9d:34:5a brd ff:ff:ff:ff:ff:ff

이제, 본딩 상태를 확인해 보면, ens32가 Active 상태로 작동하는 것을 볼 수 있다.

[root@localhost ~]# !cat
cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: ens33 (primary_reselect always)
Currently Active Slave: ens32
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens32
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:50:56:9d:da:8e
Slave queue ID: 0

Slave Interface: ens33
MII Status: down
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:50:56:9d:34:5a
Slave queue ID: 0

다운됐던 링크를 다시 연결하면,

[root@localhost ~]# ip link set ens33 up
[root@localhost ~]# ip link
1: lo:  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: ens32:  mtu 1500 qdisc pfifo_fast master bond0 state UP mode DEFAULT group default qlen 1000
    link/ether 00:50:56:9d:34:5a brd ff:ff:ff:ff:ff:ff
3: ens33:  mtu 1500 qdisc pfifo_fast master bond0 state UP mode DEFAULT group default qlen 1000
    link/ether 00:50:56:9d:34:5a brd ff:ff:ff:ff:ff:ff
4: bond0:  mtu 1500 qdisc noqueue state UP mode DEFAULT group default qlen 1000
    link/ether 00:50:56:9d:34:5a brd ff:ff:ff:ff:ff:ff

원래 설정했던 ens33이 Active 상태인 것을 볼 수 있다.

[root@localhost ~]# !cat
cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: ens33 (primary_reselect always)
Currently Active Slave: ens33
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: ens32
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:50:56:9d:da:8e
Slave queue ID: 0

Slave Interface: ens33
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: 00:50:56:9d:34:5a
Slave queue ID: 0

* 참고문서: https://kudithipudi.org/2010/07/30/how-to-check-status-of-bond-interface-in-linux/

답글 남기기

Your email address will not be published.