在linux(redhat)下雙網(wǎng)卡負(fù)載均衡(lacp)

第一步:創(chuàng)建一個(gè)ifcfg-bondX

# touch /etc/sysconfig/network-scripts/ifcfg-bond0? 新建一個(gè)bond0配置文件

#? cat /etc/sysconfig/network-scripts/ifcfg-bond0 DEVICE=bond0 BOOTPROTO=static IPADDR=1.1.1.2

NETMASK=255.255.255.0

BROADCAST=1.1.1.255

NETWORK=1.1.1.0

GATEWAY=1.1.1.1

ONBOOT=yes

TYPE=Ethernet

編輯ifcfg-bond0如上

第二步:修改/etc/sysconfig/network-scripts/ifcfg-ethX

這個(gè)實(shí)驗(yàn)中把網(wǎng)卡1和2綁定,修改/etc/sysconfig/network-scripts/ifcfg-ethX相應(yīng)網(wǎng)卡配置如下:

#? cat? /etc/sysconfig/network-scripts/ifcfg-eth1

TYPE=Ethernet

DEVICE=eth1

HWADDR=00:d0:f8:40:f1:a0? 網(wǎng)卡1mac

BOOTPROTO=none

ONBOOT=yes

USERCTL=no

MASTER=bond0

SLAVE=yes

#? cat? /etc/sysconfig/network-scripts/ifcfg-eth2

TYPE=Ethernet DEVICE=eth2

HWADDR=00:d0:f8:00:0c:0c? 網(wǎng)卡2mac

BOOTPROTO=none

ONBOOT=yes

USERCTL=no

MASTER=bond0

SLAVE=yes

第三步:配置/etc/modprobe.conf,添加alias bond0 bonding

#? cat /etc/modprobe.conf alias eth0 e100

alias snd-card-0 snd-intel8x0

options snd-card-0 index=0?

options snd-intel8x0 index=0?

remove snd-intel8x0 { /usr/sbin/alsactl store 0 >/dev/null 2>&1 || : ; }; /sbin/modprobe -r --ignore-remove snd-intel8x0 alias eth1 8139too

options 3c501 irq=3?

alias eth2 tulip

上面是三網(wǎng)卡本身的配置如果要綁定和做lacp只要再加上下面兩條配置

alias bond0 bonding? ? ? ? ? ? ? ? 綁定

options bond0 miimon=100 mode=4? ? mode=4是lacp

第四步:配置/etc/rc.d/rc.local辞做,添加需要綁定的網(wǎng)卡

# cat /etc/rc.d/rc.local?

touch /var/lock/subsys/local? 配置本身就有這條命令

ifenslave bond0 eth1 eth2? ? 這條命令是添加需要綁定的網(wǎng)卡1和2?

到這里就完成bonding的配置了可以查看一下

第五步:重啟網(wǎng)絡(luò)服務(wù)和重啟pc

#service network restart? ? 重啟網(wǎng)絡(luò)服務(wù)

# shutdown -r now? ? ? ? ? ? ? ? ? 重啟pc

重啟后可以查看bonding情況:網(wǎng)卡1和2 都綁定上了,模式為802.3ad

# cat /proc/net/bonding/bond0

Ethernet Channel Bonding Driver: v3.0.3 (March 23, 2006)?

Bonding Mode: IEEE 802.3ad Dynamic link aggregation

Transmit Hash Policy: layer2 (0) MII Status: up

MII Polling Interval (ms): 100 Up Delay (ms): 0 Down Delay (ms): 0?

802.3ad info

LACP rate: slow

Active Aggregator Info:? ? ? ?

? ? ? ? Aggregator ID: 1? ? ? ?

? ? ? ? Number of ports: 2? ? ? ?

? ? ? ? Actor Key: 9? ? ? ?

? ? ? ? Partner Key: 1

? ? ? ? Partner Mac Address: 00:d0:f8:22:33:ba Slave Interface: eth1

MII Status: up

Link Failure Count: 0

Permanent HW addr: 00:d0:f8:40:f1:a0

Aggregator ID: 1

Slave Interface: eth2

MII Status: up

Link Failure Count: 0

Permanent HW addr: 00:d0:f8:00:0c:0c

Aggregator ID: 1

接口配置信息:新增了bond0的配置信息项秉,接口bond0和eth1材泄,eth2,綁定后三個(gè)接口使用的mac都是同一個(gè):00:D0:F8:40:F1:A0 # ifconfig

