三层交换机
1.给vlan配置IP
在连接PC的交换机上划分3个VLAN,并按图-1把PC机加入相应VLAN
tarenasw-3L (config-vlan)#vlan 2 //vlan1是默认VLAN,不需创建
tarenasw-3L (config-vlan)#vlan 3
tarenasw-3L (config-vlan)#exit
tarenasw-3L (config)#interface f0/1
tarenasw-3L (config-if)#switchport access vlan 1
tarenasw-3L (config-if)#interface f0/2
tarenasw-3L (config-if)#switchport access vlan 2
tarenasw-3L (config-if)#interface f0/3
tarenasw-3L (config-if)#switchport access vlan 3
查看划分完的VLAN信息
VLAN1是默认VLAN,不需单独创建,也不能改名。所有端口默认都在VLAN1中。
tarenasw-2L#show vlan
VLAN Name Status Ports
---- ----------------------- --------- ---------------------
1 default active Fa0/1, Fa0/4, Fa0/5, Fa0/6
Fa0/7, Fa0/8, Fa0/9, Fa0/10
Fa0/11, Fa0/12, Fa0/13, Fa0/14
Fa0/15, Fa0/16, Fa0/17, Fa0/18
Fa0/19, Fa0/20, Fa0/21, Fa0/22
Fa0/23, Fa0/24, Gig1/1, Gig1/2
2 vlan0002 active Fa0/2
3 vlan0003 active Fa0/3
步骤三:为vlan1、vlan2、vlan3分别设置管理IP并开启三层交换机路由功能
tarenasw-3L #enable
tarenasw-3L #configure terminal
tarenasw-3L (config)#ip routing //开启三层交换机路由功能
tarenasw-3L (config)#interface vlan 1 //给三层交换机上的vlan123配置IP地址。
tarenasw-3L (config-if)#ip address 192.168.1.254 255.255.255.0
tarenasw-3L (config-if)#no shutdown
tarenasw-3L (config-if)#exit
tarenasw-3L (config)#interface vlan 2
tarenasw-3L (config-if)#ip address 192.168.2.254 255.255.255.0
tarenasw-3L (config-if)#no shutdown
tarenasw-3L (config-if)#exit
tarenasw-3L (config)#interface vlan 3
tarenasw-3L (config-if)#ip address 192.168.3.254 255.255.255.0
tarenasw-3L (config-if)#no shutdown
步骤四:给客户端配置IP地址并测试网络连通性如图-2图-3所示
在PC1三上测试网络连通性
PC1>ping 192.168.3.1
Pinging 192.168.3.1 with 32 bytes of data:
Reply from 192.168.3.1: bytes=32 time=11ms TTL=128
Reply from 192.168.3.1: bytes=32 time=1ms TTL=128
Reply from 192.168.3.1: bytes=32 time=1ms TTL=128
Reply from 192.168.3.1: bytes=32 time=4ms TTL=128
Ping statistics for 192.168.3.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 1ms, Maximum = 11ms, Average = 4ms
=============================================================================
2.给端口配置IP地址。
tarenasw-3L (config)#interface f0/1
tarenasw-3L (config-if)#no switchport
tarenasw-3L (config-if)#ip addresses IP 子网掩码
tarenasw-3L (config-if)#no shutdown
tarenasw-3L (config)#interface f0/2
tarenasw-3L (config-if)#no switchport
tarenasw-3L (config-if)#ip addresses IP 子网掩码
tarenasw-3L (config-if)#no shutdown
tarenasw-3L (config)#interface f0/3
tarenasw-3L (config-if)#no switchport
tarenasw-3L (config-if)#ip addresses IP 子网掩码
tarenasw-3L (config-if)#no shutdown
tarenasw-3L (config)#ip routing //开启三层交换机路由功能