Example for Configuring Traffic Policy-based 2:2 VLAN Mapping
Networking Requirements
In Figure 11-9, enterprises A and B have planned their own C-VLAN IDs. These IDs are different to the S-VLAN IDs in the packets, which means that the primary interface discards the packets. To solve this problem, configure VLAN mapping at the user side to ensure the communication between enterprise A and enterprise B.
Configuration Roadmap
The configuration roadmap is as follows:
Create outer VLANs on SwitchA, SwitchB, SwitchC, and SwitchD.
Create classes, traffic behaviors, and traffic policies on SwitchA and SwitchB.
Add interfaces on SwitchA, SwitchB, SwitchC, and SwitchD to their own VLANs.
Configure traffic policy-based VLAN mapping of double tags on GE1/0/1 of SwitchA.
Configure traffic policy-based VLAN mapping of double tags on GE1/0/2 of SwitchB.
Procedure
- Configure VLANs.
# Create VLAN 100 and VLAN 300 on SwitchA.
<HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan batch 100 300
# Create VLAN 200 and VLAN 300 on SwitchB.
<HUAWEI> system-view [HUAWEI] sysname SwitchB [SwitchB] vlan batch 200 300
# Create VLAN 300 on SwitchC.
<HUAWEI> system-view [HUAWEI] sysname SwitchC [SwitchC] vlan batch 300
# Create VLAN 300 on SwitchD.
<HUAWEI> system-view [HUAWEI] sysname SwitchD [SwitchD] vlan batch 300
- Add interfaces to VLANs.
# Add GE1/0/1 of SwitchA to VLAN 100 and VLAN 300.
[SwitchA] interface gigabitethernet 1/0/1 [SwitchA-GigabitEthernet1/0/1] port link-type trunk [SwitchA-GigabitEthernet1/0/1] port trunk allow-pass vlan 100 300 [SwitchA-GigabitEthernet1/0/1] quit
# Add GE1/0/2 of SwitchB to VLAN 200 and VLAN 300.
[SwitchB] interface gigabitethernet 1/0/2 [SwitchB-GigabitEthernet1/0/2] port link-type trunk [SwitchB-GigabitEthernet1/0/2] port trunk allow-pass vlan 200 300 [SwitchB-GigabitEthernet1/0/2] quit
# Add GE1/0/1 of SwitchC to VLAN 300.
[SwitchC] interface gigabitethernet 1/0/1 [SwitchC-GigabitEthernet1/0/1] port link-type trunk [SwitchC-GigabitEthernet1/0/1] port trunk allow-pass vlan 300 [SwitchC-GigabitEthernet1/0/1] quit
# Add GE1/0/2 on SwitchD to VLAN 300.
[SwitchD] interface gigabitethernet 1/0/2 [SwitchD-GigabitEthernet1/0/2] port link-type trunk [SwitchD-GigabitEthernet1/0/2] port trunk allow-pass vlan 300 [SwitchD-GigabitEthernet1/0/2] quit
- Configure traffic classifiers, traffic behaviors, and traffic
policies.
# Configure the traffic classifier, traffic behavior, and traffic policy in the inbound direction of SwitchA.
[SwitchA] traffic classifier name1 operator and [SwitchA-classifier-name1] if-match vlan-id 300 [SwitchA-classifier-name1] if-match cvlan-id 30 [SwitchA-classifier-name1] quit [SwitchA] traffic behavior name1 [SwitchA-behavior-name1] remark vlan-id 100 [SwitchA-behavior-name1] remark cvlan-id 10 [SwitchA-behavior-name1] quit [SwitchA] traffic policy name1 [SwitchA-trafficpolicy-name1] classifier name1 behavior name1 [SwitchA-trafficpolicy-name1] quit
# Configure the traffic classifier, traffic behavior, and traffic policy in the outbound direction of SwitchA.
[SwitchA] traffic classifier name2 operator and [SwitchA-classifier-name2] if-match vlan-id 100 [SwitchA-classifier-name2] if-match cvlan-id 10 [SwitchA-classifier-name2] quit [SwitchA] traffic behavior name2 [SwitchA-behavior-name2] remark vlan-id 300 [SwitchA-behavior-name2] remark cvlan-id 30 [SwitchA-behavior-name2] quit [SwitchA] traffic policy name2 [SwitchA-trafficpolicy-name2] classifier name2 behavior name2 [SwitchA-trafficpolicy-name2] quit
# Configure the traffic classifier, traffic behavior, and traffic policy in the inbound direction of SwitchB.
[SwitchB] traffic classifier name1 operator and [SwitchB-classifier-name1] if-match vlan-id 300 [SwitchB-classifier-name1] if-match cvlan-id 30 [SwitchB-classifier-name1] quit [SwitchB] traffic behavior name1 [SwitchB-behavior-name1] remark vlan-id 200 [SwitchB-behavior-name1] remark cvlan-id 20 [SwitchB-behavior-name1] quit [SwitchB] traffic policy name1 [SwitchB-trafficpolicy-name1] classifier name1 behavior name1 [SwitchB-trafficpolicy-name1] quit
# Configure the traffic classifier, traffic behavior, and traffic policy in the outbound direction of SwitchB.
[SwitchB] traffic classifier name2 operator and [SwitchB-classifier-name2] if-match vlan-id 200 [SwitchB-classifier-name2] if-match cvlan-id 20 [SwitchB-classifier-name2] quit [SwitchB] traffic behavior name2 [SwitchB-behavior-name2] remark vlan-id 300 [SwitchB-behavior-name2] remark cvlan-id 30 [SwitchB-behavior-name2] quit [SwitchB] traffic policy name2 [SwitchB-trafficpolicy-name2] classifier name2 behavior name2 [SwitchB-trafficpolicy-name2] quit
- Configure traffic policy-based VLAN mapping of double tags.
# Configure traffic policy-based VLAN mapping of double tags on GE1/0/1 of SwitchA.
[SwitchA] interface GigabitEthernet 1/0/1 [SwitchA-GigabitEthernet1/0/1] traffic-policy name1 inbound [SwitchA-GigabitEthernet1/0/1] traffic-policy name2 outbound
# Configure traffic policy-based VLAN mapping of double tags on GE1/0/2 of SwitchB.
[SwitchB] interface GigabitEthernet 1/0/2 [SwitchB-GigabitEthernet1/0/2] traffic-policy name1 inbound [SwitchB-GigabitEthernet1/0/2] traffic-policy name2 outbound
- Verify the configurations.
Verify that users of enterprise A and enterprise B can communicate with each other.
Configuration Files
SwitchA configuration file
# sysname SwitchA # vlan batch 100 300 # traffic classifier name1 operator and precedence 5 if-match vlan-id 300 if-match cvlan-id 30 traffic classifier name2 operator and precedence 10 if-match vlan-id 100 if-match cvlan-id 10 # traffic behavior name1 permit remark vlan-id 100 remark cvlan-id 10 traffic behavior name2 permit remark vlan-id 300 remark cvlan-id 30 # traffic policy name1 match-order config classifier name1 behavior name1 traffic policy name2 match-order config classifier name2 behavior name2 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 100 300 traffic-policy name1 inbound traffic-policy name2 outbound # return
SwitchB configuration file
# sysname SwitchB # vlan batch 200 300 # traffic classifier name1 operator and precedence 5 if-match vlan-id 300 if-match cvlan-id 30 traffic classifier name2 operator and precedence 10 if-match vlan-id 200 if-match cvlan-id 20 # traffic behavior name1 permit remark vlan-id 200 remark cvlan-id 20 traffic behavior name2 permit remark vlan-id 300 remark cvlan-id 30 # traffic policy name1 match-order config classifier name1 behavior name1 traffic policy name2 match-order config classifier name2 behavior name2 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 200 300 traffic-policy name1 inbound traffic-policy name2 outbound # return
SwitchC configuration file
# sysname SwitchC # vlan batch 300 # interface GigabitEthernet1/0/1 port link-type trunk port trunk allow-pass vlan 300 # return
SwitchD configuration file
# sysname SwitchD # vlan batch 300 # interface GigabitEthernet1/0/2 port link-type trunk port trunk allow-pass vlan 300 # return