>  기사  >  운영 및 유지보수  >  네트워크 인터페이스 구성에 대한 예제 튜토리얼 본딩

네트워크 인터페이스 구성에 대한 예제 튜토리얼 본딩

PHP中文网
PHP中文网원래의
2017-06-21 13:46:032262검색

Bonding

은 고속 네트워크 카드를 외부 서비스용 동일한 IP 주소에 바인딩하여 고가용성 또는 로드 밸런싱을 달성할 수 있는 것입니다. 물론 두 개의 네트워크 카드에 동일한 IP 주소를 직접 설정하는 것은 불가능합니다. 본딩을 통해 가상 네트워크 카드는 외부 연결을 제공하고, 물리적 네트워크 카드는 동일한 MAC 주소로 수정됩니다.

본딩 작업 모드

모드 0(balance-rr)

라운드 로빈 전략: 각 슬레이브 인터페이스에서 처음부터 끝까지 데이터 패킷을 순차적으로 보냅니다. 이 모드는 로드 밸런싱 및 내결함성 기능을 제공합니다.

모드 1(active-backuop)

Active-backup(active-backup) 전략: 바인딩에서는 하나의 슬레이브만 활성화되고 활성 슬레이브 인터페이스가 실패하는 경우에만 다른 슬레이브가 활성화됩니다. 스위치에서의 혼동을 피하기 위해 바인딩된 MAC 주소는 하나의 외부 포트에서만 볼 수 있습니다.

모드 3(브로드캐스트)

브로드캐스트 전략: 모든 슬레이브 인터페이스에서 모든 메시지를 보냅니다. 이 모드는 내결함성을 제공합니다.

두 번째 Bonding 구성

1 Bonding 장치의 구성 파일 생성

[root@CentOS68 ~]# vim /etc/sysconfig/network-scripts/ifcfg-bond0

DEVICE=bond0

BOOTPROTO=none

BONDING_OPTS="miimon=100 mode=0"

IPADDR =200.200 .200.200

PREFIX=24

GATEWAY=200.200.200.1

miimon은 링크 감지를 설정하는 시간(밀리초)입니다. miimon=100인 경우 시스템은 100밀리초마다 링크 한쪽의 연결 상태를 감지합니다. 한 회선을 사용할 수 없으면 다른 회선으로 전환됩니다.

mode는 모드를 지정하는 데 사용됩니다

2 슬레이브 구성 파일 생성

추가할 네트워크 카드의 구성 파일입니다. 여기서는 eth1과 eth2라는 두 개의 네트워크 카드를 사용하여 구성을 수정합니다. 두 개의 네트워크 카드

