본문 바로가기
Operating System/Linux

[Linux] ifenslave 명령어 사용법 (Bonding Adaptor Active Change / 본딩 어댑터 전환)

by 근육곰돌이 2020. 1. 31.
728x90

개요

- RHEL / CentOS 에서 Bonding(본딩)은 어뎁터 이중화를 의미합니다. 어뎁터 이중화 구성을 통해 빠른 장애대응 및 네트워크 대역폭 증가를 하는데 유용합니다.  본딩은 기본적으로 여러 모드가 있지만, 오늘은 Active-Slave에서 인터페이스 Down하지 않고, Active Adaptor로 전환하는 방법을 설명하려고 합니다.

(본딩에 대한 설명은 추후 포스팅 하겠습니다.)

 

Bonding 설정 확인 방법

확인 명령어: # cat /proc/net/bonding/bond0
~] cat /proc/net/bonding/bond0
Ethernet Channel Bonding Driver: v3.7.1 (April 27, 2011)

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth4          # 현재 Active 마스터 어뎁터
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth4
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: aa:aa:aa:aa:aa:01
Slave queue ID: 0

Slave Interface: eth5
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: aa:aa:aa:aa:aa:02
Slave queue ID: 0

현재 테스트 단말은 위와 같이 eth4, eth5 => bond0로 구성되어 있으며, eth4가 Active상태 입니다.

본딩 어뎁터를 조절하기 위해서는 ifenslave 명령를 통해서 어뎁터 다운상태 없이 변경이 가능합니다.


 

ifenslave 명령 옵션

  • ifenslave : Attach and detach slave network devices to a bonding device.
  • 명령어: ifenslave {-c|--change-active} <bonding> <interface>
~] ifenslave -h
Usage: ifenslave [-f] <master-if> <slave-if> [<slave-if>...]
       ifenslave -d   <master-if> <slave-if> [<slave-if>...]
       ifenslave -c   <master-if> <slave-if>
       ifenslave --help

       To create a bond device, simply follow these three steps :
       - ensure that the required drivers are properly loaded :
         # modprobe bonding ; modprobe <3c59x|eepro100|pcnet32|tulip|...>
       - assign an IP address to the bond device :
         # ifconfig bond0 <addr> netmask <mask> broadcast <bcast>
       - attach all the interfaces you need to the bond device :
         # ifenslave [{-f|--force}] bond0 eth0 [eth1 [eth2]...]
         If bond0 didn't have a MAC address, it will take eth0's. Then, all
         interfaces attached AFTER this assignment will get the same MAC addr.
         (except for ALB/TLB modes)

       To set the bond device down and automatically release all the slaves :
         # ifconfig bond0 down

       To detach a dead interface without setting the bond device down :
         # ifenslave {-d|--detach} bond0 eth0 [eth1 [eth2]...]

       To change active slave :
         # ifenslave {-c|--change-active} bond0 eth0

       To show master interface info
         # ifenslave bond0

       To show all interfaces info
       # ifenslave {-a|--all-interfaces}

       To be more verbose
       # ifenslave {-v|--verbose} ...

       # ifenslave {-u|--usage}   Show usage
       # ifenslave {-V|--version} Show version
       # ifenslave {-h|--help}    This message

 

 

ifenslave -c 옵션 : Currently Active Slave 상태를 변경하는 방법

ifenslave 명령을 통해 마스터 어뎁터로 변경 가능할 수 있습니다.
   ifenslave -c [본딩 어뎁터] [Active할 slave 어뎁터]
~] ifenslave -c bond0 eth5  # bond0 어뎁터에 eth5로 마스터 어뎁터로 변경


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

Bonding Mode: fault-tolerance (active-backup)
Primary Slave: None
Currently Active Slave: eth5   # 변경 적용 됨
MII Status: up
MII Polling Interval (ms): 100
Up Delay (ms): 0
Down Delay (ms): 0

Slave Interface: eth4
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 1
Permanent HW addr: aa:aa:aa:aa:aa:01
Slave queue ID: 0

Slave Interface: eth5
MII Status: up
Speed: 1000 Mbps
Duplex: full
Link Failure Count: 2
Permanent HW addr: aa:aa:aa:aa:aa:02
Slave queue ID: 0

 

ifenslave -d 옵션 : Slave 인터페이스 삭제 

-d 옵션으로 본딩에 설정된 Slave 어뎁터를 삭제할 수 있습니다.
   ifenslave -d [본딩 어뎁터] [삭제할 slave 어뎁터]
~] ifenslave -d bond0 eth5


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

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

Slave Interface: eth4
MII Status: down
Speed: Unknown
Duplex: Unknown
Link Failure Count: 2
Permanent HW addr: aa:aa:aa:aa:aa:01
Slave queue ID: 0

 

ifenslave 옵션 없음 : Slave 인터페이스 추가 

옵션없이 ifenslave로 본딩에 설정된 Slave 어뎁터를 추가할 수 있습니다.
   ifenslave [본딩 어뎁터] [추가할 slave 어뎁터]
~] ifenslave bond0 eth5


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

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

Slave Interface: eth4
MII Status: down
Speed: Unknown
Duplex: Unknown
Link Failure Count: 2
Permanent HW addr: aa:aa:aa:aa:aa:01
Slave queue ID: 0

Slave Interface: eth5
MII Status: down
Speed: Unknown
Duplex: Unknown
Link Failure Count: 0
Permanent HW addr: aa:aa:aa:aa:aa:02
Slave queue ID: 0

 

 

 

참고 자료

Linux Man page : https://linux.die.net/man/8/ifenslave

 

ifenslave(8) - Linux man page

ifenslave(8) - Linux man page Name ifenslave - Attach and detach slave network devices to a bonding device. Synopsis ifenslave [-acdfhuvV] [--all-interfaces] [--change-active] [--detach] [--force] [--help] [--usage] [--verbose] [--version] master slave ...

linux.die.net

 

 

모두들 장애없는 나날이 함께하길..

 

 

반응형