bond0? ? Link encap:Ethernet? HWaddr 00:D0:F8:40:F1:A0? ? ? ? ? ?

? ? ? ? ? ? ? inet addr:1.1.1.2? Bcast:1.1.1.255? Mask:255.255.255.0

? ? ? ? ? ? ? inet6 addr: fe80::2d0:f8ff:fe40:f1a0/64 Scope:Link

? ? ? ? ? ? ? UP BROADCAST RUNNING MASTER MULTICAST? MTU:1500? Metric:1? ? ? ? ?

? ? ? ? ? ? ? RX packets:128 errors:0 dropped:0 overruns:0 frame:0? ? ? ? ?

? ? ? ? ? ? ? TX packets:259 errors:0 dropped:0 overruns:0 carrier:0? ? ? ? ?

? ? ? ? ? ? ? collisions:0 txqueuelen:0?

? ? ? ? ? ? ? RX bytes:15466 (15.1 KiB)? TX bytes:39679 (38.7 KiB)

eth0? ? ? ? Link encap:Ethernet? HWaddr 00:11:11:EB:71:E2?

? ? ? ? ? ? ? inet addr:192.168.180.8? Bcast:192.168.180.15? Mask:255.255.255.240? ? ? ? ?

? ? ? ? ? ? ? inet6 addr: fe80::211:11ff:feeb:71e2/64 Scope:Link

? ? ? ? ? ? ? UP BROADCAST RUNNING MULTICAST? MTU:1500? Metric:1? ? ? ? ?

? ? ? ? ? ? ? RX packets:311 errors:0 dropped:0 overruns:0 frame:0? ? ? ? ? ?

? ? ? ? ? ? ? TX packets:228 errors:0 dropped:0 overruns:0 carrier:0? ? ? ? ?

? ? ? ? ? ? ? collisions:0 txqueuelen:1000?

? ? ? ? ? ? ? RX bytes:30565 (29.8 KiB)? TX bytes:35958 (35.1 KiB) eth1? ? ?

? ? ? ? ? ? ? Link encap:Ethernet? HWaddr 00:D0:F8:40:F1:A0? ? ? ? ? ?

? ? ? ? ? ? ? inet6 addr: fe80::2d0:f8ff:fe40:f1a0/64 Scope:Link

? ? ? ? ? ? ? UP BROADCAST RUNNING SLAVE MULTICAST? MTU:1500? Metric:1? ? ? ? ?

? ? ? ? ? ? ? RX packets:54 errors:0 dropped:0 overruns:0 frame:0? ? ? ? ? ?

? ? ? ? ? ? ? TX packets:97 errors:0 dropped:0 overruns:0 carrier:0? ? ? ? ?

? ? ? ? ? ? ? collisions:0 txqueuelen:1000?

? ? ? ? ? ? ? RX bytes:6696 (6.5 KiB)? TX bytes:13821 (13.4 KiB)? ? ? ? ?

? ? ? ? ? ? ? Interrupt:209 Base address:0x2e00?

eth2? ? ? ? Link encap:Ethernet? HWaddr 00:D0:F8:40:F1:A0?

? ? ? ? ? ? ? inet6 addr: fe80::2d0:f8ff:fe40:f1a0/64 Scope:Link

? ? ? ? ? ? ? UP BROADCAST RUNNING SLAVE MULTICAST? MTU:1500? Metric:1? ? ? ? ?

? ? ? ? ? ? ? RX packets:74 errors:0 dropped:0 overruns:0 frame:0? ? ? ? ?

? ? ? ? ? ? ? TX packets:162 errors:0 dropped:0 overruns:0 carrier:0? ? ? ? ?

? ? ? ? ? ? ? collisions:0 txqueuelen:1000?

? ? ? ? ? ? ? RX bytes:8770 (8.5 KiB)? TX bytes:25858 (25.2 KiB)? ? ? ? ?

? ? ? ? ? ? ? Interrupt:201 Base address:0x2f00?

lo? ? ? ? ? ? Link encap:Local Loopback?

? ? ? ? ? ? ? inet addr:127.0.0.1? Mask:255.0.0.0? ? ? ? ?

? ? ? ? ? ? ? inet6 addr: ::1/128 Scope:Host

? ? ? ? ? ? ? UP LOOPBACK RUNNING? MTU:16436? Metric:1

