一、基本配置前准备:开启配置之旅
在开始配置之前,首先需要登录到交换机。你可以使用Console线连接交换机,通过终端软件(如PuTTY、SecureCRT)进行本地登录;也可以通过Telnet或SSH进行远程登录。登录后,进入特权模式和全局配置模式,为后续的配置做好准备。
CiscoSwitch> enableCiscoSwitch# configure terminal
二、创建VLAN并分配端口:构建网络基础
VLAN(虚拟局域网)的划分是三层交换机配置的关键步骤之一。通过创建不同的VLAN,可以将网络划分为多个逻辑子网,提高网络的安全性和管理效率。例如,我们可以创建VLAN 10(销售部门)和VLAN 20(工程部门):
Switch(config)# vlan 10Switch(config-vlan)# name SalesSwitch(config-vlan)# exitSwitch(config)# vlan 20Switch(config-vlan)# name EngineeringSwitch(config-vlan)# exit
接下来,将相应的端口划分到对应的VLAN中。假设将FastEthernet0/1端口分配给VLAN 10:
Switch(config)# interface FastEthernet0/1Switch(config-if)# switchport mode accessSwitch(config-if)# switchport access vlan 10Switch(config-if)# exit
三、启用三层路由功能并配置SVI:实现跨VLAN通信
为了让不同VLAN之间的设备能够相互通信,需要启用三层交换机的路由功能,并为每个VLAN配置一个交换虚拟接口(SVI),作为该VLAN的默认网关。例如:
Switch(config)# ip routingSwitch(config)# interface Vlan10Switch(config-if)# ip address 192.168.10.1 255.255.255.0Switch(config-if)# no shutdownSwitch(config-if)# exitSwitch(config)# interface Vlan20Switch(config-if)# ip address 192.168.20.1 255.255.255.0Switch(config-if)# no shutdownSwitch(config-if)# exit
四、配置静态路由(可选):拓展网络边界
如果网络中存在多个三层设备,可以通过配置静态路由来实现设备之间的互通。例如,添加一条静态路由,指定去往192.168.30.0/24网络的下一跳地址为192.168.10.254:
Switch(config)# ip route192.168.30.0255.255.255.0192.168.10.254
五、安全与管理配置(推荐):保障网络稳定
为了确保交换机的安全和便于管理,还需要进行一些额外的配置。例如,设置管理IP地址、默认网关、主机名和登录密码等:
Switch(config)# interface Vlan1Switch(config-if)# ip address 192.168.1.100 255.255.255.0Switch(config-if)# no shutdownSwitch(config)# ip default-gateway 192.168.1.1Switch(config)# hostname SW-CoreSW-Core(config)# enable secret mypasswordSW-Core(config)# line vty 0 4SW-Core(config-line)# loginSW-Core(config-line)# password telnetpassSW-Core(config-line)# exit
最后,别忘了保存你的配置:
SW-Core#copyrunning-config startup-config
六、验证命令:确保配置无误
完成配置后,使用以下命令来验证配置是否正确:
|
命令 |
功能 |
|---|---|
|
show ip interface brief |
查看接口IP地址状态 |
|
show vlan brief |
查看VLAN及端口分配 |
|
show ip route |
查看路由表 |
|
ping 192.168.10.10 |
测试连通性 |
|
traceroute 192.168.20.10 |
查看路径 |





发表回复