当前位置:网站首页>Configure the switch to divide VLAN based on the interface (access layer equipment as gateway)

Configure the switch to divide VLAN based on the interface (access layer equipment as gateway)

2020-11-10 17:46:25 Nankong City

Networking graph

  brief introduction

  • Divide VLAN There are : Based on interfaces 、 be based on MAC Address 、 be based on IP subnet 、 Based on the agreement 、 Based on Strategy (MAC Address 、IP Address 、 Interface ). It is based on interface partition VLAN, It's the simplest , The most common way to divide .
  • Based on interface partition VLAN According to the interface of the switch VLAN. Network administrators pre configure each interface of the switch with a different PVID, When a data frame enters the switch , If you don't have VLAN label , The data frame will be marked with interface specification PVID Of Tag, Then the data frame will be specified in PVID Transmission of .
  • In a typical layered network , When the access switch is a layer 3 switch , It can be used as a gateway for users , Reduce the configuration and complexity of aggregation switches .

Networking requirements

  • Pictured 1 Shown ,PC1 and PC2 Respectively belong to VLAN 2 and VLAN 3, Through the access switch SW2 Access switch convergence SW1.PC3 Belong to VLAN 4, adopt SW3 Access switch convergence SW1. Access switch SW2 As PC1 and PC2 Gateway for ,SW3 As PC3 Gateway for , By configuring static routing on the switch , Implement users PC Mutual access and interconnection with routers .

Configuration ideas

  • Configure the access switch , Based on interface partition VLAN, Realize the interworking between the two layers .
  • Configure the access switch as PC Gateway for , Realize the communication between users in different network segments .
  • Configure aggregation switch static routing , Realize the intercommunication between users and routers .

Operation steps

  • Configure the access switch SW2

  # establish VLAN.

<HUAWEI> system-view
[HUAWEI] sysname SW2  // Change the name of the device to SW2, Easy to identify 
[SW2] vlan batch 2 to 3  // Batch creation VLAN 2 and VLAN 3

   # Add the interface to the corresponding VLAN.

[SW2] interface gigabitethernet 1/0/23
[SW2-GigabitEthernet1/0/23] port link-type access  // Will work with PC The interface type of the connected interface is set to access
[SW2-GigabitEthernet1/0/23] port default vlan 2  // take PC1 into VLAN 2
[SW2-GigabitEthernet1/0/23] quit
[SW2] interface gigabitethernet 1/0/24
[SW2-GigabitEthernet1/0/24] port link-type access
[SW2-GigabitEthernet1/0/24] port default vlan 3  // take PC2 into VLAN 3
[SW2-GigabitEthernet1/0/24] quit

   # To configure VLANIF Interface , As the user PC Gateway for .

[SW2] interface vlanif 2  // establish VLANIF2 Interface 
[SW2-Vlanif2] ip address 192.168.2.1 24  // To configure IP Address , this IP The address is PC1 Gateway address for 
[SW2-Vlanif2] quit
[SW2] interface vlanif 3  // establish VLANIF3 Interface 
[SW2-Vlanif3] ip address 192.168.3.1 24  // To configure IP Address , this IP The address is PC2 Gateway address for 
[SW2-Vlanif3] quit

   # To configure SW2 and SW1 interconnection .

[SW2] vlan batch 5  // establish VLAN 5
[SW2] interface gigabitethernet 1/0/1
[SW2-GigabitEthernet1/0/1] port link-type access
[SW2-GigabitEthernet1/0/1] port default vlan 5  //SW2 and SW1 With Untagged Means of communication 
[SW2-GigabitEthernet1/0/1] quit
[SW2] interface vlanif 5  // establish VLANIF5 Interface 
[SW2-Vlanif5] ip address 192.168.5.2 24  // To configure IP Address , this IP The address is SW2 And SW1 Interconnection interface IP Address 
[SW2-Vlanif5] quit
[SW2] ip route-static 0.0.0.0 0.0.0.0 192.168.5.1  // Configure the default route , by PC The user finds the exit to access the router . The next hop of the default route is SW1 Connected to the interface IP Address 
  •   Configure the access switch SW3

  # establish VLAN.

<HUAWEI> system-view
[HUAWEI] sysname SW3  // Change the name of the device to SW3
[SW3] vlan batch 4  // Batch creation VLAN 4

   # Add the interface to the corresponding VLAN.