? ? ? ? ? ? ? RX packets:6283 errors:0 dropped:0 overruns:0 frame:0? ? ? ? ?

? ? ? ? ? ? ? TX packets:6283 errors:0 dropped:0 overruns:0 carrier:0? ? ? ? ?

? ? ? ? ? ? ? collisions:0 txqueuelen:0?

? ? ? ? ? ? ? RX bytes:9783674 (9.3 MiB)? TX bytes:9783674 (9.3 MiB)

(二)銳捷交換機(jī)配置:

lacp system-priority 100? ? ? ? 全局配置lacp優(yōu)先級(jí)

interface GigabitEthernet 0/23

no switchport

lacp port-priority 100? ? ? ? ? 接口的lacp優(yōu)先級(jí)?

port-group 1 mode active? ? ? 接口下開啟lacp 主動(dòng)模式

interface GigabitEthernet 0/24?

no switchport

lacp port-priority 100?

port-group 1 mode active

interface AggregatePort 1?

no switchport? no ip proxy-arp

ip address 1.1.1.1 255.255.255.0

和linux成功建立lacp后狀態(tài)信息如下:

Show? lacp summary?

System Id:100, 00d0.f822.33ba

Flags:? S - Device is requesting Slow LACPDUs? F - Device is requesting Fast LACPDUs. A - Device is in active mode.? ? ? ? P - Device is in passive mode. Aggregate port 1:

Local information:

LACP port? ? ? Oper? ? Port? ? Port

Port? ? ? Flags? ? State? ? ? Priority? ? ? ? Key? ? Number? State ----------------------------------------------------------------------

Gi0/23? ? SA? ? ? ? bndl? ? ? ? 100? ? ? ? ? ? 0x1? ? 0x17? ? 0x3d

Gi0/24? ? SA? ? ? ? bndl? ? ? ? 100? ? ? ? ? ? 0x1? ? 0x18? ? 0x3d

Partner information:

? ? ? ? ? ? ? ? ? ? LACP port? ? ? ? ? ? ? ? ? Oper? ? Port? ? Port

Port? ? ? Flags? ? Priority? ? ? Dev ID? ? ? Key? ? Number? State ---------------------------------------------------------------------

Gi0/23? ? SA? ? ? ? 255? ? ? 00d0.f840.f1a0? 0x9? ? 0x2? ? ? 0x3d

Gi0/24? ? SA? ? ? ? 255? ? ? 00d0.f840.f1a0? 0x9? ? 0x1? ? ? 0x3d

State表示狀態(tài)信息:bndl表示lacp建立成功烦粒,sup表示不成功夯缺。

建立成功后在交換機(jī)上去ping? linux 1.1.1.2

Ruijie#ping 1.1.1.2

Sending 5, 100-byte ICMP Echoes to 1.1.1.2, timeout is 2 seconds:? < press Ctrl+C to break > !!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms 在linux上ping交換機(jī)

[root@localhost ~]# ping 1.1.1.1

PING 1.1.1.1 (1.1.1.1) 56(84) bytes of data.

64 bytes from 1.1.1.1: icmp_seq=1 ttl=64 time=0.601 ms

64 bytes from 1.1.1.1: icmp_seq=2 ttl=64 time=0.606 ms

64 bytes from 1.1.1.1: icmp_seq=3 ttl=64 time=0.608 ms

64 bytes from 1.1.1.1: icmp_seq=4 ttl=64 time=0.607 ms

--- 1.1.1.1 ping statistics ---

4 packets transmitted, 4 received, 0% packet loss, time 3002ms rtt min/avg/max/mdev = 0.601/0.605/0.608/0.024 ms

[root@localhost ~]#

可以ping通蚤氏,lacp建立正常。

把原傳輸數(shù)據(jù)的那個(gè)網(wǎng)卡shut down異常測(cè)試時(shí)踊兜,需要等到lacp狀態(tài)超時(shí)才能切換到另一條鏈路竿滨。

Ruijie#sh lacp summary?

System Id:100, 00d0.f822.33ba

Flags:? S - Device is requesting Slow LACPDUs? F - Device is requesting Fast LACPDUs. A - Device is in active mode.? ? ? ? P - Device is in passive mode. Aggregate port 1:

Local information:

? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? LACP port? ? ? Oper? ? Port? ? Port

Port? ? ? Flags? ? State? ? ? Priority? ? ? ? Key? ? Number? State ----------------------------------------------------------------------

