1、实验目的
掌握交换机VLAN的基本操作
理解广播域的作用
2、拓扑与需求
拓扑:
需求:
1.设置SW1和SW2的设备名分别为SW1和SW2
2.按拓扑图所示配置PC1~4的IP地址
3.交换机按图示配置各终端所属的相应vlan,并且进行合理的配置使得同vlan间PC可以相互访问,不同vlan间PC不可以相互访问(不使用trunk)
4.在SW2上配置使得PC1可以使用Telnet远程管理到SW2,远程管理密码为SPOTO
3、配置与实现
- 设置SW1和SW2的设备名分别为SW1和SW2
SW1
Switch>enable
Switch#configure terminal
Switch(config)#hostname SW1
SW2
Switch>enable
Switch#configure terminal
Switch(config)#hostname SW2
- 按拓扑图所示配置PC1~4的IP地址
PC1
PC1>enable
PC1#configure terminal
PC1(config)#interface Ethernet0/0
PC1(config-if)#ip address 192.168.10.1 255.255.255.0
PC1(config-if)#no shutdown
PC2
PC2>enable
PC2#configure terminal
PC2(config)#interface Ethernet0/0
PC2(config-if)#ip address 192.168.20.1 255.255.255.0
PC2(config-if)#no shutdown
PC3
PC3>enable
PC3#configure terminal
PC3(config)#interface Ethernet0/0
PC3(config-if)#ip address 192.168.10.2 255.255.255.0
PC3(config-if)#no shutdown
PC4
PC4>enable
PC4#configure terminal
PC4(config)#interface Ethernet0/0
PC4(config-if)#ip address 192.168.20.2 255.255.255.0
PC4(config-if)#no shutdown
- 交换机按图示配置各终端所属的相应vlan,并且进行合理的配置使得同vlan间PC可以相互访问,不同vlan间PC不可以相互访问(不使用trunk)
SW1
SW1(config)#interface range ethernet 0/0-1
SW1(config-if-range)#switchport mode access
SW1(config-if-range)#switchport access vlan 10
% Access VLAN does not exist. Creating vlan 10
SW1(config-if-range)#interface range ethernet 0/2-3
SW1(config-if-range)#switchport mode access
SW1(config-if-range)#switchport access vlan 20
% Access VLAN does not exist. Creating vlan 20
当接口划入的VLAN不存在时,IOS会自动创建
使用 range 可以批量操作多个接口
SW2
SW2(config)#interface range ethernet 0/0-1
SW2(config-if-range)#switchport mode access
SW2(config-if-range)#switchport access vlan 10
% Access VLAN does not exist. Creating vlan 10
SW2(config-if-range)#interface range ethernet 0/2-3
SW2(config-if-range)#switchport mode access
SW2(config-if-range)#switchport access vlan 20
% Access VLAN does not exist. Creating vlan 20
4. 在SW2上配置使得PC1可以使用Telnet远程管理到SW2,远程管理密码为SPOTO
SW2
配置SVI(交换虚拟接口,可用于管理交换机)
SW2(config)#interface vlan 10
SW2(config-if)#ip address 192.168.10.3 255.255.255.0
SW2(config-if)#no shutdown
配置Enable密码为SPOTO
SW2(config)#enable password SPOTO
配置允许Telnet,密码为SPOTO
SW2(config)#line vty 0 4
SW2(config-line)#transport input telnet
SW2(config-line)#password SPOTO
SW2(config-line)#login