test

2.5 Cách cấu hình trunk trên switch Cisco catalyst

Trunks là yêu cầu cho Vlan traffic giữa các switches với nhau. Trong phần này chúng ta hãy cùng xem cách cấu hình trunk giữa các switches Cisco. Đây là 1 ví dụ:
Ở ví dụ trên bạn có thể nhìn thấy chúng ta có 2 máy tính kết nối tới 2 switches. Chúng ta sẽ đưa 2 máy tính vào chung 1 vlan trên cả 2 switches.

Tạo vlan trên switches

SW1(config)#vlan 50
SW1(config-vlan)#name Computers
SW1(config-vlan)#exit

SW2(config)#vlan 50
SW2(config-vlan)#name Computers
SW2(config-vlan)#exit

Đưa interface kết nối mỗi máy tính vào vlan.

SW1(config)#interface fa0/1
SW1(config-if)#switchport access vlan 50

SW2(config)#interface fa0/2
SW2(config-if)#switchport access vlan 50

Bây giờ chúng ta sẽ tạo trunk trên 2 interfaces kết nối giữa 2 switches

SW1(config)#interface fa0/14
SW1(config-if)#switchport mode trunk
Command rejected: An interface whose trunk encapsulation is "Auto" can not be
configured to "trunk" mode.

SW2(config)#interface fa0/14
SW2(config-if)#switchport mode trunk
Command rejected: An interface whose trunk encapsulation is "Auto" can not be
configured to "trunk" mode.

Chúng ta đã cấu hình mode trunk trên interface tuy nhiên có thông báo lỗi xảy ra, vậy trước khi cấu hình mode trunk  chúng ta cần cấu hình kiểu đóng gói trunk trước (802.1Q hoặc ISL).

SW1(config-if)#switchport trunk encapsulation dot1q

SW2(config-if)#switchport trunk encapsulation dot1q

SW1#show interfaces fa0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: dynamic auto
Operational Mode: static access
Administrative Trunking Encapsulation: dot1q

SW2#show interfaces fa0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: dynamic auto
Operational Mode: static access
Administrative Trunking Encapsulation: dot1q

Bạn có thể nhìn thấy loại đóng gói trunk trên mỗi interface. Giờ chúng ta sẽ cấu hình lại mode trunk trên mỗi interface.

SW1(config)#interface fa0/14
SW1(config-if)#switchport mode trunk

SW2(config)#interface fa0/14
SW2(config-if)#switchport mode trunk

Bây giờ các bạn có thể kiểm tra từng port kết nối giữa 2 switches.

SW1#show interfaces fa0/14 switchport
Name: Fa0/14
Switchport: Enabled Administrative Mode: trunk Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q

SW2#show interfaces fa0/14 switchport
Name: Fa0/14
Switchport: Enabled Administrative Mode: trunk Operational Mode: trunk
Administrative Trunking Encapsulation: dot1q
Operational Trunking Encapsulation: dot1q

OK. Bây giờ hãy thử ping giữa H1 và H2

C:\Documents and Settings\H1>ping 192.168.1.2
Pinging 192.168.1.2 with 32 bytes of data:
Reply from 192.168.1.2: bytes=32 time<1ms TTL=128
Reply from 192.168.1.2: bytes=32 time<1ms TTL=128
Reply from 192.168.1.2: bytes=32 time<1ms TTL=128
Reply from 192.168.1.2: bytes=32 time<1ms TTL=128
Ping statistics for 192.168.1.2:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms

Tuyệt vời phải không nào? H1 và H2 đã thông nhau. Theo bạn chúng ta đã hoàn thành chưa? Hãy xem tiếp, Chúng ta vẫn còn những phần khác ở đằng sau. Giờ hãy thử show vlan trên switch.

Đầu tiên bạn có thể thấy là không nhìn thấy inter fa0/14. Nó là hoàn toàn bình thường bởi vì câu lệnh show vlan chỉ show cho chúng ta những interface đang ở mode access, không phải trunk. Giờ hãy tới với câu lệnh tiếp theo.