Gi0/23? ? SA? ? ? ? sups? ? ? ? 100? ? ? ? ? ? 0x1? ? 0x17? ? 0x45

Gi0/24? ? SA? ? ? ? bndl? ? ? ? 100? ? ? ? ? ? 0x1? ? 0x18? ? 0x3d

Partner information:

? ? ? ? ? ? ? ? ? ? LACP port? ? ? ? ? ? ? ? ? Oper? ? Port? ? Port

Port? ? ? Flags? ? Priority? ? ? Dev ID? ? ? Key? ? Number? State ---------------------------------------------------------------------

Gi0/23? ? SP? ? ? ? 0? ? ? ? 0000.0000.0000? 0x0? ? 0x0? ? ? 0x0

Gi0/24? ? SA? ? ? ? 255? ? ? 00d0.f840.f1a0? 0x9? ? 0x1? ? ? 0x3d

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市润文,隨后出現(xiàn)的幾起案子姐呐,更是在濱河造成了極大的恐慌,老刑警劉巖典蝌,帶你破解...
    沈念sama閱讀 212,383評(píng)論 6 493
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件曙砂,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡骏掀,警方通過查閱死者的電腦和手機(jī)鸠澈,發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 90,522評(píng)論 3 385
  • 文/潘曉璐 我一進(jìn)店門柱告,熙熙樓的掌柜王于貴愁眉苦臉地迎上來,“玉大人笑陈,你說我怎么就攤上這事际度。” “怎么了涵妥?”我有些...
    開封第一講書人閱讀 157,852評(píng)論 0 348
  • 文/不壞的土叔 我叫張陵乖菱,是天一觀的道長(zhǎng)。 經(jīng)常有香客問我蓬网,道長(zhǎng)窒所,這世上最難降的妖魔是什么? 我笑而不...
    開封第一講書人閱讀 56,621評(píng)論 1 284
  • 正文 為了忘掉前任帆锋,我火速辦了婚禮吵取,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘锯厢。我一直安慰自己皮官,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 65,741評(píng)論 6 386
  • 文/花漫 我一把揭開白布实辑。 她就那樣靜靜地躺著捺氢,像睡著了一般。 火紅的嫁衣襯著肌膚如雪徙菠。 梳的紋絲不亂的頭發(fā)上讯沈,一...
    開封第一講書人閱讀 49,929評(píng)論 1 290
  • 那天郁岩,我揣著相機(jī)與錄音婿奔,去河邊找鬼。 笑死问慎,一個(gè)胖子當(dāng)著我的面吹牛萍摊,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播如叼,決...
    沈念sama閱讀 39,076評(píng)論 3 410
  • 文/蒼蘭香墨 我猛地睜開眼冰木,長(zhǎng)吁一口氣:“原來是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來了笼恰?” 一聲冷哼從身側(cè)響起踊沸,我...
    開封第一講書人閱讀 37,803評(píng)論 0 268
  • 序言:老撾萬榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎社证,沒想到半個(gè)月后逼龟,有當(dāng)?shù)厝嗽跇淞掷锇l(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 44,265評(píng)論 1 303
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡追葡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 36,582評(píng)論 2 327
  • 正文 我和宋清朗相戀三年腺律,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了奕短。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 38,716評(píng)論 1 341
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡匀钧,死狀恐怖翎碑,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情之斯,我是刑警寧澤日杈,帶...
    沈念sama閱讀 34,395評(píng)論 4 333
  • 正文 年R本政府宣布,位于F島的核電站佑刷,受9級(jí)特大地震影響达椰,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜项乒,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 40,039評(píng)論 3 316
  • 文/蒙蒙 一啰劲、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧檀何,春花似錦蝇裤、人聲如沸。這莊子的主人今日做“春日...
    開封第一講書人閱讀 30,798評(píng)論 0 21
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽。三九已至垛孔,卻和暖如春藕甩,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背周荐。 一陣腳步聲響...
    開封第一講書人閱讀 32,027評(píng)論 1 266
  • 我被黑心中介騙來泰國(guó)打工狭莱, 沒想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人概作。 一個(gè)月前我還...
    沈念sama閱讀 46,488評(píng)論 2 361
  • 正文 我出身青樓腋妙,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親讯榕。 傳聞我的和親對(duì)象是個(gè)殘疾皇子骤素,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 43,612評(píng)論 2 350

推薦閱讀更多精彩內(nèi)容