题目如图所示:
四台终端对应网段1.1、2.1、3.上、4.1,分别对应
vlanl、Vlan2、 vlan3、 vlan4。
使不同网段的终端能够多互通。
一、配置終端电脑IP地址、子网掩码、网关
四台主机分别对应四个网段,所以划分成四个vlan从
左到右分別力:pcl、pc2、pc3、pc4。
二、配置SW1、SW2交换机
工配置SW1交换机到终端代码:
SW1交换机eQ/0/2口对应vlan1;eo/0/3口对应vlan2;
全部配置为access接口。
1 undo terminal monitor #取消设备提示信息
2system-view #进入系统试图
3sysname SW1 #将交换机名字改为SM1
4 /开始创建vIan/
5 vlan batch 2 to 4 #创建vlan2-4(因为交换机上所有接口默认属于vlanl,所以只需要创建vLan2- 4)
6 /划分vlan接口/
7 interface vlanif 1 (进入vlan1)
8 ip address 192.168.1.1 24(配置网关、子网掩码)
9 interface vlanif 2
10 ip address 192.168.2.1 24
11 interface vlanif 3
12 ip address 192.168.3.1 24
13 interface vlanif 4
14 ip address 192.168.4.1 24
15 /配置pc端口/
16 interface Etherneto/0/2 #进入接口
17 port link-type access #交换机上连接PC的接口类型为Access 类型接口
18 port default vlan 1 #配置接口的默认VLAN并同时 加入相应VLAN中
19 quit #退出
20 interface Etherneto/0/3 #进入接口
21 port link-type access #交换机上连接PC的接口类型为Access类型接口
22 port default vlan 2 #配置接口的默认VLAN并同时加入相应VLAN中
23 quit #退出
2、配置SW1交换机到SW3交换机代码SW1交换机到SW3为e0/0/1接口,配置为trunk接口。
1/配置交换机端口/
2 interface Etherneto/0/1 #进入按口
3 port link-type trunk #交换机上连接PC的接口类型为trunk类型
4 port trunk al1ow-pass vlan al1 #该接口允许所有vlan通过
(也可以写成 port trunk allow-pass vlan 1 to 4 #允许vlan2到v1an4通过)
5 quit
SW2交换机代码大体相同,只需要注意修改接口号等信息。
三、配置SW3交换机
SW3交换机两个接口全部连接交换机,所以全部配置为trunk接口。
1 undo terminal monitor
2 vlan batch 2 to 4 #创建vlan2到vlan4
3 interface vlanif 2
4 ip address 192.168.1.1 24
5 interface vlanif 2
6 ip address 192.168.2.1 24
7 interface vlanif 3
8 ip address 192.168.3.1 24
9 interface vlanif 4
10 ip address 192.168.4.1 24
11 interface GigabitEtherneto/0/1 #可简写为 int go/e/1
12 port link-type trunk
13port trunk allow-pass vlan all
14 interface GigabitEthernet0/0/2
15 port link-type trunk
16port trunk allow-pass vlan all
17 quit