Bạn thấy không? Câu lênh show interface trunk rất có ích. Nó sẽ show toàn bộ các interface đang ở mode trunk với cách đóng gói là 802.1Q hoặc ISL và native Vlan đi cùng nó.
Chúng ta cũng thấy Vlan 1-4094 được cho phép hoạt động trong interface trunk. Chúng ta cũng thấy ở đây native Vlan là 1, vlan 50 đang hoạt động. Điều cuối cùng là trạng thái port trong spanning-tree là forwarding (Chúng ta sẽ có 1 vài bài khác liên quan tới spanning tree). 
Trước khi chúng ta tiếp tục với VTP, các bạn hãy để ý tới câu lệnh sau.


SW2#show interface fa0/2 switchport


Name: Fa0/2
Switchport: Enabled
Administrative Mode: static access
Operational Mode: static access

1 interface có thể ở mode access hoặc mode trunk. Ở đây port fa0/2 cưa switch 2 kết nối với máy tính đang ở static access Nó có nghĩa là port này đang ở mode access.

SW2#show interfaces fa0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk

Phía trên lại là 1 trường hợp khác. Port fa0/14 đang ở mode trunk

SW2(config-if)#switchport mode ?
access Set trunking mode to ACCESS unconditionally
dot1q-tunnel set trunking mode to TUNNEL unconditionally
dynamic Set trunking mode to dynamically negotiate access or trunk
private-vlan Set private-vlan mode
trunk Set trunking mode to TRUNK unconditionally

Như bạn thấy bên trên. Khi đi vào cấu hình các mode cho interface chúng ta có khá nhiều options, trong đó có cả dynamic, giờ hãy kiểm tra cái options này.

SW2(config-if)#switchport mode dynamic ?
auto Set trunking mode dynamic negotiation parameter to AUTO
desirable Set trunking mode dynamic negotiation parameter to DESIRABLE

Chúng ta có thể lựa chọn dynamic AUTO hoặc dynamic DESIRABLE. Lúc này switch sẽ tự động tìm cấu hình port theo mode trunk hoặc access. Vậy sự khác nhau giữa AUTO và DESIRABLE là gì?
OK. Giờ chúng ta hãy cấu hình cả 2 port ở 2 switches ở chế độ AUTO trước. Các bạn hãy xem cấu hình.
SW1(config)#interface fa0/14

SW1(config-if)#switchport mode dynamic auto

SW1(config)#interface fa0/14
SW2(config-if)#switchport mode dynamic auto

Và đây là kết quả.

SW1(config-if)#do show interface f0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: dynamic auto
Operational Mode: static access

SW2(config-if)#do show interface f0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: dynamic auto
Operational Mode: static access

Bạn có thể thấy chúng ta có port ở mode access.

Bây giờ ta không cấu hình ở dạng AUTO nữa, thử chuyển sang DESIRABLE  nhé.

SW1(config)#interface fa0/14
SW1(config-if)#switchport mode dynamic desirable
SW2(config)#interface fa0/14
SW2(config-if)#switchport mode dynamic auto

Và đây là kết quả:

SW1#show interfaces fa0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: dynamic desirable
Operational Mode: trunk

SW2#show interfaces fa0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: dynamic desirable
Operational Mode: trunk

Kaka. Như các bạn thấy bên trên với dynamic DESIRABLE  thì 2 port của chúng ta đều chạy ở mode trunk.

Ok. Thế giờ chuyện gì sẽ xảy ra nếu như 1 port ở chế độ AUTO, 1 ở DESIRABLE.


SW1(config)#interface fa0/14
SW1(config-if)#switchport mode dynamic desirable

SW2(config)#interface fa0/14
SW2(config-if)#switchport mode dynamic auto

Và đây sẽ là kết quả:

SW1#show interfaces f0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: dynamic desirable
Operational Mode: trunk

SW2#show interfaces fa0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: dynamic auto
Operational Mode: trunk

Tata. Chúng ta vẫn có 2 port ở mode trunk phải ko nào. 
Bây giờ chúng ta hãy xem phần cấu hình dưới đây. Chắc chắn sẽ giúp bạn rất nhiều.

