Example for Configuring Interface-based VLAN Assignment (LNP Dynamically Negotiates the Link Type)
Networking Requirements
Switching devices and user terminals are deployed on the network shown in Figure 4-25. To implement Layer 2 connectivity, configure the link type for each interface and add interfaces to VLANs. If the network scale is large, the configuration is complex. To simplify configurations, switches are connected through the trunk link, and switches and user terminals are connected through access links and added to VLANs.
Configuration Roadmap
The configuration roadmap is as follows:
- Enable LNP in the system view and interface view to implement auto-negotiation. Because PCs do not support LNP, so switch interfaces connected to terminals are used as access interfaces and interfaces between switches are used as trunk interfaces through negotiation.
- Create VLANs and add interfaces to VLANs to implement Layer 2 connectivity.
Procedure
- Enable global LNP
By default, global LNP is enabled. If LNP is disabled, run the undo lnp disable command in the system view to enable LNP.
- Create VLANs.
You can create VLANs on each switch, or create VLANs on Switch3 and use the VLAN Central Management Protocol (VCMP) to synchronize created VLANs to other switches. The following describes how to create VLANs. If VCMP is used, you need to configure Switch3 as the VCMP server and Switch1 and Switch2 as the VCMP clients. For details, see VCMP Configuration.
# Create VLAN 10 and VLAN 20 on Switch3. The configurations of Switch1 and Switch2 are similar to the configuration of Switch3, and are not mentioned here.
<HUAWEI> system-view [HUAWEI] sysname Switch3 [Switch3] vlan batch 10 20
- Enable LNP on interfaces, and add switch interfaces connected to PCs to a VLAN as access interfaces and interfaces between switches to VLANs as trunk interfaces
- If the interface is not a Layer 2 interface, you need to run the portswitch command to set the interface to work in Layer 2 mode.
- By default, LNP is enabled. If LNP is disabled, run the undo port negotiation disable command to enable LNP on the interface.
# Configure Switch1. The configurations of Switch2 are similar to the configuration of Switch1, and are not mentioned here.
[Switch1] interface GigabitEthernet 1/0/1 [Switch1-GigabitEthernet1/0/1] port default vlan 10 [Switch1-GigabitEthernet1/0/1] quit [Switch1] interface GigabitEthernet 1/0/2 [Switch1-GigabitEthernet1/0/2] port trunk allow-pass only-vlan 10 20 [Switch1-GigabitEthernet1/0/2] quit [Switch1] interface GigabitEthernet 1/0/3 [Switch1-GigabitEthernet1/0/3] port default vlan 20 [Switch1-GigabitEthernet1/0/3] quit
# Configure Switch3.
[Switch3] interface GigabitEthernet 1/0/1 [Switch3-GigabitEthernet1/0/1] port trunk allow-pass only-vlan 10 20 [Switch3-GigabitEthernet1/0/1] quit [Switch3] interface GigabitEthernet 1/0/2 [Switch3-GigabitEthernet1/0/2] port trunk allow-pass only-vlan 10 20 [Switch3-GigabitEthernet1/0/2] quit
The port trunk allow-pass only-vlan 10 20 command configures the interface to allow only VLAN 10 and VLAN 20. - Verify the configuration.
After the preceding configuration is complete, run the display lnp interface interface-type interface-number command to view auto-negotiation on the specified Layer 2 interface.
[Switch1] display lnp interface gigabitethernet1/0/2 LNP information for GigabitEthernet1/0/2: Port link type: trunk Negotiation mode: desirable Hello timer expiration(s): 7 Negotiation timer expiration(s): 0 Trunk timer expiration(s): 278 FSM state: trunk Packets statistics 56 packets received 0 packets dropped bad version: 0, bad TLV(s): 0, bad port link type: 0, bad negotiation state: 0, other: 0 58 packets output 0 packets dropped other: 0
Run the display lnp summary command to view auto-negotiation information on all interfaces of the Layer 2 device.
[Switch1] display lnp summary Global LNP : Negotiation enable ------------------------------------------------------------------------------- C: Configured; N: Negotiated; *: Negotiation disable; Port link-type(C) link-type(N) InDropped OutDropped FSM ------------------------------------------------------------------------------- GE1/0/1 desirable access 0 0 access GE1/0/2 desirable trunk 0 0 trunk GE1/0/3 desirable access 0 0 access
Configuration Files
Switch1 configuration file
# sysname Switch1 # vlan batch 10 20 # interface GigabitEthernet1/0/1 port default vlan 10 # interface GigabitEthernet1/0/2 port trunk allow-pass only-vlan 10 20 # interface GigabitEthernet1/0/3 port default vlan 20 # return
Switch2 configuration file
# sysname Switch2 # vlan batch 10 20 # interface GigabitEthernet1/0/1 port default vlan 10 # interface GigabitEthernet1/0/2 port trunk allow-pass only-vlan 10 20 # interface GigabitEthernet1/0/3 port default vlan 20 # return
Switch3 configuration file
# sysname Switch3 # vlan batch 10 20 # interface GigabitEthernet1/0/1 port trunk allow-pass only-vlan 10 20 # interface GigabitEthernet1/0/2 port trunk allow-pass only-vlan 10 20 # return