交换机和路由器配置过程总结
第一部分 交换机配置
一、概述
一层、二层交换机工作在数据链路层,三层交换机工作在网络层,最常见的是以太网交换机。交换机一般具有用户模式、配置模式、特权模式、全局配置模式等模式。
二、基本配置命令(CISCO)
Switch >enable 进入特权模式
Switch #config terminal 进入全局配置模式 Switch (config)#hostname 设置交换机的主机名
Switch(config)#enable password 进入特权模式的密码(明文形式保存) Switch(config)#enable secret 加密密码(加密形式保存) (优先) Switch(config)#ip default-gateway 配置交换机网关
Switch(config)#show mac-address-table 查看MAC地址
Switch(config)logging synchronous 阻止控制台信息覆盖命令行上的输入 Switch(config)no ip domain-lookup 关闭DNS查找功能 Switch(config)exec-timeout 0 0 阻止会话退出 使用Telnet远程式管理
Switch (config)#line vty 0 4 进入虚拟终端 Switch (config-line)# password 设置登录口令 Switch (config-line)# login 要求口令验证 控制台口令
switch(config)#line console 0 进入控制台口 switch(config-line)# password xx
switch(config-line)# 设置登录口令login 允许登录 恢复出厂配置
Switch(config)#erase startup-config Switch(config)delete vlan.dat Vlan基本配置
Switch#vlan database 进去vlan配置模式 Switch(vlan)#vlan 号码 name 名称 创建vlan及vlan名 Switch(vlan)#vlan号码 mtu数值 修改MTU大小
Switch(vlan)#exit 更新vlan数据并推出 Switch#show vlan 查看\\验证 Switch#copy running-config startup-config 保存配置 VLAN 中添加 删除端口
Switch#config terminal 进入全局配置 Switch(config)#interface fastethernet0/1 进入要分配的端口 Switch(config-if)#Switchport mode access 定义二层端口 Switch(config-if)#Switchport acces vlan 号 把端口分给一个vlan Switch(config-if)#switchport mode trunk 设置为干线
Switch(config-if)#switchport trunk encapsulation dot1q 设置vlan 中继协议
Switch(config-if)#no switchport mode 或 ( switchport mode access) 禁用干线 Switch(config-if)#switchport trunk allowed vlan add 1,2 从Trunk中添加vlans Switch(config-if)#switchport trunk allowed vlan remove 1,2 从Trunk中删除vlan Switch(config-if)#switchport trunk pruning vlan remove 1,2 ;从Trunk中关闭局部修剪 查看vlan信息 Switch#show vlan brief 所有vlan信息 查看vlan信息 Switch#show vlan id 某个vlan信息 注:Switch#show int trunk 查看trunk协议
注:可以使用default interface interface-id 还原接口到默认配置状态 Trunk
开启(no) ——将端口设置为永久中继模式
关闭(off) ——将端口设置为永久非中继模式, 并且将链路转变为非中继链路 企望(desirable)——让端口主动试图将链路转换成中继链路 自动(auto) ——使该端口愿意将链路变成中继链路 交换机显示命令:
switch#show vtp status 查看vtp配置信息 switch#show running-config 查看当前配置信息 switch#show vlan 查看vlan配置信息 switch#show interface 查看端口信息 switch#show int f0/0 查看指定端口信息 switch#dir flash: 查看闪存
switch#show version 查看当前版本信息
switch#show cdp cisco设备发现协议 (可以查看聆接设备) switch#show cdp traffic 杳看接收和发送的cdp包统计信息 switch#show cdp neighbors 查看与该设备相邻的cisco设备
switch#show interface f0/1 switchport 查看有关switchport的配置 switch#show cdp neighbors 查看与该设备相邻的cisco设备
三、模拟配置(一个实例)
图一:PC机IP地址、子网掩码、默认网关配置截图
图二:模拟网络拓扑结构图
图三:全局模式下对交换机进行配置
图四:查看VLAN当前配置信息
第二部分 路由器配置
一、环境搭建(借鉴网上的材料,通过自己配置也实现了同样的功能)
添加一个模块化的路由器,单击Packet Tracer 5.0的工作区中刚添加的路由器,在弹出的配置窗口上添加一些模块:
图五
默认情况下,路由器的电源是打开的,添加模块时需要关闭路由器的电源,单击图一箭
头所指的电源开关,将其关闭,路由器的电源关闭后绿色的电源指示灯也将变暗。
图六 添加所需要的模块
在“MODULES”下寻找所需要的模块,选中某个模块时会在下方显示该模块的信息。然后拖到路由器的空插槽上即可。
图八 添加一计算机,其RS-232与路由器的Console端口相连