Trunk overview and configuration method (theory and practice)

Preparing the environment: an installation GNS3-1.3.10, Wireshark, SecureCRT8.0 computer. And add a route map in GNS 3. (GNS3-1.3.10, Wireshark, SecureCRT8.0 installation and connection:
https://blog.51cto.com/14473285/2426223 ) (connected to the GNS. 3 Add the route map:
https://blog.51cto.com/14473285/2426262 )


What Trunk that? What is the role of Trunk? Through these two issues we have to understand the Trunk. I hope you can understand after reading this article to learn Trunk.


1. What is the Trunk?

In the previous article about the role of vlan, vlan configuration method, by vlan we can easily separate broadcast domains, to avoid broadcast storms, divided into multiple small networks in large network environments with a switch, each can be achieved when a small network that is a vlan, vlan on the same user on the same network segment communicate with each other, the interface a switch is limited when too many users use switch interface is not enough, I need to add a switch. Set in different switches in the same vlan, in theory, this vlan users can communicate with each other, then the vlan users how to communicate it? 1:
Trunk overview and configuration method (theory and practice)
(FIG. 1)
shown in Figure 1, the user we want to communicate with each other in the two switches VLAN 10, we need to access a link connecting two switches, while the two ends of this link to configure the interface to the same vlan 10, to communicate (if this interface is not configured at both ends of the link 10 to each other users vlan 10 vlan two switches, the user 10 in which two switches vlan It can not communicate, because they are not in a vlan in). So we want these two switches vlan 20, the user of the communication vlan 30 needs to access the two links are the same, and the interface are arranged to vlan 20, vlan 30 implemented in each channel, shown in Figure 2:
Trunk overview and configuration method (theory and practice)
(FIG. 2)
2, the two switches connected by links the plurality of devices communicate with each other in the same vlan need to add multiple links. Then the same problem, we switch interface is limited, each link also have to occupy the port, while there will be a large number of lines, then this method is not desirable, the drawbacks is relatively large.
Delivery of similar examples in reality, when we transport goods, in order to separate the cargo area of transport, we will give these goods labeled various labels, in order to achieve distinguished results. Vlan then, since each of a number of different vlan, can use only one relay link, transmit the data of different frames are marked with different vlan identifier, sent to another switch, and then transmitted through the vlan ID, realize the communication between the vlan, which is Trunk. 3:
Trunk overview and configuration method (theory and practice)
(FIG. 3)
Switched network, there are two types of links: the access link and relay link
1), the access link: usually belong to a VLAN, as shown above, the connection between the host switch domain link
2), following the link: can carry a plurality of VLAN, the link connected between the two switches in FIG. 3, the relay link is often
used to connect a switch to another switch, or to connect the switch to the router.


2, Trunk role

. 1), Trunk is a common link, data may be transmitted in all vlan Trunk, to reach across all vlan switch through a communication link.
2), Trunk adding identification data different according to the vlan vlan number transmitted, so that the same vlan communication across the switch.
Trunk as mentioned above is added to the identification data transmitted in accordance with different vlan vlan number, so that the same vlan communication across the switch. So vlan logo What? This identifies what it contains?


3, vlan logo

There are two Vlan identification:
. 1), the ISL (the Cisco proprietary protocol)
2), the IEEE 802.1Q
when using two identification process is actually encapsulated, the frame data is sent to the Trunk interface, the data frame will increase the encapsulation Trunk after sent to the other switch, the switch receives the data frame Trunk interface means, see the package decapsulation content identifier forwarded to the corresponding vlan in.
 ISL logo is a Cisco proprietary protocol, and the agreement to occupy 32 bytes, not recommended, nor here in the introduction.
 IEEE 802.1q protocol is a common protocol, so the device can be used, the agreement only four bytes, is an agreement that we often use in the following configuration will use this protocol to configure.


4, vlan inter-switch communication process

通过上面的讲述我们知道,vlan跨交换机通信时vlan发送数据到交换机,通过trunk接口时trunk根据不同的vlan号给数据帧加封装,发送到另一台交换机trunk接口,trunk接口接受到加封装的数据帧,通过解析封装的vlan号发送到相应的vlan中。如图:
Trunk overview and configuration method (theory and practice)
Vlan 10发送数据帧到交换机,这个时候就要经过trunk接口发送到另一台交换设备中,数据帧在经过trunk接口时,trunk接口根据vlan号给数据帧加封标识(而这个标识是vlan 10特有的标识),然后发送掉另一台交换机,在经过另一台交换就trunk接口时,trunk解析封装的标识内容,知道时vlan 10发送的数据,然后解除封装回复原始数据帧,发送给vlan 10接口,vlan10中的用户接收数据。


5、trunk的配置

经过上面的讲述大家应该大概了解了什么是trunk、trunk的作用与vlan跨交换机通讯的过程,下面我们就在GNS 3中实验配置trunk,达到在两台交换机中通过trunk实现同一vlan之间通讯。

