VLAN与Trunk配置:
问题
参照如下网络拓扑实现跨交换机的相同vlan的通信。
使用eNSP搭建实验环境
通过eNSP搭建如上环境,购买2台交换机和4台PC机,并如图连接。
分别给PC1-2-3-4机配上IP地址和子网掩码并且如图标注好自己的网段和IP地址,保证试验的时候看起来会更加方便。
![VLAN与Trunk配置](https://s1.51cto.com/images/blog/201905/01/00b39e3ec7a06a95ffed7b07065493d1.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![VLAN与Trunk配置](https://s1.51cto.com/images/blog/201905/01/295b9b000cfb97383032b5bc10b7c074.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![VLAN与Trunk配置](https://s1.51cto.com/images/blog/201905/01/ffae17fc4e309fcd54eb1708fda7fd89.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
![VLAN与Trunk配置](https://s1.51cto.com/images/blog/201905/01/7168f95a99cb27be41126341696ea181.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
如上图所示,把
PC1的IP地址配置为:192.168.1.1,子网掩码为255.255.255.0.
PC2的IP地址配置为:192.168.1.2,子网掩码为255.255.255.0.
PC3的IP地址配置为:192.168.1.3,子网掩码为255.255.255.0.
PC4的IP地址配置为:192.168.1.4,子网掩码为255.255.255.0.
![VLAN与Trunk配置](https://s1.51cto.com/images/blog/201905/01/6cc444a98d567ad7c2e81fbcd48ec3e6.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
此时,看到这些红点的时候,证明咱们刚才购买并配置信息的设备没有开机
![VLAN与Trunk配置](https://s1.51cto.com/images/blog/201905/02/31f5ca4a5cf05fa118d04af4be083d5e.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
此时需要把设备都框选,点击右键-开启设备。
![VLAN与Trunk配置](https://s1.51cto.com/images/blog/201905/02/e6763d9d18fda7d2f55dbb03da1e1b08.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
此时能看到绿色的点,证明所有设备开启正常并且连通成功。
以上这些都是都是以一些特别基本的环境搭配,下面就是通过输入指令配置交换机,所以是比较重点的,希望看到本片文章的老师和同学能仔细认真的看。
所有新手需要熟练使用Tab键做补齐工作。
配置第一台交换机sw1:
![VLAN与Trunk配置](https://s1.51cto.com/images/blog/201905/02/0a1151820845e7821b9ce9a4600c784b.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
[sw1]-vlan batch 5 10 创建多个不连续的vlan 5 和10
[sw1]-interface Ethernet0/0/1 进入0/0/1接口配置模式
[sw1]-Ethernet0/0/1]port link-type access 设置0/0/1端口为接入模式
[sw1]-Ethernet0/0/1]port default vlan 5 把端口加入vlan5
[sw1]-interface Ethernet0/0/2 进入0/0/2接口配置模式
[sw1]-Ethernet0/0/2]port link-type access 设置0/0/2端口为接入模式
[sw1]-Ethernet0/0/2]port default vlan 10 把端口加入vlan10
[sw1]-interface Ethernet0/0/3 进入0/0/3接口配置模式
[sw1]-Ethernet0/0/3]port link-type trunk 设置0/0/3端口为trunk模式
[sw1]-Ethernet0/0/3]port trunk allow-pass vlan 5 10 允许所有vlan数据通过
第一台交换机配置完毕。
下面配置第二换机sw2:
![VLAN与Trunk配置](https://s1.51cto.com/images/blog/201905/02/93a9bf621c54e7db8dcd20f6750a78bd.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
[sw2]-vlan batch 5 10 创建多个不连续的vlan 5 和10
[sw2]-interface Ethernet0/0/1 进入0/0/1接口配置模式
[sw2]-Ethernet0/0/1]port link-type access 设置0/0/1端口为接入模式
[sw2]-Ethernet0/0/1]port default vlan 5 把端口加入vlan5
[sw2]-interface Ethernet0/0/2 进入0/0/2接口配置模式
[sw2]-Ethernet0/0/2]port link-type access 设置0/0/2端口为接入模式
[sw2]-Ethernet0/0/2]port default vlan 10 把端口加入vlan10
[sw2]-interface Ethernet0/0/3 进入0/0/3接口配置模式
[sw2]-Ethernet0/0/3]port link-type trunk 设置0/0/3端口为trunk模式
[sw2]-Ethernet0/0/3]port trunk allow-pass vlan 5 10 允许所有vlan数据通过
以上两台路由器配置完毕。
测试
VLAN 5的2台主机能够互通,VLAN 10的2台主机能够互通。
VLAN 5与VLAN 10的2台主机不能够互通。
![VLAN与Trunk配置](https://s1.51cto.com/images/blog/201905/02/1fbd0beae854590f4b4b935214013884.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
PC1 ping PC3能够ping通 ,成功。
![VLAN与Trunk配置](https://s1.51cto.com/images/blog/201905/02/8437c59e6a9c610542ff927bded3ac70.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
PC2 ping PC4能够ping通 ,成功。
![VLAN与Trunk配置](https://s1.51cto.com/images/blog/201905/02/84d74170156dcf732330e99032002371.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
PC1 ping PC2不能ping通,因为不属于同一网段。
![VLAN与Trunk配置](https://s1.51cto.com/images/blog/201905/02/ecf994e781b0a72c7bd582e4ccc120e1.png?x-oss-process=image/watermark,size_16,text_QDUxQ1RP5Y2a5a6i,color_FFFFFF,t_100,g_se,x_10,y_10,shadow_90,type_ZmFuZ3poZW5naGVpdGk=)
PC3 ping PC4不能ping通,因为不属于同一网段。
至此,VLAN与Trunk配置实验到此结束。
这个小实验也是第一次做,难免会发生一些小错误,希望您谅解。
如果您在看到文章的同时要是发现问题,希望您第一时间告知,我们共通成长。
感谢您的观看。