[SW3] interface gigabitethernet 1/0/2
[SW3-GigabitEthernet1/0/2] port link-type access  // Will work with PC The interface type of the connected interface is set to access
[SW3-GigabitEthernet1/0/2] port default vlan 4  // take PC3 into VLAN 4
[SW3-GigabitEthernet1/0/2] quit

   # To configure VLANIF Interface , As the user PC Gateway for .

[SW3] interface vlanif 4  // establish VLANIF4 Interface 
[SW3-Vlanif4] ip address 192.168.4.1 24  // To configure IP Address , this IP The address is PC3 Gateway address for 
[SW3-Vlanif4] quit

   # To configure SW3 and SW1 interconnection .

[SW3] vlan batch 5  // establish VLAN 5
[SW3] interface gigabitethernet 1/0/1
[SW3-GigabitEthernet1/0/1] port link-type access
[SW3-GigabitEthernet1/0/1] port default vlan 5  //SW3 and SW1 With Untagged Means of communication 
[SW3-GigabitEthernet1/0/1] quit
[SW3] interface vlanif 5  // establish VLANIF5 Interface 
[SW3-Vlanif5] ip address 192.168.5.3 24  // To configure IP Address , this IP The address is SW3 And SW1 Interconnection interface IP Address 
[SW3-Vlanif5] quit
[SW3] ip route-static 0.0.0.0 0.0.0.0 192.168.5.1  // Configure the default route , by PC The user specifies the exit to access the router . The next hop of the default route is SW1 Connected to the interface IP Address 
  •   Configure the aggregation switch SW1

  # establish VLAN.

<HUAWEI> system-view
[HUAWEI] sysname SW1  // Change the name of the device to SW1
[SW1] vlan batch 5  // Batch creation VLAN 5

   # Will connect PC Add the corresponding VLAN.

[SW1] interface gigabitethernet 1/0/1
[SW1-GigabitEthernet1/0/1] port link-type access  // Set the interface type of the interface connected to the router to access
[SW1-GigabitEthernet1/0/1] port default vlan 5
[SW1-GigabitEthernet1/0/1] quit
[SW1] interface gigabitethernet 1/0/2
[SW1-GigabitEthernet1/0/2] port link-type access  // Will work with SW2 The interface type of the connected interface is set to access
[SW1-GigabitEthernet1/0/2] port default vlan 5
[SW1-GigabitEthernet1/0/2] quit
[SW1] interface gigabitethernet 1/0/3
[SW1-GigabitEthernet1/0/3] port link-type access  // Will work with SW3 The interface type of the connected interface is set to access
[SW1-GigabitEthernet1/0/3] port default vlan 5
[SW1-GigabitEthernet1/0/3] quit

   # To configure VLANIF Interface , Realize interconnection with router .

[SW1] interface vlanif 5  // establish VLANIF5 Interface 
[SW1-Vlanif5] ip address 192.168.5.1 24  // To configure IP Address , this IP The address is connected to the router IP Address 
[SW1-Vlanif5] quit

   # Configure return route details , Realize the mutual visit between intranet segments .

[SW1] ip route-static 192.168.2.0 255.255.255.0 192.168.5.2  // Purpose IP yes 192.168.2.0/24 The network segment , The next jump is 192.168.5.2, The IP The address corresponds to SW2 Connection interface VLANIF Of IP Address 
[SW1] ip route-static 192.168.3.0 255.255.255.0 192.168.5.2  // Purpose IP yes 192.168.3.0/24 The network segment , The next jump is 192.168.5.2, The IP The address corresponds to SW2 Connection interface VLANIF Of IP Address 
[SW1] ip route-static 192.168.4.0 255.255.255.0 192.168.5.3  // Purpose IP yes 192.168.4.0/24 The network segment , The next jump is 192.168.5.3, The IP The address corresponds to SW3 Connection interface VLANIF Of IP Address 

   # Configure the default route , Realize the access from intranet segment to router .

[SW1] ip route-static 0.0.0.0 0.0.0.0 192.168.5.4  // Let's say the router and SW1 Connected to the interface IP The address is 192.168.5.4
  •   Check the configuration results

  PC1、PC2、PC3 They can visit each other , meanwhile PC Can communicate with routers .

 

版权声明
本文为[Nankong City]所创,转载请带上原文链接,感谢