1)、打开GNS 3,配置两台路由设备,并添加交换机业务单板,添加交换机磁盘空间,更改路由图标为交换机图标,更改路由名称为交换名称,方便我们识别(这里我不在详细介绍添加更改过程,会在关键点介绍,不会的可以参考【VLAN的原理、静态VLAN与配置方法(理论与实践):https://blog.51cto.com/14473285/2427648】中配置交换机)。如图
Trunk overview and configuration method (theory and practice)
在拓扑操作区添加两台路由设备。
Trunk overview and configuration method (theory and practice)
给路由设备添加交换机业务单板。
Trunk overview and configuration method (theory and practice)
给路由设备设置磁盘空间。
Trunk overview and configuration method (theory and practice)
更改图标为交换机图标。
Trunk overview and configuration method (theory and practice)
更改名称为交换机名称。(另一台路由设备同上更改设置)
Trunk overview and configuration method (theory and practice)
更改好的交换机设备。

2)、在拓扑操作区域添加4台PC主机(PC1、PC2、PC3、PC4),并与交换机设备连接,两台交换机连接,PC1、PC2连接sw1交换机分别连接交换机f1/0、f1/1接口,PC3、PC4连接sw2交换机反别连接交换机f1/0、f1/1接口,sw1交换机f1/2接连接sw2交换机f1/2接口,并点击显示接口图标显示接口。如图:
Trunk overview and configuration method (theory and practice)
在拓扑操作区添加PC设备。
Trunk overview and configuration method (theory and practice)
连接交换机与PC设备,PC1、PC2连接sw1交换机分别连接交换机f1/0、f1/1接口,PC3、PC4连接sw2交换机反别连接交换机f1/0、f1/1接口,sw1交换机f1/2接连接sw2交换机f1/2接口。
Trunk overview and configuration method (theory and practice)
点击显示接口图标,在拓扑操作区显示接口。
Trunk overview and configuration method (theory and practice)
通过书写工具在拓扑操作区标记出我们将要设置的vlan,与各个PC机的IP地址。

3)、点击开启全部设备,并双击设备图标打开设备配置揭界面,如图:
Trunk overview and configuration method (theory and practice)
点击开启按钮,开启全部设备。
Trunk overview and configuration method (theory and practice)
分别双击设备图标,打开设备配置界面,弹出设备配置窗口。

4)、在sw1交换机中配置vlan10、vlan20,并将PC机接口分别添加进vlan10、vlan20,在sw2交换机中同样操作(按拓扑区域标注出来的接口添加),并在PC机中添加IP地址(同样按拓扑操作区标注出来的添加),如图:
Trunk overview and configuration method (theory and practice)
选择sw1交换机,输入configure terminal进入全局模式,输入no ip routing关闭路由功能(因为我们是路由设备改的交换设备,所以我们就要关闭路由功能),然后选择SW2交换设备同样配置,这里我就不在截图。
Trunk overview and configuration method (theory and practice)
选择SW1交换机设备,在全局模式中输入vlan 10,20进行配置vlan10、vlan20,然后输入exit退出vlan,输入命令do show vlan-switch brief查看vlan,下面就会显示我们添加的vlan10、vlan20(选择SW2交换设备同样配置,这里我就不在截图)。
Trunk overview and configuration method (theory and practice)
在sw1交换机配置界面以全局模式输入命令interface fastethernet1/0进入f1/0接口模式,输入命令switch mode access进入链路接入模式,输入命令switch access vlan 10接口接入vlan 10,输入exit退出接口模式回到全局模式,继续输入interface fastethernet1/1进入f1/1接口模式,,输入命令switch mode access进入链路接入模式,输入命令switch access vlan 20接口接入vlan 20,输入命令do show vlan-switch brief查看valn列表,接口f1/0、f1/1成功接入vlan10、vlan20。在sw2交换机配置界面同样操作,不在截图。
Trunk overview and configuration method (theory and practice)
这里我先在sw2交换机中配置trunk,输入exit退出接口模式,输入interface fastethernet1/2,进入f1/2接口,输入命令switchport mode trunk配置接口为trunk模式,输入switchport trunk encapsulation dot1q配置trunk协议(这里我用了两个?来提示命令符),输入exit退出接口模式,输入命令do show interface fastethernet1/2 switchport 查看f1/2接口配置,在这里我们可以看到接口模式配置为trunk模式,并且可以通过所有vlan。配置完成后在sw1中重复配置,这里不在截图。

5)、配置完成交换机后,我们来配置PC1、PC2、PC3、PC4主机IP地址,PC1配置IP地址为192.168.10.10,PC2配置IP地址为192.168.10.20,PC3配置IP地址为192.168.10.30,PC4配置IP地址为192.168.10.40,如图:
Trunk overview and configuration method (theory and practice)
选择PC1主机,进入配置界面,输入命令 ip 192.168.10.10配置IP地址为192.168.10.10,稍等下面会显示配置信息(PC2、PC3、PC4同样操作,就不再截图)。

6)、配置完成后,我们通过ping命令来验证我们的配置结果,如图:
Trunk overview and configuration method (theory and practice)
我们在PC1中用ping命令来连接PC3成功建立通信,当用PC2中连接时无法通信,因为我们通过vlan的划分将PC1与PC3设置在同样vlan,并通过配置trunk跨交换机连接PC3,所以PC1和PC3正常通信,虽然和PC2处于同一交换机,但通过vlan的划分分隔开与PC2的广播域,所以PC1与PC2无法建立通信。
Trunk overview and configuration method (theory and practice)
我们在PC2中用ping命令成功与PC4建立连接,与PC3无法通信,理论与上面是相同。

Through this experiment we successfully communicate the same in different vlan switch by configuring the trunk.

Guess you like

Origin blog.51cto.com/14473285/2427896