As shown in the figure, HostA and HostB, HostC and Hostd belong to the R&D department and the quality department respectively, and the two departments are interconnected through a Layer 2 switch.
Configuration Idea:
1.Add the interface that connects the switchb to the host terminal to the VLAN and set the link type to access;
2.Add the interface between SwitchA and SwitchB to a VLAN with the link type trunk;
3.Create a VLANIF and configure the gateway with the IP address of the user
Detailed operation steps:
switcha configuration:
1.Create a VLAN
system-view into system mode.
switcha]vlan batch 2 3 Create new vlans 2 and 3 in batches
2.Create a VLANIF Layer 3 interface as the gateway IP address of the PC.
switcha] interface vlanif 2 enters the Layer 3 vlanif10 interface.
switcha-vlanif2] ip address 1.1.1.1 255.255.255.0 This IP address is the gateway address corresponding to HostA B.
switcha-vlanif2] quit exit the vlanif2 interface.
switcha] interface vlanif 3
switcha-vlanif3] ip address 2.2.2.1 255.255.255.0 This IP address is the gateway address corresponding to Hostc D.
switcha-vlanif3] quit
3.The interface is added to the corresponding VLAN, SwitchA---Trunk---SwitchB
switcha] interface gigabitethernet 0/0/1
switcha-gigabitethernet0 0 1] port link-type trunk The link type is trunk
switcha-gigabitethernet0 0 1] port trunk allow-pass 2 to 3 divides the interface into vlan 2 and vlan3.
switcha-gigabitethernet0/0/1] quit
switchb configuration:
1.Create a VLAN
system-view into system mode.
SwitchB] vlan batch 2 3 Create new vlans 2 and 3 in batches
2.The interface is added to the corresponding VLAN, and SwitchB---Trunk---SwitchA
switchb] interface gigabitethernet 0/0/1
switchb-gigabitethernet0 0 1] port link-type trunk The link type is trunk
switchb-gigabitethernet0 0 1] port trunk allow-pass 2 to 3 divides the interface into vlan 2 and vlan3.
switchb-gigabitethernet0/0/1] quit
The interface joins the corresponding VLAN, SwitchB---Access--- Host, HostA and HostB are the same, and C and D are the same.
switchb] interface ethernet 0/0/2
switchb-ethernet0 0 2] port link-type access The link type is access
switchb-ethernet0 0 2] port default vlan 2 divides hosta into vlan2.
switchb-ethernet0/0/2] quit
switchb] interface ethernet 0/0/4
switchb-ethernet0 0 4] port link-type access The link type is access
switchb-ethernet0 0 4] port default vlan 3 divides hostc into vlan3.
switchb-ethernet0/0/3] quit
Test it out.