[Linux] 본딩(bonding) 개념 및 설정하기

2022년 03월 21일 공개

Bonding이란?

여러개의 NIC를 논리적으로 하나로 묶는 것을 뜻합니다.

Bonding 설정 방법

실습 환경

CentOS7 환경 기준입니다.

[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.9.2009 (Core)

실습 예제

2개의 NIC(ens33, ens36)을 Bonding 하겠습니다.

[root@localhost ~]# ifconfig
ens33: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.91.128  netmask 255.255.255.0  broadcast 192.168.91.255
        inet6 fe80::20c:29ff:fe87:b70e  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:87:b7:0e  txqueuelen 1000  (Ethernet)
        RX packets 226  bytes 22388 (21.8 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 172  bytes 26838 (26.2 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens36: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.91.129  netmask 255.255.255.0  broadcast 192.168.91.255
        inet6 fe80::20c:29ff:fe87:b718  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:87:b7:18  txqueuelen 1000  (Ethernet)
        RX packets 9  bytes 1104 (1.0 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 22  bytes 2236 (2.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 10  bytes 1010 (1010.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 1010 (1010.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]#

네트워크 환경 설정 변경

네트워크 환경설정이 있는 디렉토리로 이동합니다.

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

Bonding할 NIC의 네트워크 설정을 변경합니다.

[root@localhost network-scripts]# vi ifcfg-ens33
BOOTPROTO=none
NAME=ens33
DEVICE=ens33
ONBOOT=yes
MASTER=bond0
SLAVE=yes

[root@localhost network-scripts]# vi ifcfg-ens36
BOOTPROTO=dhcp
NAME=ens36
DEVICE=ens36
ONBOOT=yes
MASTER=bond0
SLAVE=yes
[root@localhost network-scripts]#

Bonding 설정 파일을 만들고 구성합니다.

[root@localhost network-scripts]# vi ifcfg-bond0
BOOTPROTO=none
NAME=bond0
DEVICE=bond0
ONBOOT=yes
TYPE=Bond
IPADDR=192.168.91.110
NETMASK=255.255.255.0
GATEWAY=192.168.91.2
BONDING_OPTS=mode=1 miimon=10 primary=ens33 fail_over_mac=1
[root@localhost network-scripts]#

본딩 모듈 적재

Bonding 모듈을 리눅스 커널에 적재합니다.

[root@localhost network-scripts]# modprobe --first-time bonding
[root@localhost network-scripts]#

본딩 설정 적용 및 확인

네트워크 서비스를 재시작합니다.

[root@localhost ~]# systemctl restart network
[root@localhost ~]#

Bonding이 올바르게 구성되었는지 확인합니다.

[root@localhost ~]# ifconfig
bond0: flags=5187<UP,BROADCAST,RUNNING,MASTER,MULTICAST>  mtu 1500
        inet 192.168.91.110  netmask 255.255.255.0  broadcast 192.168.91.255
        inet6 fe80::20c:29ff:fe87:b70e  prefixlen 64  scopeid 0x20<link>
        ether 00:0c:29:87:b7:0e  txqueuelen 1000  (Ethernet)
        RX packets 208  bytes 16990 (16.5 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 140  bytes 14296 (13.9 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens33: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 00:0c:29:87:b7:0e  txqueuelen 1000  (Ethernet)
        RX packets 2757  bytes 224406 (219.1 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 1819  bytes 291970 (285.1 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

ens36: flags=6211<UP,BROADCAST,RUNNING,SLAVE,MULTICAST>  mtu 1500
        ether 00:0c:29:87:b7:18  txqueuelen 1000  (Ethernet)
        RX packets 44  bytes 3768 (3.6 KiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 36  bytes 3666 (3.5 KiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 10  bytes 1010 (1010.0 B)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 10  bytes 1010 (1010.0 B)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

[root@localhost ~]#

Bonding의 세부설정을 확인합니다.

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

Bonding Mode: fault-tolerance (active-backup) (fail_over_mac active)
Primary Slave: ens33 (primary_reselect always)
Currently Active Slave: ens33
MII Status: up
MII Polling Interval (ms): 10
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:0c:29:87:b7:0e
Slave queue ID: 0

Slave Interface: ens36
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 0
Permanent HW addr: 00:0c:29:87:b7:18
Slave queue ID: 0
[root@localhost ~]#

좋은 웹페이지 즐겨찾기