| 设备名 | 地址 |
|---|---|
| PC1 | 10.65.1.1/16 |
| PC2 | 10.66.1.1/16 |
| PC3 | 10.65.1.3/16 |
| PC4 | 10.66.1.3/16 |
| LSW1 | 10.65.1.7/16 |
| LSW2 | 10.65.1.8/16 |
上面的/16表示对应的子网掩码是255.255.0.0
| 源设备名称 | 设备端口 | 端口描述 | 目标设备名称 | 设备端口 |
|---|---|---|---|---|
| LSW1 | E0/0/1 | 无 | LSW2 | 无 |
| LSW1 | E0/0/2 | 无 | PC1 | 无 |
| LSW1 | E0/0/3 | 无 | PC2 | 无 |
| LSW2 | E0/0/1 | 无 | LSW1 | 无 |
| LSW2 | E0/0/2 | 无 | PC3 | 无 |
| LSW2 | E0/0/3 | 无 | PC4 | 无 |
1、双击LSW1交换机,把LSW1改名为LSW1。
xxxxxxxxxxsystemun in ensysname LSW1
2、配置交换机的IP,由于交换机不能直接配置IP,所以先要进入交换机的虚拟子接口vlanif
xxxxxxxxxxint vlanif 1
3、为交换机配置IP
xxxxxxxxxxip add 10.65.1.7 16
4、双击LSW2交换机,把LSW2改名为LSW2。
xxxxxxxxxxsystemun in ensysname LSW2
5、配置交换机的IP,由于交换机不能直接配置IP,所以先要进入交换机的虚拟子接口vlanif
xxxxxxxxxxint vlanif 1
6、为交换机配置IP
xxxxxxxxxxip add 10.65.1.8 16
7、双击在LSW1交换机的[LSW1]视图下添加VLAN2、VLAN3
xxxxxxxxxxvlan batch 2 3
8、进入到对应端口,并且把端口加入到对应的VLAN。注意这些端口默认都是Hybrid模式, 我们把端口的模式改为access模式,注意access只能允许有一个VLAN
xxxxxxxxxxint e0/0/2port link-type accessport default vlan 2int e0/0/3port link-type accessport default vlan 3
9、双击在LSW2交换机的[LSW2]视图下添加VLAN2、VLAN3
xxxxxxxxxxvlan batch 2 3
10、进入到对应端口,并且把端口加入到对应的VLAN。注意这些端口默认都是Hybrid模式, 我们把端口的模式改为access模式,注意access只能允许有一个VLAN
xxxxxxxxxxint e0/0/2port link-type accessport default vlan 2int e0/0/3port link-type accessport default vlan 3int e0/0/2port link-type accessport default vlan 2int e0/0/3port link-type accessport default vlan 3
11、把两台交换机之间的中继链路的两个端口配置为Trunk模式,并且设置允许所有VLAN通过 双击LSW1交换机
xxxxxxxxxxint e0/0/1port link-type trunkport trunk allow-pass vlan all
双击LSW2交换机
xxxxxxxxxxint e0/0/1port link-type trunkport trunk allow-pass vlan all
只配置好PC机和交换机IP的情况下:使用PC1可以ping通PC3、LSW1、LSW2的IP
把两台交换机的VLAN配置好并且配置好上面的11步之后:使用PC1只可以ping通PC3 思考:为什么现在PC1ping不通LSW1、LSW2的IP呢 回答:虽然IP都属于同一网段,但是LSW1、LSW2和PC1的VLAN不同 原因:LSW1、LSW2的IP是在虚拟子接口vlanif配置的即VLAN是VLAN1,而PC1的VLAN是VLAN2
如何让PC1能够ping通LSW1、LSW2的IP呢 解决如下(为了减少笔记改动,我们这里就不做了,屏幕前的你可以尝试下面的步骤试一试): 1、双击LSW1,进入VLAN1,删掉LSW1的ip,然后进入VLAN2,把删掉的ip重新配置到VLAN2里面
xxxxxxxxxx进入VLAN1:int vlanif 1删掉ip:undo进入VLAN2:int vlanif 2