第一部分交换机配置一、基础配置1、模式进入Switch>Switch>enSwitch#configSwitch(Config)#interface ethernet 0/22、配置交换机主机名命令:hostname <主机名>3、配置交换机IP地址Switch(Config)#interface vlan 1Switch(Config-If-Vlan1)#ip address 10.1.128.251 255.255.255.0Switch(Config-If-Vlan1)#no shut4、为交换机设置Telnet授权用户和口令:telnet-user <用户名>password {0|7} <密码>例:Switch(Config)#telnet-user test password 0 test5、为交换机设置Web授权用户和口令:web-user <用户名>password {0|7} <密码>例:Switch(Config)#web-user admin password 0 digital6、设置系统日期和时钟:clock set <HH:MM:SS> <YYYY/MM/DD>7、设置退出特权用户配置模式超时时间exec timeout <minutes > //单位为分钟,取值范围为0~3008、保存配置:write9、显示系统当前的时钟:Switch#show clock10、指定登录用户的身份是管理级还是访问级Enable [level {visitor|admin} [<密码>]]11、指定登录配置模式的密码:Enable password level {visitor|admin}12、设置端口的速率和双工模式(接口配置模式下)命令:speed-duplex {auto | force10-half | force10-full | force100-half | force100-full | {{force1g-half | force1g-full} [nonegotiate [master | slave]] } }no speed-duplex二、单交换机VLAN划分1、VLAN基本配置(1)新建VLAN:vlan <vlan-id>(2)命名VLAN:name <vlan-name>(3)为VLAN 分配交换机端口Switch(Config-If-Vlan1)#switchport interface Ethernet 0/2(4)设置Trunk 端口允许通过VLAN:Switch(Config-ethernet0/0/5)#switchport trunk allowed vlan 1;3;5-202、划分VLAN:(1)进入相应端口:Switch(config)#interface Ethernet 0/2(2)修改模式:Switch(Config-ethernet0/0/5)switchport mode access(3)划分VLAN:Switch(Config-ethernet0/0/5)#switchport access vlan 4三、跨交换机VLAN划分(两台交换机作相同操作)1、新建VLAN2、划分VLAN3、修改链路模式(1)进入相应端口:Switch(config)#interface Ethernet 0/1(2)修改模式:Switch(config-if)#switchport mode trunk四、VLAN间主机的通信1、新建VLAN2、划分VLAN3、修改链路模式(1)进入相应端口:Switch(config)#interface Ethernet 0/1(2)修改模式:Switch(config-if)#switchport mode trunk注意:如果是三层交换机,在修改模式先封装802.1协议:Switch(config-if)#switchport trunk encapsulation dot1q4、建立VLAN子接口(1)、进入VLAN接口模式:Switch(config)#interface vlan 2(2)、设置VLAN子接口地址:Switch(config-if)#ip address 192.168.0.1 255.255.255.0(3)、打开端口:Switch(config-if)#no shutdown5、设置各主机IP地址、子网掩码、网关注意:(1)各主机IP地址应与其所在的VLAN在同一网段。
(2)192.168.0.1/24中的“24”表示子网掩码为3个255。
(3)主机所在的VLAN的子接口地址就是主机的网关。
五、端口安全配置1、启用和禁用端口安全功能:启用:Switch(config-if)# switchport port-security禁用:Switch(config-if)# no switchport port-security2、设置接口上安全地址的最大个数(1~128)Switch(config-if)#switchport port-security maximum 13、设置处理违例的方式Switch(config-if)#switchport port-security violation shutdown4、手工配置接口上的安全地址Switch(config-if)#switchport port-security mac-address 00d0.d373.B0605、查看安全配置:Switch#show port-security六、设置广播风暴抑制功能Switch(Config)#broadcast-suppression <packets>参数:<packets>代表每秒钟允许通过的广播数据报的个数,取值范围为1~262143。
七、端口聚合1、创建port group:Switch(Config)#port-group 1//数字范围1-162、把物理端口加入组:Switch(Config-Ethernet0/0/1)#port-group 1 mode active3、进入port-channel 配置模式:Switch(Config)#interface port-channel 1第二部分路由器配置一、路由器基本配置1、基础配置Router>en //进入特权模式Router#config //进入全局配置模式Router(Config)#hostname DCR //定义路由器的名字为DCRDCR (Config)#enable password //特权用户的口令Current password:出厂配置无特权用户的口令Newpassword:****** //输入口令,如“123456”Confirmnewpassword:****** //确认口令。
DCR (Config)#telnet admin password 7 admin //配置远程用户的口令Router(Config-Serial2/0)#physical-layer speed 64000//配置时钟频率二、静态路由配置1、命令:ip route <目的IP> <子网掩码> {<接口名称>|<下一跳IP地址>} [<路由优先级>]<preference>为路由优先级,取值范围为1~255,preference的值越小优先级越高。
Router(config)#ip route 1.1.1.0 255.255.255.0 2.1.1.12、默认路由ip route 0.0.0.0 0.0.0.0{<接口名称>|<下一跳IP地址>} [<路由优先级>]三、单臂路由1、打开端口:2、进入子接口配置IP地址,并封装dot1q协议到对应的VLAN。
Router_config#interface f0/0.1Router(config_f0/0.1)#ip address 192.168.100.1 255.255.255.0Router(config_f0/0.1)#encapsulation dot1Q 100 //封装dot1Q到VLAN 100Route(config_f0/0.1)#exitRouter_config#interface f0/0.2Router(config_f0/0.2)#ip address 192.168.200.1 255.255.255.0Router(config_f0/0.2)#encapsulation dot1Q 200 //封装dot1Q到VLAN 200Router(config_f0/0.2)#exit四、动态路由协义配置1、RIP协议在DCR路由器上运行RIP路由协议的基本配置很简单,通常只需打开RIP开关、使能发送和接收RIP数据报,即按RIP缺省配置发送和接收RIP数据报(DCR路由器缺省发送RIP-II接收RIP-I和RIP-II)(1)启动RIP协议:Router(config)#router rip(2)配置RIP协义版本:Router(config-router-rip)#version 2(3)配置接口使能发送/接收RIP数据报Router(config-serial2/0)#ip rip work(4)配置引入路由(缺省路由权值、配置RIP中引入其它协议的路由)❶缺省路由权值:Router(config-router-rip)#default-metric 3 //权值可设1-16❷路由重分发:redistribute { static | ospf } [ metric <value> ]缺省情况下,路由器不引入其它路由。
<value>值指定以多大的路由权值引入路由,不指定则按缺省路由权值(default-metric)引入,取值范围1~16。
Router(config-router-rip)#redistribute ospf metric 52、OSPF协议(1)启动OSPF协议(必须)Router(Config)#router ospf(2)配置运行OSPF路由器的ID号(可选)router id <router_id><router_id>为路由器ID号,以IP地址表示,点分十进制格式。