SW1(config)#interface fa0/14
SW1(config-if)#switchport mode dynamic auto

SW2(config)#interface fa0/14
SW2(config-if)#switchport mode trunk

Như ta thấy 1 port cấu hình trunk, 1 port auto. Và đây là kết quả.

SW1#show interfaces f0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: dynamic auto
Operational Mode: trunk

SW2#show interfaces fa0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk

Ok. Ta thấy 2 port cùng đã chuyển sang mode trunk.
Vậy 1 port auto còn 1 port access thì sao?

SW1(config)#interface fa0/14
SW1(config-if)#switchport mode dynamic auto

SW2(config)#interface fa0/14
SW2(config-if)#switchport mode access

Và đây là kết quả:

SW1#show interfaces f0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: dynamic auto
Operational Mode: static access

SW2#show interfaces fa0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: static access
Operational Mode: static access

Tèn tèn. Chúng ta có 2 ports access.
Như vậy có thể kết luận, khi 2 port của switch connected với nhau, 1 port cấu hình AUTO thì nó sẽ hoạt động ở mode trunk hay access phụ thuộc vào port bên kia cấu hình như thế nào. Nó sẽ tự động nhận cấu hình của port của switch kết nối với nó.

Phần dynamic AUTO đã ok. GIờ hãy thử tới DESIRABLE

SW1(config)#interface fa0/14
SW1(config-if)#switchport mode dynamic desirable

SW2(config)#interface fa0/14
SW2(config-if)#switchport mode trunk

SW1#show interfaces f0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: dynamic desirable
Operational Mode: trunk

SW2#show interfaces fa0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk

Ok. Như các bạn thấy thì DESIRABLE kết hợp với trunk thì chúng ta sẽ có 2 ports trunk.
Vậy chuyện gì sẽ xảy ra nếu như ta cấu hình 1 port trunk, 1 port access?

SW1(config)#interface fa0/14
SW1(config-if)#switchport mode access

SW2(config)#interface fa0/14
SW2(config-if)#switchport mode trunk

SW1#show interfaces f0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: static access
Operational Mode: trunk

SW2#show interfaces fa0/14 switchport
Name: Fa0/14
Switchport: Enabled
Administrative Mode: trunk
Operational Mode: trunk

SW1#
%SPANTREE-7-RECV_1Q_NON_TRUNK: Received 802.1Q BPDU on non trunk
FastEthernet0/14 VLAN1.
%SPANTREE-7-BLOCK_PORT_TYPE: Blocking FastEthernet0/14 on VLAN0001. Inconsistent
port type.
%SPANTREE-2-UNBLOCK_CONSIST_PORT: Unblocking FastEthernet0/14 on VLAN0001. Port
consistency restored.

Aha. Chúng ta sẽ có 2 ports trunk nhưng lỗi đã xuất hiện bởi spanning-tree. Spanning-tree là 1 giao thức hoạt động trên switch để phòng chống LOOP. Chúng ta sẽ nghiên cứu sau. Bây giờ hãy xem lại sự khác nhau của switchport mode và kết quả của chúng.

Đó là tất cả chúng ta có về trunking giữa 2 switch. Hi vọng nó sẽ có ích cho các bạn.
Dưới đây là toàn bộ câu lệnh đã cấu hình trên 2 switches.

hostname SW1
!
vlan 50
name Computers
!
interface FastEthernet0/1
switchport access vlan 50
!
interface FastEthernet0/14
switchport mode trunk
switchport trunk encapsulation dot1q
!
end 

hostname SW2
!
vlan 50
name Computers
!
interface FastEthernet0/2
switchport access vlan 50
!
interface FastEthernet0/14
switchport mode trunk
switchport trunk encapsulation dot1q
!
end

Trân trọng!
2.5 Cách cấu hình trunk trên switch Cisco catalyst 2.5 Cách cấu hình trunk trên switch Cisco catalyst Reviewed by phucvm on tháng 8 18, 2019 Rating: 5

Không có nhận xét nào:

Được tạo bởi Blogger.