[root@CentOS68 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth1

DEVICE=eth1

TYPE=Ethernet

BOOTPROTO=none

MASTER=bond0

SLAVE=yes

USERCTL=0

MASTER는 테스트 네트워크 카드가 속한 본드를 지정합니다. SLAVE는 소속을 지정합니다. USERCTL은 사용자에게 제어 권한이 있는지 여부를 지정합니다.

eth2와 eth1의 구성은 비슷합니다

[root@CentOS68 ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth2

DEVICE=eth2

TYPE=Ethernet

BOOTPROTO=none

MASTER=bond0

SLAVE=yes

USERCTL=0

3 네트워크 서비스 다시 시작

[root@CentOS68 ~]# service NetworkManager stop #centos6上不稳定,建议关闭
[root@CentOS68 ~]# service network restart

인터페이스 bond0 종료 중: [ OK ]

인터페이스 eth0 종료 중: [ OK ]

루프백 인터페이스 종료 중: [ OK ]

루프백 인터페이스 불러오는 중: [ OK ]

인터페이스 bond0 불러오는 중 : IP 주소 200.200.200.200이 장치 bond0에 이미 사용 중인지 확인 중...

[ OK ]

인터페이스 eth0 가져오기: IP 주소 192.168.29.68이 장치 eth0에 이미 사용 중인지 확인 중...

[ OK ]

IP 주소와 MAC

[root@CentOS68 ~]# ip a

[…]

7: eth1: f0a1b18d46481de828ed4efbe804fbbf mtu 1500 qdisc pfifo_fast 마스터 bond0 상태 UP qlen 1000

link/ether 00:0c:29:74:74:45 brd ff:ff:ff:ff:ff:ff

9: bond0 : 659f38eec8c9fd78542a327e910ef660 mtu 1500 qdisc noqueue 상태 UP

link/ether 00:0c:29:74:74:45 brd ff:ff:ff:ff:ff:ff

inet 200.200.200.200/24 ​​BRD 200.200 .200.255 스코프 Global Bond0

Inet6 FE80 :: 20C : 29ff : Fe74 : 7445/64 스코프 링크 잠재적 인 Dadfailed

valid_lft Forever Preferred_lft Forever

you는 IP 주소가 취한 것을 알 수 있습니다. 효과와 MAC 주소는 동일합니다.

4 bond0 상태 확인

[root@CentOS68 ~]# cat /proc/net/bonding/bond0

이더넷 채널 본딩 드라이버: v3.7.1(2011년 4월 27일)

본딩 모드: 로드 밸런싱(라운드 로빈)

MII 상태: up

MII 폴링 간격(ms): 100

업 지연(ms): 0

다운 지연(ms): 0

슬레이브 인터페이스: eth1

MII 상태: up

속도: 1000Mbps

이중: 전체

링크 실패 횟수: 0

영구 HW 주소: 00:0c:29:74:74:45

Slave 대기열 ID: 0

Slave 인터페이스: eth2

MII 상태: up

속도: 1000Mbps

Duplex : full

링크 실패 횟수: 0

영구 HW 주소: 00:0c:29:74:74:4f

슬레이브 대기열 ID: 0

좋아요, 모든 일이 잘 진행되고 있습니다

5 본드 삭제

[root@CentOS68 ~]# ifconfig bond0 down

[root@CentOS68 ~]# rmmod bonding

삭제가 성공했는지 확인해보세요

[root@CentOS68 ~]# ifconfig bond0

bond0: error fetching interface information: Device not found

已经找不到bond0,说明删除成功。

详细帮助:/etc/share/doc/kernel-doc-version/Documentation/networking/bonding.txt

 

三 nmcli实现bonding

 1 添加bonding接口

[root@centos7 ~]# nmcli connection add type bond con-name mybond0 ifname bond0 mode active-backup

Connection 'mybond0' (cc101e79-3dcb-49ee-8164-89c9e877c315) successfully added.

2添加从属接口

[root@centos7 ~]# nmcli connection add type bond-slave ifname ens34 master mybond0

Connection 'bond-slave-ens34' (9c8ff11a-72ef-4d63-a950-2ab777d2a1ea) successfully added.

[root@centos7 ~]# nmcli connection add type bond-slave ifname ens38 master mybond0

Connection 'bond-slave-ens38' (c40b3e6f-32f4-4d1a-a323-aed2519cf865) successfully added.

注意:如没有指定从属接口连接名,则该名称是接口名称加类型构成

3 启动从属接口

[root@centos7 ~]# nmcli connection up bond-slave-ens34

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/40)

[root@centos7 ~]# nmcli connection up bond-slave-ens38

Connection successfully activated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/41)

4 启动bonding 绑定

[root@centos7 ~]# nmcli connection up mybond0

Connection successfully activated (master waiting for slaves) (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/48)

5 查看绑定

[root@centos7 ~]# nmcli connection show

NAME UUID TYPE DEVICE

bond-slave-ens34 9c8ff11a-72ef-4d63-a950-2ab777d2a1ea 802-3-ethernet ens34

bond-slave-ens38 c40b3e6f-32f4-4d1a-a323-aed2519cf865 802-3-ethernet ens38

mybond0 cc101e79-3dcb-49ee-8164-89c9e877c315 bond bond0

6 添加IP地址

[root@centos7 ~]# nmcli connection modify mybond0 ipv4.method manual ipv4.addresses 200.1.1.1/24

7 删除bond绑定

(1)关闭bond

[root@centos7 ~]# nmcli connection down mybond0

Connection 'mybond0' successfully deactivated (D-Bus active path: /org/freedesktop/NetworkManager/ActiveConnection/18)

[root@centos7 ~]#

(2)删除bond

[root@centos7 ~]# nmcli connection delete mybond0

Connection 'mybond0' (9ed2f027-bbb1-44d1-87fc-7f7275d7fe70) successfully deleted.

(3)删除从属接口

[root@centos7 ~]# nmcli connection delete bond-slave-ens34

Connection 'bond-slave-ens34' (a46ad620-d4b5-43f9-a73a-447785504a17) successfully deleted.

[root@centos7 ~]# nmcli connection delete bond-slave-ens38

Connection 'bond-slave-ens38' (66b1f44d-ad71-4576-8061-f6cba2b976e8) successfully deleted.

 

好了

위 내용은 네트워크 인터페이스 구성에 대한 예제 튜토리얼 본딩의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.