test

2.11 Private VLAN (PVLAN) on Switch

Chào các bạn. Trong bài trước tôi đã giới thiệu về protected port . Bây giờ chúng ta hãy tìm hiểu về Private VLAN nhé. Hãy xem ví dụ dưới đây nào

Rất nhiều người nghĩ rằng private VLAN là khá phức tạp khi nhìn vào hình lần đầu tiên. Bây giờ tôi sẽ giải thích nó hoạt động như thế nào nhé.
Private VLAN luôn luôn có 1 primary VLAN. Bên trong primary VLAN bạn sẽ tìm thấy các port gọi là promiscuous port. Trong hình trên bạn có thể thấy là 1 router đang kết nối tới 1 promiscuous port. Tất cả các port còn lại đều có thể kết nối tới Promiscuous port. Bên trong primary VLAN bạn cũng sẽ có 1 hoặc 1 vài secondary VLANs, ở đây secondary VLANs có 2 loại:
  • Community VLAN: Tất cả các port bên trong community VLAN đề có thể kết nối với nhau và kết nối với promiscuous port.
  • Isolated VLAN: Tất cả các port bên trong isolated VLAN không thể kết nối với nhau nhưng chúng có thể kết nối voiws primiscuous port.
Giờ tới phần cấu hình nhé.
Đầu tiên chúng ta hãy kiểm tra topology nhé.
Giờ hãy kiểm tra xem chúng ta có gì trong topo trên nhé.
  • Primary VLAN là 500
  • Community VLAN là 501
  • Isolated VLAN là 502
  • H1 và H2 bên trong community VLAN, vì vậy chúng có thể giao tiếp với nhau vào giao tiếp với S1 (kết nối vào Prom port)
  • H3 và H4 bên trong isolated VLAN, vì vậy chúng không thể kết nối với nhau, chỉ có thể kết nối với S1.
Giờ hãy bắt đầu nào!


SW1(config)#vtp mode transparent
Setting device to VTP TRANSPARENT mode.

Việc cấu hình private VLAN yêu cầu trước tiên chúng ta phải đổi VTP mode trang transparent.

SW1(config)#vlan 501
SW1(config-vlan)#private-vlan community
SW1(config-vlan)#vlan 500
SW1(config-vlan)#private-vlan primary
SW1(config-vlan)#private-vlan association add 501

Giờ tôi đã cấu hình community VLAN rồi đó. Đầu tiên là tạo VLAN, sao đó là cài đặt nó vào dạng community. Tiếp theo chúng ta tạo VLAN 500, cấu hình nó thành primary, và cuối cùng là add VLAN 501 vào VLAN 500.

SW1(config)#interface range fa0/1 - 2
SW1(config-if-range)#switchport mode private-vlan host
SW1(config-if-range)#switchport private-vlan host-association 500 501

Như các bạn thấy bên trên tôi đã cấu hình port kết nối tới H1 và H2 vào VLAN 501. Chúng ta cũng phải sử dụng câu lệnh switchport private-vlan host-association để báo với witch là VLAN 501 nằm trong VLAN 500.
Tiếp theo chúng ta sẽ cấu hình fa0/24 là promisuous port.

SW1(config)#interface fa0/24
SW1(config-if)#switchport mode private-vlan promiscuous
SW1(config-if)#switchport private-vlan mapping 500 501

Giờ hãy kiểm tra interface trên switch 1 nhé.

SW1#show interfaces fastEthernet 0/1 switchport
Name: Fa0/1
Switchport: Enabled
Administrative Mode: private-vlan host
Operational Mode: down
Administrative Trunking Encapsulation: negotiate
Negotiation of Trunking: Off
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Administrative Native VLAN tagging: enabled
Voice VLAN: none
Administrative private-vlan host-association: 500 (VLAN0500) 501 (VLAN0501)
Administrative private-vlan mapping: none

SW1#show interface fa0/24 switchport
Name: Fa0/24
Switchport: Enabled
Administrative Mode: private-vlan promiscuous
Operational Mode: private-vlan promiscuous
Administrative Trunking Encapsulation: negotiate
Operational Trunking Encapsulation: native
Negotiation of Trunking: Off
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Administrative Native VLAN tagging: enabled
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: 500 (VLAN0500) 501 (VLAN0501)

Đó các bạn thấy không. Port fa0/1 và fa0/24 đã ok rồi đó.
Tiếp theo hãy sử dụng lệnh sau:

SW1#show vlan private-vlan
Primary Secondary Type Ports
------- --------- ----------------- -----------------------------------------
-
500 501 community Fa0/1, Fa0/2, Fa0/24

Câu lệnh show vlan private-vlan cho chúng ta những thông tin quý giá. Bạn có thể thấy vlan 500 chính là primary VLAN và vlan 501 chính là secondary VLAN, nó cũng cho bạn biết VLAN 501 thuộc lại community hay isolated VLAN.

SW1#show vlan private-vlan type
Vlan Type
---- -----------------
500 primary
501 community

Câu lệnh trên lại cho chúng ta 1 cái nhìn nhanh chóng về private VLAN, rất dễ nhìn phải không các bạn. Nhưng nó chỉ show duy nhất VLAN chứ không show port nhé.

Còn giờ thì hãy đi kiểm tra kết nối giữa các máy tính nào.

C:Documents and SettingsH1>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

C:Documents and SettingsH1>ping 192.168.1.254
Pinging 192.168.1.254 with 32 bytes of data:
Reply from 192.168.1.254: bytes=32 time<1ms TTL=128

