Switch analog division VLAN configuration and TRUNK label configuration

Switch analog division VLAN configuration and TRUNK label configuration

Foreword:

What is a switch and what does it do

  1. A switch is a network device based on MAC address identification and capable of forwarding encapsulated data packets.
  2. The switch is also called a switching hub, which works at the data link layer (layer 2). This layer provides a frame composed of information bits. The frame consists of a header or header bit containing a start flag, addressing information And (for LAN) a 32-bit cyclic redundancy code (CRC). The role of CRC is to ensure the integrity of the frame when the information bits pass through the physical medium. The data link layer also provides link management. For Ethernet, the frame is transmitted when the channel is idle and stops when a collision is detected. In a token ring network. When a free token is received, the frame is transmitted. Therefore, the switch can not only synchronize, amplify, and reshape data, but also effectively filter short frames and fragments.
  3. The working process of the switch can be summarized as learning (mac table), broadcasting (addressing), forwarding (data), and updating (mac table)

1. Switch VLAN

1. What is vlan
VLAN (Virtual LAN), translated into Chinese is "Virtual LAN". A LAN can be a network composed of a few home computers, or an enterprise network composed of hundreds of computers. The LAN referred to by VLAN specifically refers to a network divided by routers—that is, a broadcast domain.

②In simple terms, the communication between users in the same VLAN is the same as in a local area network. The broadcasts in the same VLAN can only be heard by members of the VLAN, and will not be transmitted to other VLANs, so that it is not controlled. The occurrence of necessary broadcast storms. At the same time, if there is no routing, different VLANs cannot communicate with each other, thereby improving the information security between different working groups. Network administrators can comprehensively manage the exchange of information between different working groups within the network by configuring routes between VLANs.

③In simple terms, one switch is virtualized into multiple switches.
Insert picture description here

2. Divide VLAN
with Cisco switch as an example
Client host: 4
switches: Cisco 2960 switch One
VLAN: valn10 and vlan20
Effect : No. 1 and No. 2 hosts are VLAN 10 and No. 4 hosts are VLAN 20.

①Connect the four hosts to the switch with straight-through cables and configure them to the same network segment

Insert picture description here②Double -click the switch, enter the CLI, enter the switch command configuration window
Insert picture description here③The following is the command to divide VLAN

Switch>en             ###  进入特权模式
Switch#config t       ###  进入全局配置模式
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#vlan 10                      ###  创建vlan10
Switch(config-vlan)#vlan 20                 ###  创建vlan20
Switch(config-vlan)#interface fa0/1         ###  选择交换机的1网口进行配置
Switch(config-if)#sw ac vl 10               ###  把这个口的设备都规划到vlan10
Switch(config-if)#interface fa0/2           ###  选择交换机的2网口进行配置
Switch(config-if)#sw ac vl 10               ###  把这个口的设备都规划到vlan10
Switch(config-if)#interface fa0/3           ###  选择交换机的3网口进行配置
Switch(config-if)#sw ac vl 20               ###  把这个口的设备都规划到vlan20
Switch(config-if)#interface fa0/4           ###  选择交换机的4网口进行配置
Switch(config-if)#sw ac vl 20               ###  把这个口的设备都规划到vlan20
Switch(config-if)#exit                      ###  完成退出 

④Press to configure, exit the configuration mode to browse mode (the first mode) show vlan brieffor viewing.
Insert picture description here

Two. TRUNK

1. What is trunk

(1)传输 vlan 的作用。
(2)数据在trunk 链路上传输要打vlan标签,数据在离开trunk 链路时要脱vlan标签
(3)通过 trunk 的标签可以区分不同的流量。
(4)注意:trunk 工作在数据链路层(只能识别 mac 地址),不能实现不同 vlan 之间的通信

2. Configure the trunk
with Cisco switches as an example
Client host: 8
switches: Cisco 2960 switches 2
VLANs: vlan10 and vlan20
Effect : Use a straight-through cable to connect No. 1 switch and No. 2 switch. The host under vlan10 of switch 1 and vlan10 of switch 2 can pass through. The vlan20 in switch 1 and the host under vlan20 in switch 2 can pass through.

①Create 8 hosts and two switches, connect the two switches to fa0/24 ports with a straight-through cable, and connect the other host addresses as shown in the figure.
Insert picture description here③**We will configure switch 1 first.

switch>en                          ###  进入特权模式
switch#config t                    ###  进去全局配置模式
Enter configuration commands, one per line.  End with CNTL/Z.
switch(config)#hostname switchNo.1                    ###  把交换机的名字改下
switchNo.1(config)#interface fa0/24                   ###  针对交换机的24口进行配置
switchNo.1(config-if)#switch mode  trunk              ###  打上trunk的标签

switchNo.1(config-if)#                       
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/24, changed state to up

switchNo.1(config-if)#  exit                         ###退出

④Configure the No. 2 switch.

Switch>en                                       ###  进入特权模式
Switch#config t                                 ###  进入全局配置模式
Enter configuration commands, one per line.  End with CNTL/Z.
Switch(config)#hostname switchNo.2              ###  把交换机名字改成2号

switchNo.2(config)#vlan 10                      ### 创建vlan10
switchNo.2(config-vlan)#vlan 20                 ### 创建vlan20
switchNo.2(config-vlan)#interface fa0/5         ###对2号交换机5、6 、7 、8 端口划分到vlan
switchNo.2(config-if)#sw ac vl 10
switchNo.2(config-if)#interface fa0/6
switchNo.2(config-if)#sw ac vl 10
switchNo.2(config-if)#interface fa0/7
switchNo.2(config-if)#sw ac vl 20
switchNo.2(config-if)#interface fa0/8
switchNo.2(config-if)#sw ac vl 20


switchNo.2(config)#interface fa0/24           ### 对24端口进行配置
switchNo.2(config-if)#switch mode  trunk      ### 打上trunk标签
switchNo.2(config-if)#sexit

⑤Test :

1) Use 101 host to ping 106 host
Insert picture description here
2) Use 101
Insert picture description here
host to ping 107 host 3) Use 107 host to ping 104 host
Insert picture description here

End of experiment simulation

================================================= ================================================= ================================================= ================================================= ================================================= =============================================
Hard browsing and watching, if right You are helpful, please like it (σ゚∀゚)σ…:*☆

Guess you like

Origin blog.csdn.net/qq_26129413/article/details/110825261