Hướng dẫn cấu hình etherchannel giữa các Switch với - LACP - PAgP

Thảo luận trong 'Switching' bắt đầu bởi duongvo, 22/8/17.

  1. duongvo

    duongvo Member

    Như các bạn đã biết, Switch Cisco có thể sử dụng các cổng Ethernet, Fast-Ethernet(FE), GigaEthernet(GE), 10 GigaEthernet(10GE) để tăng tốc độ các link. Mỗi lần link bị quá tải ta có thể nâng cấp các đường lên 10 lần, nhưng như vậy sẽ rất tốn kém trong việc mua module gắn vào và dây dẫn, bên cạnh đó, không phải Switch nào cũng có module để bạn gắn cũng như tốn chi phí về mua dây dẫn. Ví dụ bạn đang dùng 1 link FE, giờ quá tải, bạn tăng lên GE, hiệu quả sử dụng rất thấp và không cần thiết.

    Một phương pháp khác phù hợp hơn trong trường hợp này để tăng băng thông các link đó là kếp hợp (“bó”) các link lại. Công nghệ này được gọi là EtherChannel.

    upload_2017-8-22_9-38-51.jpeg

    Công nghệ EtherChannel có thể bó từ 2 đến 8 link FE, GE, 10GE thành 1 link logical. Khi đó, Switch đối xử các port thuộc EtherChannel như 1 port duy nhất.

    Switch hoặc thiết bị ở 2 đầu EtherChannel phải hiểu và sử dụng công nghệ EtherChannel để đảm bảo hoạt động đúng và chống loop. Nếu chỉ có 1 đầu sử dụng EtherChannel, còn đầu bên kia không sử dụng thì có thể gây ra loop.

    Traffic không phải lúc nào cũng được phân bố đồng đều qua các đường link thuộc EtherChannel, mà nó phụ thuộc vào phương pháp load balancing mà Switch sử dụng và mẫu traffic trong mạng.

    Nếu một trong các link thuộc EtherChannel bị down thì traffic sẽ tự động được chuyển sang link khác trong channel chỉ trong vòng vài miliseconds (theo kết quả mình test trên thiết bị thật thì thậm chí không bị rớt 1 gói tin nào). Khi link up trở lại thì traffic được phân bố lại như cũ.

    Kết hợp các port với EtherChannel

    EtherChannel có thể kết hợp các physical ports chỉ khi:
    – Cùng tốc độ (speed)
    – Cùng loại (full-duplex, half-duplex)
    – Nếu port Layer 2 thì cùng port access, phải access cùng VLAN còn port trunk thì phải cùng native VLAN và allowed VLAN. Hoặc cùng là port Layer 3 (routed port).

    Phân phối traffic trong EtherChannel - Load Balancing

    Switch lựa chọn đường link nào trong EtherChannel để forward frame dựa vào kết quả của thuật toán hash. Thuật toán có thể sử dụng source IP, destination IP (hoặc cả hai), source MAC, destination MAC (hoặc cả hai), TCP/UDP port number. Thuật toán hash sẽ cho ra một chuỗi số nhị phân (0 & 1).

    Nếu chỉ có source hoặc destination được hash (IP, MAC, port number) thì Switch sẽ sử dụng một hoặc nhiều low-oder bits của giá trị hash để làm index lựa chọn link trong EtherChannel. Nếu cả source và destination được hash, Switch sẽ thực hiện phép toán exclusive-OR (XOR) trên một hoặc nhiều low-order bits để làm index.

    Bảng phân loại EtherChannel Load Balancing

    upload_2017-8-22_9-38-59.jpeg

    Tùy thuộc vào mô hình mạng mà ta cấu hình load balancing sử dựng các link physical nhiều nhất có thể. Ví dụ ở port Layer 3 thì không nên dùng MAC address để forward, vì khi đó, địa chỉ MAC luôn không đổi. Cách tốt nhất là sử dụng port để load balancing, vì src-port là random nên tận dụng được tối đa các đường có thể.

    Thuật toán hash cho kết quả có giá trị từ 0-7 (000-111). Kết quả hash có giá trị nào thì port tương ứng sẽ được chọn. Đối với 8 ports thì cần 3 bits, 4 port thì cần 2 bits…

    Bảng giá trị Load Balancing:
    upload_2017-8-22_9-39-7.jpeg

    Note: Tương ứng với số port mà thuật toán hash chỉ cần tính toán với số bit tương ứng.
    Có 2 port: Cần 1 bit (2 giá trị 0,1) để chọn đường đi. Ví dụ kết quả 0 đi link 0, kết quả 1 đi link 1.
    Có 3-4 port: Cần 2 bit (4 giá trị 00,01,10,11).
    Có 5-8 port: Cần 3 bit (8 giá trị 000-111).

    Switch đối xử EtherChannel như là một đường link duy nhất, do đó khi nó nhận frame từ bất cứ một link nào thuộc EtherChannel thì nó sẽ không forward ngược ra các link còn lại trong EtherChannel (để chống loop).
    Spanning Tree cũng xem EtherChannel (port-channel) là một link duy nhất và đại diện cho tất cả các link thuộc EtherChannel. Khi một trong các link thuộc EtherChannel bị down thì EtherChannel vẫn up, do đó Spanning Tree không cần phải hội tụ.
    Trừ khi tất cả các link thuộc EtherChanel bị down (khiến cho EtherChannel cũng down theo) thì Spanning Tree mới phải hội tụ. Do đó EtherChannel giúp giảm việc tính toán lại Spanning Tree của Switch.
    Khi Switch nhận được broadcast hoặc multicast frames thì nó cũng thực hiện load balancing tương tự như các frame khác: dùng địa chỉ broadcast hoặc multicast cho vào thuật toán hash để tính ra kết quả và lựa chọn link.

    2. Các phương thức thương lượng trong EtherChannel

    Có hai giao thức dùng để thương lượng trong EtherChannel là PAgP (Port Aggregation Protocol – độc quyền của Cisco) và LACP (Link Aggregation Control Protocol – giao thức chuẩn hóa IEEE 802.3ad).

    upload_2017-8-22_9-39-18.jpeg

    Ở mode On: Switch không cần thương lượng mà tự động gán port vào Channel.
    Ở mode Auto (PAgP)/Passive (LACP): chờ thương lượng để lên EtherChannel – bị động.
    Ở mode Desirable (PAgP)/Active (LACP): Chủ động thương lượng Switch bên kia để lên EtherChannel

    upload_2017-8-22_9-39-25.jpeg

    Những trường hợp trên đều không thể thương lượng thành EtherChannel. Những trường hợp còn lại đều lên EtherChannel (tất nhiên phải cùng protocol PAgP hoặc LACP).

    Note: Điểm khác biệt cơ bản để ta chọn PAgP hay LACP là:

    PAgP: cho phép định nghĩa EtherChannel với tối đa 8 ports.
    LACP: cho phép định nghĩa EtherChannel với tối đa là 16 ports, khi đó 8 ports sẽ ở trạng thái active, 8 ports ở trạng thái Hot-Standby. Khi 1 port ở trạng thái active bị down, Switch sẽ chọn 1 port từ Hot-Standby -> Active

    3. Cấu hình EtherChannel

    Nếu PAgP hoặc LACP được cấu hình ở mode on thì Switch sẽ tự đưa các ports vào EtherChannel mà không thương lượng với neighbor, nghĩa là không có bất kỳ gói tin PAgP hoặc LACP nào được trao đổi. Điều này có thể dẫn đến trường hợp ở một đầu thì các ports được đưa vào EtherChannel, trong khi đầu bên kia thì không (nghĩa là một bên thì xem đó là một logical link, trong khi phía bên kia thì vẫn xem là nhiều physical links), và có thể gây ra loop. Vì vậy, đối với EtherChannel ta không nên cấu hình mode on, mà nên sử dụng giao thức để thương lượng.
    Khi các ports được cấu hình là thành viên của EtherChannel thì Switch sẽ tự động tạo ra một logical port-channel interface. Interface này đại diện cho toàn bộ channel.
    Khi cấu hình EtherChannel thì ta không cần thiết phải chỉ định giao thức thương lượng là PAgP hay LACP, mà chỉ cần cấu hình các mode tương ứng với giao thức đó là Switch tự động biết sử dụng giao thức nào.


    Cấu hình PAgP


    Switch(config)# interface type mod/num
    Switch(config-if)# channel-protocol pagp
    Switch(config-if)# channel-group number mode {on | {{auto | desirable} [non-silent]}}


    Ví dụ:

    Switch(config)# interface f0/1 - 4
    Switch(config-if)# channel-protocol pagp
    Switch(config-if)# channel-group 1 mode desirable


    Cấu hình LACP

    Switch(config)# lacp system-priority priority
    Switch(config)# interface type mod/num
    Switch(config-if)# channel-protocol lacp
    Switch(config-if)# channel-group number mode {on | passive | active}
    Switch(config-if)# lacp port-priority priority


    Giải thích:

    upload_2017-8-22_9-39-36.jpeg
    System-id gồm LACP system-priority có giá trị từ 1 – 65535 (mặc định là 32768) và địa chỉ MAC, switch nào có system-id nhỏ hơn sẽ có quyền lựa chọn active port (switch còn lại nghe theo).

    upload_2017-8-22_9-39-43.jpeg
    Port-id gồm LACP port-priority có giá trị từ 1 – 65535 (mặc định là 32768) và port number, Port nào có port-id nhỏ hơn sẽ trở thành Active Port

    Ví dụ:

    Switch1(config)# lacp system-priority 100
    Switch1(config)# interface range gig 2/1 – 4 , gig 3/1 – 4
    Switch1(config-if)# channel-protocol lacp
    Switch1(config-if)# channel-group 1 mode active
    Switch1(config-if)# lacp port-priority 100
    Switch1(config-if)# exit
    Switch1(config)# interface range gig 2/5 – 8 , gig 3/5 – 8
    Switch1(config-if)# channel-protocol lacp
    Switch1(config-if)# channel-group 1 mode active


    Switch1 cấu hình lacp system-priority 100, nếu Switch 2 cấu hình mặc định (không cấu hình câu lệnh này -> sys-priority=32768) thì Switch1 sẽ có quyền lựa chọn port nào Active, port nào Hot-Standby.
    Port gig 2/1 – 4 , gig 3/1 – 4 có port-priority là 100 nhỏ hơn port gig 2/5 – 8 , gig 3/5 – 8 nên gig 2/1 – 4 , gig 3/1 – 4 là Active port, port gig 2/5 – 8 , gig 3/5 – 8 là Hot-Standby Port

    Cấu hình Load Balancing:

    Switch(config)# port-channel load-balance src-dst-port

    4. Configure Etherchannel

    Dưới đây là cấu hình tiến hành đưa 2 port f0/1 và f0/2 vào port channel mode LACP sau đó là cấu hình trunk.

    Switch(config)#int range f0/1 – 2
    Switch(config-if-range)#channel-group 1 mode ?
    active Enable LACP unconditionally
    auto Enable PAgP only if a PAgP device is detected
    desirable Enable PAgP unconditionally
    on Enable Etherchannel only
    passive Enable LACP only if a LACP device is detected

    Switch(config-if-range)#channel-group 1 mode active
    Switch(config-if-range)#exit
    Switch(config)# interface port-channel 1
    Switch(config-if)#switchport mode trunk

    Cấu hình trên là ở Switch Cisco, các bạn nếu cấu hình ở Switch hãng khác thì cần thêm câu lệnh

    # switchport trunk encapsulation dot1q

    Để kiểm tra các bạn có thể sử dụng câu lệnh show etherchannel summary

    Switch#show etherchannel summary
    Flags: D – down P – in port-channel
    I – stand-alone s – suspended
    H – Hot-standby (LACP only)
    R – Layer3 S – Layer2
    U – in use f – failed to allocate aggregator
    u – unsuitable for bundling
    w – waiting to be aggregated
    d – default port
    Number of channel-groups in use: 1
    Number of aggregators: 1Group Port-channel Protocol Ports
    ——+————-+———–+———————————————-
    1 Po1(SU) LACP Fa0/1(P) Fa0/2(P)


    Khi show etherchannel summary mà thấy chữ P (in port-channel) tức là bạn đã cấu hình thành công, còn D (down) thì có thể bạn cấu hình chưa đúng, hoặc xem lại dây kết nối.

    Chúc các bạn thành công!
     
  2. vuthang

    vuthang Member

    Giới thiệu về EtherChannel và cách cấu hình

    Tại sao phải EtherChannel?

    Do các đường trunk giữa các Switch thường có băng thông không đủ lớn đo đó không đáp ứng được nhu cầu ở bên trong mạng, dể gây ra nghẽn do đó mà người ta sử dụng Etherchannel để ghép nhiều đường lại thành một đường để tăng dung lượng. Thứ hai là đối với các Server có nhu cầu truy nhập cao do đó cũng cần một lượng băng thông lớn, để tránh nghẽn ta cũng sử dụng Etherchannel

    Nguyên tắc phân phối tải qua Etherchannel

    Việc phân phối tải qua các đường của một bundle (Etherchannel) được thực hiện theo thuật toán hashing: Thuật toán này có thể sử dụng: Địa chỉ IP nguồn, đích; Hoặc địa chỉ MAC nguồn, đích, hoặc có thể sử dụng TCP/UDP port.
    - Nếu chỉ sử dụng một địa chỉ hay một port thì việc truyền tải qua port này hay port khác được thực hiện dựa vào các bit cuối cùng, và phụ thuộc vào số port của Etherchannel
    - Nếu sử dụng cả đích, và nguồn thì thuật toán này được thực hiện nhờ phép toán XOR các bit cuối của địa chỉ.

    Các lệnh cơ bản để cấu hình Etherchannel

    1. Cấu hình PAGP Etherchannel:

    Switch(config-if)# channel-protocol pagp
    Switch(config-if)# channel-group number mode {on | auto | desirable }


    Các mode:

    + ON mode: ở mode này thì Switch tự động enable Etherchannel tuy nhiên nó lại không gởi hay nhận bất kỳ gói PAGP nào, do đó mà phải cấu hình on mode ở hai đầu
    + Auto mode: Nó sẻ tự động enable Ethechannel nếu nó nhận được PAGP packet.
    + Desirable: Nó sẻ tự động cố gắng yêu cầu đầu kia enable Ethechannel.

    2. Cấu hình LACP Etherchannel:
    Switch(config)# lacp system-priority priority
    Switch(config-if)# channel-protocol lacp
    Switch(config-if)# channel-group number mode {on | passive | active}
    Switch(config-if)# lacp port-priority priority


    Giải thích:
    + Lệnh đầu tiên để xác định system priority để xác định Switch nào làm Switch điều khiển Ethechannel, hoặc nếu Priority bằng nhau thì Switch nào có điạ chỉ Mac nhỏ hơn sẽ được chọn
    + Ta còn xác định priority của port để xác định xem port nào là active và port nào ở trạng thái standby. Port có priority nhỏ sẽ active và, lớn sẽ ở trạng thái standby
    + Các mode trong lệnh channel-group On, Passive, active tuần tự tương tự như On, Auto , Desirable trong PAGP

    Cấu hình cho sơ đồ thực tế
    upload_2017-10-24_10-38-31.jpeg
    1. Giải thích sơ bộ về sơ đồ trên

    Ở sơ đồ này ta thực hiện Etherchannel giữa Core Switch C3650 va Access Switch C2960X. Ở đây thì ta sử dụng 4 port fastethernet 0/1 – 0/4 làm etherchannel. Ta sẽ cấu hình etherchannel dùng cả PAGP, và LACP.

    2. Cấu hình PAGP

    Show run để kiểm tra cấu hình

    Access# show run

    Building configuration...
    Current configuration : 2238 bytes
    version 12.1
    no service pad
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    hostname Access
    enable password cisco
    ip subnet-zero
    no ip domain-lookup
    spanning-tree mode pvst
    spanning-tree extend system-id
    !
    interface FastEthernet0/1
    switchport trunk encapsulation isl
    switchport mode trunk
    no ip address
    duplex full
    speed 100
    channel-group 1 mode desirable
    !
    interface FastEthernet0/2
    switchport trunk encapsulation isl
    switchport mode trunk
    no ip address
    duplex full
    speed 100
    channel-group 1 mode desirable
    !
    interface FastEthernet0/3
    switchport trunk encapsulation isl
    switchport mode trunk
    no ip address
    duplex full
    speed 100
    channel-group 1 mode desirable
    !
    interface FastEthernet0/4
    switchport trunk encapsulation isl
    switchport mode trunk
    no ip address
    duplex full
    speed 100
    channel-group 1 mode desirable
    !
    interface FastEthernet0/5
    switchport access vlan 2
    switchport mode access
    no ip address
    !
    interface FastEthernet0/6
    no ip address
    !
    ............................................
    !
    interface FastEthernet0/24
    no ip address
    !
    interface GigabitEthernet0/1
    no ip address
    !
    interface GigabitEthernet0/2
    no ip address
    !
    interface Vlan1
    ip address 192.168.5.2 255.255.255.0
    define interface-range thegioimang.vn FastEthernet0/1 - 4
    !
    ip classless
    ip http server
    !
    line con 0
    logging synchronous
    line vty 0 4
    no login
    line vty 5 15
    login
    !
    end


    Core# show run

    Building configuration...

    Current configuration : 3016 bytes
    !
    version 12.1
    no service pad
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname Core
    enable password cisco
    !
    ip subnet-zero
    ip routing
    !
    no ip domain-lookup
    !
    spanning-tree mode pvst
    spanning-tree extend system-id
    !
    interface Port-channel1
    switchport trunk encapsulation isl
    switchport mode dynamic desirable
    !
    interface FastEthernet0/1
    switchport trunk encapsulation isl
    switchport mode dynamic desirable
    duplex full
    speed 100
    channel-group 1 mode desirable
    !
    interface FastEthernet0/2
    switchport trunk encapsulation isl
    switchport mode dynamic desirable
    duplex full
    speed 100
    channel-group 1 mode desirable
    !
    interface FastEthernet0/3
    switchport trunk encapsulation isl
    switchport mode dynamic desirable
    duplex full
    speed 100
    channel-group 1 mode desirable
    !
    interface FastEthernet0/4
    switchport trunk encapsulation isl
    switchport mode dynamic desirable
    duplex full
    speed 100
    channel-group 1 mode desirable
    !
    interface FastEthernet0/5
    no switchport
    ip address 192.168.3.2 255.255.255.0
    duplex half
    speed 100
    !
    interface FastEthernet0/6
    switchport mode dynamic desirable
    !
    ...................................................
    !
    interface FastEthernet0/24
    switchport mode dynamic desirable
    !
    interface GigabitEthernet0/1
    switchport mode dynamic desirable
    !
    interface GigabitEthernet0/2
    switchport mode dynamic desirable
    !
    interface Vlan1
    ip address 192.168.5.1 255.255.255.0
    !
    interface Vlan2
    ip address 192.168.2.1 255.255.255.0
    define interface-range thegioimang.vn FastEthernet0/1 - 4
    !
    router ospf 1
    log-adjacency-changes
    passive-interface Port-channel1
    network 192.168.2.0 0.0.0.255 area 0
    network 192.168.3.0 0.0.0.255 area 0
    !
    ip classless
    ip http server
    line con 0
    logging synchronous
    line vty 0 4
    password cisco
    no login
    line vty 5 15
    login
    !
    monitor session 1 source interface Po1
    monitor session 1 destination interface Fa0/10
    end


    3. Kiểm tra:


    - Show etherchannel port để xem trạng thái của tất cả các port trong group

    Core# show etherchannel port

    Channel-group listing:
    -----------------------
    Group: 1
    ----------
    Ports in the group:
    -------------------
    Port: Fa0/1
    ------------
    Port state = Up Mstr In-Bndl
    Channel group = 1 Mode = Desirable-Sl Gcchange = 0
    Port-channel = Po1 GC = 0x00010001 Pseudo port-channel = Po1
    Port index = 0 Load = 0x00 Protocol = PAgP
    Flags: S - Device is sending Slow hello. C - Device is in Consistent state.
    A - Device is in Auto mode. P - Device learns on physical port.
    d - PAgP is down.
    Timers: H - Hello timer is running. Q - Quit timer is running.
    S - Switching timer is running. I - Interface timer is running.
    Local information:
    Hello Partner PAgP Learning Group
    Port Flags State Timers Interval Count Priority Method Ifindex
    Fa0/1 SC U6/S7 H 30s 1 128 Any 29
    Partner's information:
    Partner Partner Partner Partner Group
    Port Name Device ID Port Age Flags Cap.
    Fa0/1 Access 000d.bc33.2b00 Fa0/1 0s SC 10001
    Age of the port in the current state: 00d:00h:06m:04s


    Port: Fa0/2
    ------------
    Port state = Up Mstr In-Bndl
    Channel group = 1 Mode = Desirable-Sl Gcchange = 0
    Port-channel = Po1 GC = 0x00010001 Pseudo port-channel = Po1
    Port index = 0 Load = 0x00 Protocol = PAgP
    Flags: S - Device is sending Slow hello. C - Device is in Consistent state.
    A - Device is in Auto mode. P - Device learns on physical port.
    d - PAgP is down.
    Timers: H - Hello timer is running. Q - Quit timer is running.
    S - Switching timer is running. I - Interface timer is running.
    Local information:
    Hello Partner PAgP Learning Group
    Port Flags State Timers Interval Count Priority Method Ifindex
    Fa0/2 SC U6/S7 H 30s 1 128 Any 29
    Partner's information:
    Partner Partner Partner Partner Group
    Port Name Device ID Port Age Flags Cap.
    Fa0/2 Access 000d.bc33.2b00 Fa0/2 2s SC 10001
    Age of the port in the current state: 00d:00h:32m:20s


    Port: Fa0/3
    ------------
    Port state = Up Mstr In-Bndl
    Channel group = 1 Mode = Desirable-Sl Gcchange = 0
    Port-channel = Po1 GC = 0x00010001 Pseudo port-channel = Po1
    Port index = 0 Load = 0x00 Protocol = PAgP
    Flags: S - Device is sending Slow hello. C - Device is in Consistent state.
    A - Device is in Auto mode. P - Device learns on physical port.
    d - PAgP is down.
    Timers: H - Hello timer is running. Q - Quit timer is running.
    S - Switching timer is running. I - Interface timer is running.
    Local information:
    Hello Partner PAgP Learning Group
    Port Flags State Timers Interval Count Priority Method Ifindex
    Fa0/3 SC U6/S7 H 30s 1 128 Any 29
    Partner's information:
    Partner Partner Partner Partner Group
    Port Name Device ID Port Age Flags Cap.
    Fa0/3 Access 000d.bc33.2b00 Fa0/3 14s SC 10001
    Age of the port in the current state: 00d:00h:04m:19s


    Channel group = 1 Mode = Desirable-Sl Gcchange = 0
    Port-channel = Po1 GC = 0x00010001 Pseudo port-channel = Po1
    Port index = 0 Load = 0x00 Protocol = PAgP
    Flags: S - Device is sending Slow hello. C - Device is in Consistent state.
    A - Device is in Auto mode. P - Device learns on physical port.
    d - PAgP is down.
    Timers: H - Hello timer is running. Q - Quit timer is running.
    S - Switching timer is running. I - Interface timer is running.
    Local information:
    Hello Partner PAgP Learning Group
    Port Flags State Timers Interval Count Priority Method Ifindex
    Fa0/4 SC U6/S7 H 30s 1 128 Any 29
    Partner's information:
    Partner Partner Partner Partner Group
    Port Name Device ID Port Age Flags Cap.
    Fa0/4 Access 000d.bc33.2b00 Fa0/4 14s SC 10001
    Age of the port in the current state: 00d:00h:48m:29s


    - Ta có thể sử dụng lênh show etherchannel summary để dể xem xét hơn.

    Core# show etherchannel summary

    Flags: D - down P - in port-channel
    I - stand-alone s - suspended
    H - Hot-standby (LACP only)
    R - Layer3 S - Layer2
    u - unsuitable for bundling
    U - in use f - failed to allocate aggregator
    d - default port
    Number of channel-groups in use: 1
    Number of aggregators: 1
    Group Port-channel Protocol Ports
    ------+-------------+-----------+-----------------------------------------------
    1 Po1(SU) PAgP Fa0/1(P) Fa0/2(P) Fa0/3(P) Fa0/4(P)

    4. Cấu hình LACP

    Đối với cấu hình này thì ta cũng sử dụng 4 interface fa0/1- fa0/4 làm etherchannel.

    - Show run để kiểm tra cấu hình

    Core#
    show run

    Building configuration...
    Current configuration : 2142 bytes
    !
    version 12.1
    no service pad
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname Core
    !
    enable password cisco
    !
    ip subnet-zero
    !
    lacp system-priority 100
    !
    interface Port-channel1
    no ip address
    !
    interface FastEthernet0/1
    switchport trunk encapsulation dot1q
    switchport mode trunk
    no ip address
    channel-group 1 mode active
    channel-protocol lacp
    !
    interface FastEthernet0/2
    switchport trunk encapsulation dot1q
    switchport mode trunk
    no ip address
    channel-group 1 mode active
    channel-protocol lacp
    !
    interface FastEthernet0/3
    switchport trunk encapsulation dot1q
    switchport mode trunk
    no ip address
    channel-group 1 mode active
    channel-protocol lacp
    !
    interface FastEthernet0/4
    switchport trunk encapsulation dot1q
    switchport mode trunk
    no ip address
    channel-group 1 mode active
    channel-protocol lacp
    !
    interface FastEthernet0/5
    switchport mode access
    no ip address
    spanning-tree portfast
    !
    interface FastEthernet0/6
    no ip address
    !
    ............................................
    !
    interface FastEthernet0/24
    no ip address
    !
    interface GigabitEthernet0/1
    no ip address
    !
    interface GigabitEthernet0/2
    no ip address
    !
    interface Vlan1
    ip address 192.168.5.1 255.255.255.0
    define interface-range cuong FastEthernet0/1 - 4
    !
    ip classless
    ip http server
    !
    line con 0
    line vty 0 4
    no login
    line vty 5 15
    login
    monitor session 1 source interface Po1
    monitor session 1 destination interface Fa0/5
    end


    Access# show run

    Building configuration...

    Current configuration : 2693 bytes
    !
    version 12.1
    no service pad
    service timestamps debug uptime
    service timestamps log uptime
    no service password-encryption
    !
    hostname Access
    !
    enable password cisco
    !
    ip subnet-zero
    !
    no ip domain-lookup
    !
    spanning-tree mode pvst
    spanning-tree extend system-id
    lacp system-priority 10
    !
    interface Port-channel1
    switchport trunk encapsulation dot1q
    switchport mode trunk
    !
    interface FastEthernet0/1
    switchport trunk encapsulation dot1q
    switchport mode trunk
    duplex full
    speed 100
    channel-group 1 mode active
    channel-protocol lacp
    !
    interface FastEthernet0/2
    switchport trunk encapsulation dot1q
    switchport mode trunk
    duplex full
    speed 100
    channel-group 1 mode active
    channel-protocol lacp
    !
    interface FastEthernet0/3
    switchport trunk encapsulation dot1q
    switchport mode trunk
    duplex full
    speed 100
    channel-group 1 mode active
    channel-protocol lacp
    !
    interface FastEthernet0/4
    switchport trunk encapsulation dot1q
    switchport mode trunk
    duplex full
    speed 100
    channel-group 1 mode active
    channel-protocol lacp
    !
    interface FastEthernet0/5
    switchport mode access
    spanning-tree portfast
    !
    interface FastEthernet0/6
    switchport mode dynamic desirable
    !
    ...................................................
    !
    interface FastEthernet0/24
    switchport mode dynamic desirable
    !
    interface GigabitEthernet0/1
    switchport mode dynamic desirable
    !
    interface GigabitEthernet0/2
    switchport mode dynamic desirable
    !
    interface Vlan1
    ip address 192.168.5.2 255.255.255.0
    define interface-range cuong FastEthernet0/1 - 4
    !
    ip classless
    ip http server
    line con 0
    logging synchronous
    line vty 0 4
    no login
    line vty 5 15
    login
    !
    end


    5. Kiểm tra

    - Lệnh show lacp neighbor:

    Core# show lacp neighbor

    Flags: S - Device is sending Slow LACPDUs F - Device is sending Fast LACPDUs
    A - Device is in Active mode P - Device is in Passive mode
    Channel group 1 neighbors
    Partner's information:
    Partner Partner Partner
    Port System ID Port Number Age Flags
    Fa0/1 00010,000d.299a.7e00 0x0 29s SA
    LACP Partner Partner Partner
    Port Priority Oper Key Port State
    32768 0x1 0x3D
    Partner's information:
    Partner Partner Partner
    Port System ID Port Number Age Flags
    Fa0/2 00010,000d.299a.7e00 0x1 11s SA
    LACP Partner Partner Partner
    Port Priority Oper Key Port State
    32768 0x1 0x3D
    Partner's information:
    Partner Partner Partner
    Port System ID Port Number Age Flags
    Fa0/3 00010,000d.299a.7e00 0x2 27s SA
    LACP Partner Partner Partner
    Port Priority Oper Key Port State
    32768 0x1 0x3D
    Partner's information:
    Partner Partner Partner
    Port System ID Port Number Age Flags
    Fa0/4 00010,000d.299a.7e00 0x3 12s SA
    LACP Partner Partner Partner
    Port Priority Oper Key Port State
    32768 0x1 0x3D


    - Kiểm tra trạng thái các port bằng show lacp internal hoặc show etherchannel detail

    Access#
    show lacp internal
    Flags: S - Device is sending Slow LACPDUs F - Device is sending Fast LACPDUs
    A - Device is in Active mode P - Device is in Passive mode
    Channel group 1
    LACP port Admin Oper Port Port
    Port Flags State Priority Key Key Number State
    Fa0/1 SA bndl 32768 0x1 0x1 0x0 0x3D
    Fa0/2 SA bndl 32768 0x1 0x1 0x1 0x3D
    Fa0/3 SA bndl 32768 0x1 0x1 0x2 0x3D
    Fa0/4 SA bndl 32768 0x1 0x1 0x3 0x3D

    Chúc các bạn thành công!
     
  3. tringuyen

    tringuyen Member

    Hướng dẫn cấu hình Cisco Switch EtherChannel với - LACP - PAgP

    Trong bài viết này, chúng tôi sẽ mô tả cách cấu hình cả LACP và PAgP EtherChannel trên các thiết bị chuyển mạch của Cisco.

    EtherChannel là một công nghệ Tổng hợp Liên kết, theo đó hai thiết bị chuyển mạch được kết nối với nhau với nhiều giao diện được kết hợp với nhau để tạo thành một giao diện logic duy nhất (“Port-Channe”) do đó làm tăng băng thông giữa các thiết bị chuyển mạch.

    Khi nào nên sử dụng EtherChannel

    Sơ đồ dưới đây cho thấy một tình huống có thể xảy ra để sử dụng Etherchannels:
    [​IMG]
    Giả sử chúng ta có một Switch Phòng dữ liệu cung cấp quyền truy cập vào các máy chủ. Switch này được kết nối với Switch Phân phối tổng hợp lưu lượng từ một số Switch truy cập của người dùng.

    Nếu ta kết nối hai thiết bị chuyển mạch với nhau bằng một giao diện 1Gbps, thì nó có thể là một nút cổ chai đối với lưu lượng truy cập từ người dùng đến máy chủ (đặc biệt là đối với các ứng dụng có dung lượng lớn).

    Với Etherchannel, chúng ta có thể gộp tối đa 8 giao diện lại với nhau để tạo thành một liên kết logic duy nhất (Etherchannel) và lưu lượng được cân bằng tải giữa tất cả các giao diện.

    Trong ví dụ ở trên, các giao diện 4x1Gbps được nhóm lại với nhau, do đó tạo thành một đường ống 4Gbps từ người dùng đến máy chủ. Điều này làm tăng băng thông nhưng cũng tăng cường dự phòng giữa các thiết bị chuyển mạch.

    Ghi chú:

    Nếu bạn kết nối các giao diện như hình trên mà không định cấu hình EtherChannel, thì vòng lặp Spanning-tree sẽ được phát hiện và 3 trong số 4 liên kết sẽ bị chặn bởi Spanning-Tree Protocol. Bằng cách cấu hình Etherchannel, nhóm được coi là một giao diện logic duy nhất và không có vòng lặp.

    Giao thức EtherChannel

    Có hai giao thức Etherchannel. Các giao thức này quản lý việc thiết lập kênh giữa các thiết bị chuyển mạch:

    1) Link Aggregation Control Protocol – LACP (IEEE standard protocol)
    2) Port Aggregation Protocol – PAgP (Cisco Proprietary)

    Cái đầu tiên (LACP) được ưa thích hơn vì nó được nhiều nhà cung cấp hỗ trợ và đó là một giao thức tốt hơn.

    Chế độ EtherChannel

    Mỗi giao thức được liệt kê ở trên có ba chế độ hoạt động quyết định liệu Switch sẽ chủ động tìm cách tạo liên kết Etherchannel hay sẽ đợi đầu kia hình thành liên kết.

    LACP Modes: ON, ACTIVE, PASSIVE
    PAgP Modes: ON, DESIRABLE, AUTO

    Hãy xem một bảng hữu ích bên dưới cho biết liệu Etherchannel sẽ thiết lập hay không tùy thuộc vào từng chế độ chuyển đổi:

    Cấu hình EtherChannel

    Giả sử các giao diện vật lý Gi0 / 0 lên đến Gi0 / 3 sẽ được sử dụng để tạo thành Etherchannel. Hơn nữa, tốt hơn hết là bạn nên định cấu hình giao diện logic Port là Trunk để cho phép các VLAN truyền qua lại giữa các thiết bị chuyển mạch switches.
    [​IMG]
    Cấu hình LACP

    Switch đầu tiên SW1 sẽ là Chế độ chủ động(active) và SW2 sẽ ở Chế độ thụ động (passive).

    SW1(config)# interface range Gi0/0 -3 <– Chọn 4 interfaces
    SW1(config-if-range)# channel-protocol lacp <– Chọn giao thức LACP
    SW1(config-if-range)# channel-group 1 mode active <– Thiết lập mode active

    SW1(config-if-range)# exit

    SW1(config)# interface port-channel 1 <– Cấu hình cổng logic là trunk
    SW1(config-if)#switchport trunk encapsulation dot1q
    SW1(config-if)#switchport mode trunk


    SW2(config)# interface range Gi0/0 – 3 <– Select the 4 interfaces
    SW2(config-if-range)# channel-protocol lacp <– Set protocol to LACP
    SW2(config-if-range)# channel-group 1 mode passive <– Set mode to passive

    SW2(config-if-range)# exit

    SW2(config)# interface port-channel 1 <– Configure the logical port as trunk
    SW2(config-if)#switchport trunk encapsulation dot1q
    SW2(config-if)#switchport mode trunk


    [​IMG]
    Cấu hình PAgP

    Switch đầu tiên SW1 sẽ ở Chế độ mong muốn(desirable) và SW2 sẽ ở Chế độ tự động(auto).

    SW1(config)# interface range Gi0/0 -3 <– Chọn 4 interfaces
    SW1(config-if-range)# channel-group 1 mode desirable <– Thiết lập mode desirable

    SW1(config-if-range)# exit

    SW1(config)# interface port-channel 1 <– Cấu hình cổng logic là trunk
    SW1(config-if)#switchport trunk encapsulation dot1q
    SW1(config-if)#switchport mode trunk


    SW2(config)# interface range Gi0/0 – 3 <– Select the 4 interfaces
    SW2(config-if-range)# channel-group 1 mode auto <– Set mode to auto

    SW2(config-if-range)# exit

    SW2(config)# interface port-channel 1 <– Configure the logical port as trunk
    SW2(config-if)#switchport trunk encapsulation dot1q
    SW2(config-if)#switchport mode trunk


    Các lệnh hiển thị hữu ích

    Dưới đây là một số lệnh hữu ích để xác minh hoạt động chính xác và cho các mục đích khắc phục sự cố:
    • show etherchannel summary
    • show etherchannel 1 port-channel
    • show interfaces etherchannel
    Chúc các bạn thành công!
     
  4. NgocMy

    NgocMy New Member

    rất rõ ràng và đầy đủ, cám ơn bài viết.
     

trang này