C:Documents and SettingsS1>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

Oa các bạn thấy đó, H1 có thể ping H2, H1 có thể ping server và server có thể ping H2. Ok rồi đó.
Giờ chúng ta tiếp tục với isolated VLAN nhé.

SW1(config)#vlan 502
SW1(config-vlan)#private-vlan isolated
SW1(config-vlan)#vlan 500
SW1(config-vlan)#private-vlan primary
SW1(config-vlan)#private-vlan association add 502

Rồi đó. Tôi đã tạo VLAN 502, cấu hình nó thành isolated VLAN, gán vào VLAN 500 (Primary VLAN). Giờ tôi sẽ cấu hình thêm interface fa0/3-4 nhé. Chúng sẽ thuộc isolated VLAN.

SW1(config)#interface range fa0/3 - 4
SW1(config-if-range)#switchport mode private-vlan host
SW1(config-if-range)#switchport private-vlan host-association 500 502

Ok rồi đó. Port fa0/3-4 đã được cấu hình cho VLAN 502. Tiếp theo chúng ta cấu hình tới fa0/24 nào

SW1(config)#interface fa0/24
SW1(config-if)#switchport mode private-vlan promiscuous
SW1(config-if)#switchport private-vlan mapping 500 502

Đó tôi vừa đưa thêm VLAN 502 vào đó.
Giờ chúng ta hãy xem kết quả kiểm tra nhé.

SW1#show interfaces fa0/3 switchport
Name: Fa0/3
Switchport: Enabled
Administrative Mode: private-vlan host
Operational Mode: down
Administrative Trunking Encapsulation: negotiate
Negotiation of Trunking: Off
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Administrative Native VLAN tagging: enabled
Voice VLAN: none
Administrative private-vlan host-association: 500 (VLAN0500) 502 (VLAN0502)
Administrative private-vlan mapping: none

Aha. Port fa0.3 đã OK phải ko nào và port 4 cũng phải tương tự thế.

SW1#show interfaces fastEthernet 0/4 switchport | include host-as
Administrative private-vlan host-association: 500 (VLAN0500) 502 (VLAN0502)

Giờ kiểm tra port 24 1 lần nữa nhé.

SW1#show interfaces fa0/24 switchport
Name: Fa0/24
Switchport: Enabled
Administrative Mode: private-vlan promiscuous
Operational Mode: private-vlan promiscuous
Administrative Trunking Encapsulation: negotiate
Operational Trunking Encapsulation: native
Negotiation of Trunking: Off
Access Mode VLAN: 1 (default)
Trunking Native Mode VLAN: 1 (default)
Administrative Native VLAN tagging: enabled
Voice VLAN: none
Administrative private-vlan host-association: none
Administrative private-vlan mapping: 500 (VLAN0500) 501 (VLAN0501) 502
(VLAN0502)

Rồi đó. Các bạn thấy không? Bây giờ cả VLAN 501 và 502 đã nằm trong primary VLAN 500.
Giờ hãy thử với câu lệnh "show vlan private-vlan"

SW1#show vlan private-vlan
Primary Secondary Type Ports
------- --------- ----------------- -----------------------------------------
-
500 501 community Fa0/1, Fa0/2, Fa0/24
500 502 isolated Fa0/3, Fa0/4, Fa0/24

VLAN, port, loại VLAN đều hiện đủ rồi nè.
Để đơn giản hơn chúng ta có câu lệnh:

SW1#show vlan private-vlan type
Vlan Type
---- -----------------
500 primary
501 community
502 isolated

Aha. Nếu như bạn chỉ quan tâm tới VLAN thì câu lệnh trên là đủ rồi đó.
Ok rồi. Giờ hãy kiểm tra kết nối giữa các máy tính và server nào.

C:\Documents and Settings\H3>ping 192.168.1.254
Pinging 192.168.1.254 with 32 bytes of data:
Reply from 192.168.1.254: bytes=32 time<1ms TTL=128

C:\Documents and Settings\H4>ping 192.168.1.254
Pinging 192.168.1.254 with 32 bytes of data:
Reply from 192.168.1.254: bytes=32 time<1ms TTL=128

C:\Documents and Settings\H3>ping 192.168.1.4
Pinging 192.168.1.4 with 32 bytes of data:
Request timed out.
Ping statistics for 192.168.1.4:
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),

C:\Documents and Settings\H1>ping 192.168.1.4
Pinging 192.168.1.4 with 32 bytes of data:
Request timed out.
Ping statistics for 192.168.1.4:
Packets: Sent = 1, Received = 0, Lost = 1 (100% loss),

Các bạn thấy kết quả không? H3 và H4 có thể kết nối tới server nhưng không thể kết nối với nhau. Tôi cũng đã thử ping từ H1 tới H4 nhưng cũng không được. Thế là private VLAN đã chạy hoàn hảo rồi đó. 
Thực tế áp dụng với doanh nghiệp khi sử dụng private VLAN là khá ít. Nó chỉ hữu dụng đối với DC, khi mà các server trong cùng 1 VLAN cần phân tách traffic của 1 hay 1 nhóm khách hàng, không cho phép các server kết nối với nhau, chỉ cho phép server ra ngoài internet.
Trân trọng!
2.11 Private VLAN (PVLAN) on Switch 2.11 Private VLAN (PVLAN) on Switch Reviewed by phucvm on tháng 8 21, 2019 Rating: 5

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

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