CCIE思科教育培训 CCIE培训

Cisco交换路由配置命令及说明

Cisco交换路由配置命令

【交换机命令总结】

【交换机口令设置】:
switch>enable    进入特权模式       
switch#config terminal    进入全局配置模式
switch(config)#hostname <hostname>    设置交换机的主机名
switch(config)#enable secret xxx    设置特权加密口令
switch(config)#enable password xxa    设置特权非密口令

使用Telnet远程式管理
switch(config)#interface vlan 1    进入vlan 1
 switch(config-if)#ip address <IP> <mask>    设置IP地址
switch(config-if)#ip default-gateway <IP>    设置默认网关
switch(config)#line vty 0  4    进入虚拟终端
switch(config-line)#login    允许登录
switch(config-line)#password xx    设置登录口令
switch#exit    返回命令
 控制台口令
switch(config)#line console 0    进入控制台口
switch(config-line)#login    允许登录
switch(config-line)#password xx    设置登录口令
switch#exit    返回命令
 基本接口配置
switch(config)#interface f0/1    进入f0/1接口
switch(config-if)#duplex full    配置全双工模式
switch(config-if)#speed 100    配置速率
switch(config-if)#description to *****    接口描述
switch(config)#ip domain-name  ***.com    设置或名服务器
switch(config)#mac-address-table aging-time <10-1000000>    设置mac表超时时间
switch#write    保存配置信息
switch#copy running-config startup-config    保存当前配置nvram
 switch#erase startup-config    清除配置文件
 交换机VLAN设置:
switch#vlan database    进入VLAN设置
switch(vlan)#vlan 2    建VLAN 2
 switch(vlan)#name 名字    建VLAN 2的名称
switch(vlan)#no vlan 2    删vlan 2
注:删除vlan时原属于此vlan的端口处于非激活状态,直到重新分配为止
switch(config)#int f0/1    进入端口1
 switch(config-if)#switchport mode access    当前端口工作莫试
switch(config-if)#switchport access vlan 2    当前端口加入vlan 2
 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中删除vlans
 switch(config-if)#switchport trunk pruning vlan remove 1,2 ;从Trunk中关闭局部修剪
 以太网通道配置
switch(config)#interface range fasternet0/1 - 2    将fasternet0/1和0/2 口捆绑 (成双不成单)
switch(config-if)#channel-group 1 mode on    配置以太通道模式
switch(config-if)#port-channel load-balance {dst-mac | src-mac}在链路间实现负载均衡
switch#show etherchannel  1  summary    查看通道信息
switch#show etherchannel  load-balance    查看通道信息
vtp配置
switch(config)#vtp domain <name>    设置vtp域名
switch(config)#vtp password <word>    设置vtp密码
switch(config)#vtp mode server    设置vtp服务器模式
switch(config)#vtp mode client    设置vtp客户机模式
switch(config)#vtp mode transparent    设置vtp 透明模式
switch(config)#vtp version <1>  <2>    设置vtp版本
switch(config)#vtp pruning    启用vtp修解
switch(config)#no vtp pruning    关闭vtp修解
 注:要想从vtp中减少一台交换机只需将该交换机vtp 名更改
 生成树stp:
switch(config)#spanning-tree vlan <vlan-list>    启用stp生成树(基于vlan)
switch(config)#spanning-tree vlan <vlan-list> root primary    指定根交换机(基于vlan)
switch(config)#spanning-tree vlan <vlan-list> root secondary    指定备用根交换机(基于vlan)
switch(config)#spanning-tree vlan <vlan-list> priority <0-65535> 指定交换机优先级(基于vlan)
switch(config)#no spanning-tree vlan <vlan-list> priority    将交换机的优先级恢复默认值(基于vlan)
switch(config-if)#spanning-tree vlan <vlan-list> cost <0-200000000> 指定端口成本(起用trunk的端口模式下)
switch(config-if)#spanning-tree vlan <vlan-list> port-prioty <0-255> 指定交换机端口优先级(基于vlan)
switch(config-if)#spanning-tree portfast    配置速端口(连接终端设备的端口状态)如pc机
switch(config)#spanning-tree uplinkfast    配置上行速端口
 注:在配置上行速端口前要先将基于vlan上的网桥优先级,网桥成本恢复默认值。起用了该命令后在进行优先级更改,
switch(config)#spanning-tree vlan <vlan-list> hello-time <1-10> 配置交换机hello时间(基于vlan)
switch(config)#spanning-tree vlan <vlan-list> forward-time <4-30> 修改转发延迟计时器(基于vlan)
switch(config)#spanning-tree vlan <vlan-list> max-time <6-40>    修改最大老化时间(基于vlan)
 注:vlan为可选参数,当没有该参数时将修改所有vlan网桥的优先级\及所有的vlan端口成本
switch#show spanning-tree summery    检测vlan生成树配置
switch#show spanning-tree vlan <vlan-id> detail    浏览详细生成树配置信息
switch#show spanning-tree interface <int-id> detail    浏览详细生成树端口配置信息
 交换机显示命令:
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 mac-address-table aging-time    查看mac超时时间
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设备

【2950交换机密码恢复】
 拨下交换机的电源线
 用手按在mode按键上,插上电源线。
 看到出现  flash_init  load_helper  boot    switch:  画面时松开mode键
 在switch:后执行flash_init命令查看flash中的文件
 把config.text 文件改名为"config.old    rename flash:config.text flash:config.old
执行boot命令启动交换机
 交换机出现是否进入配置的对话, 执行no命令
 进入特权模式查看flash文件      执行enable  在switch#show flash:
把config.old改为config.text            rename flash:config.old flash:config.text 
把config.text考入系统的running-config
 copy flash:config.text system:running-config
重新设置密码并存盘



【路由器命令总结】

路由器命令状态:
>>  路由器处于rxboot状态,开机60秒内按ctrl+break可进入此状态用于软件升级和手工引导.
router>用户命令状态,只能查看一些基本信息
router#特权命令状态
router(config)#全局设置状态
router(config-if)#接口设置状态
 路由器口令设置:
router>enable    进入特权模式
router#config terminal    进入全局配置模式
router(config)#hostname <hostname>    设置交换机的主机名
router(config)#enable secret xxx    设置特权加密口令
router(config)#enable password xxx    设置特权非密口令
 控制台口令
router(config)#line console 0    进入控制台口
router(config-line)#login    要求口令验证
router(config-line)#password xx    设置登录口令
 使用Telnet远程式管理
router(config)#line vty 0 4    进入虚拟终端
router(config-line)#login    要求口令验证
router(config-line)#password xx    设置登录口令

路由器基本配置:
router(config)#int s0/0  <f0/1>    进入Serail接口
router(config-if)#ip address <ip> <netmask>    设置IP地址
router(config-if)#ip address <ip><netmask> second      设置第二个IP
 router(config-if)#description to *****    接口描述
router(config-if)#no shutdown    激活当前接口
router(config-if)#clock rate 64000    设置同步时钟 (仅用于串口)
router(config-if)#clock rate 64    设置带宽    (仅用于串口)
router(config-if)#ip ospf authentication-key 口令    为ospf设置认证(不加密)
router(config-if)#ip ospf message-digest-key <钥匙号>md5 口令          为ospf设置md5认证
router(config-if)#no ip ospf message-digest-key <钥匙号>md5 口令        为ospf设置md5认证
router(config)#int f0/0.1                进入子接口
router(config-subif.1)#ip address <ip><netmask>      设置子接口IP
 router(config-subif.1)#encapsulation dot1q <isl>序号    绑定vlan中继协议 (vlan三层路由)
注:  dot1q 为IEEE802.1Q标准          isl为 思科专用
router#write          保存配置信息
router#copy running-config startup-config    保存当前配置nvram
 router#debug ip rip<events>        监测配置
router#no debug ip all        关闭监测配置
router#reload    重新起动
router#erase startup-config    清除配置文件
 路由器显示命令:
router#show run        显示配置信息
router#show interface        显示接口信息
router#show ip route    显示路由信息
router#show ip arp    显示arp缓存
router#show cdp nei    显示邻居信息
 静态路由:
router(config)#ip route <ip-address> <subnet-mask> <下一跳><distance>        命令格式
 注: distance 改变默认管理开销
router(config)#ip route 0.0.0.0 0.0.0.0 <下一跳>      默认路
router(config)#ip classless    数据包不能转发时匹配给默认路由
router(config)#no ip classless    数据包不能转发时弃掉
 动态路由rip:
router(config)#ip routing                          启动路由转发
router(config)#router rip                      启动RIP路由协议。
router(config-router)#network <net-id>    设置发布路由
router(config-router)#version <1-2>    设置rip版板
router(config-router)#no auto-summary    禁用自动聚合(当子网不连续时)v2版本
router(config-if)#ip rip send version 1    允许v2给v1发送报文(运行v2的接口模式下)
router(config-if)#ip rip receive version 1    允许v2接收v1的报文(运行v2的接口模式下)
router(config-if)#ip rip send version 1 2    同时发送v1, v2报文(在运行v2的接口模式下)
 注: 当运行rip version 2 的路由器和运行rip version 1的路由器相联时,可以通过接口兼容性开关来实现
 也可以在一个接口上同时发送和接收v1, v2 两个版本
 动态路由ospf:
router(config)#router ospf <process-id>    启用ospf进程
router(config-router)#network <net-id> <返掩码>area <area-id>    启用ospf进程
 例: network 192.168.10.2  0.0.0.0 area 0只在某一接口上启用sopf
   network 192.168.0.0  0.0.255.255 area 0将属于192.168.0.0网段的所有接口启用ospf
 router(config-router)#network redistribute rip metric <n>    将rip路由重分发到ospf区域
router(config-router)#area <area-id> authentication message-digest    在区域中启用md5认证
router(config-router)#area <area-id> authentication    在区域中启用认证(不加密)
router(config-router)#area <area-id> stub    使该区域成为stub区域
router(config-router)#area <area-id> default-cost <n>    改变ABR通告的默认路由(默认为1)
 router(config-router)#area <area-id> stub no-summary    使该区域成为完全stub区域(在ABR上配置)
router(config-router)#area <area-id> nass    使该区域成为nass区域
router(config-router)#area <area-id> nass no-summary    使nass区域不接收lsa3,lsa4(在ABR上配置)
router(config-router)#area <area-id> stub no-redistribution default-information-originate
注: 使nass区域不接收lsa5,lsa7    但接收lsa3,lsa4,(在ABR上配置)
router(config-router)#area <area-id> stub no-redistribution no-summary   
注: 使nass区域不接收lsa3,lsa4,lsa5,lsa7(在ABR上配置)
router(config-router)#area <area-id> range <net-id><正掩码>            区域间汇总
router(config-router)#area <area-id> range <net-id><正掩码>        null0    防止汇总过大而导至错误
 注: 地址汇总可以减少LSA泛滥的数量,屏蔽一些网络不稳定的细节,从而节省资源
router(config-router)#summary-address <net-id> <正掩码>            外部路由汇总(不同自治系统间汇总)
router(config-router)#area <area-id> virtual-link <route-id>            虚链路配置(中间区域两个ASB上配置
router(config-router)#summary-address
 router#show ip interface <interface-id>    查看指定接口信息
router#show ip interface <interface-id>    查看指定接口信息
router#show ip ospf neighbor <router-id>    查看邻居结构信息
router#show ip ospf database router <router-id>    查看路由器
router#show ip interface <interface-id>    查看指定接口信息
router#show ip ospf neighbor <router-id>    查看邻居结构信息
router#show ip ospf database router <router-id>    查看路由器lsa1通告
router#show ip ospf database network <router-id>    路由器网络lsa2通告(所有于DR相连的route)
 router#show ip ospf database summary <router-id>    查看路由器lsa3汇总通告
router#show ip ospf database asbr-summary    查看路由器lsa4(通告ASBR主机地址)
router#show ip ospf database external <router-id>    查看lsa5通告(在整个ospf区中泛滥)
router#show ip ospf database nass-summary    查看路由器lsa7(在nass区中泛滥)
router#show ip ospf database border-rourters    路由器条目(只显示到达ABR和ASBR的路由)
router#show ip ospf virtual-link    查看虚链路配置
router#show ip route    查看网络条目(数据包要转发的目的网络)
 注: 区域内( i )  区域间( I ) (IA)  类型1的外部路由(E1 )计算到达asbr的价值)      类型2外部路由(E2 忽略) 
router#debug ip adj    查看邻接关系的建立
 热备份路由协议HRSP:
router(config-if)#standby <number> ip <virtual-ip-address>    将接口加入备份组
router(config-if)#no standby <number> ip <virtual-ip-address>    将接口从备份组中脱离
 注: 需要加入备份组的所有接口起用相同的virtual-ip-address 且在同一网段内
router(config-if)#standby <number> priority <0-255>    设置优先级(默认为100)
router(config-if)#standby <number> preempt    设置占先权
router(config-if)#standby <number> time <hello-interval> <holdtime>    更改hello消息计时器
 注: hello间隔默认为3秒  保持时间最少应该为hello时间的3倍 可以在(1-255之间变化)
router(config-if)#standby <number> track <type> <type-id> <interface-priority>   
注: 利用端跟踪,活跃路由器的优先级可以基于路由器端口的可用性自动进行调整,当跟踪的端口不可用时活跃路由器的优先级将被降低 (默认为10)  例:standby 48 track interface <serial> fastethernet 0/1 100
 router#show standby    查看备份组状态
 基本访问控制列表:
router(config)#ip access-list { standard | extended } name    命名访问列表
router(config)#access-list <1-99> permit <source-net-id> <返掩码>
router(config)#access-list <1-99> deny  <主机> <返掩码>
注: 0.0.0.0 255.255.255.255 简写为any    允许或拘绝所有网络
  0.0.0.0 简写为host    允许或拘绝某个主机返掩码
router(config-if)#ip access-group <1-99> in/out    在接口上定义access-list的方向 
router(config-if)#ip access-group  name  in/out    在接口上定义命名access-list的方向           
扩展访问控制列表:
router(config)#access-list <number> {permit|deny } protocol <SourceIP| wild> <destinationIP|wild>[precedence<0-7>][tos<0-15><log>          基于ip的访问列表
 注: 扩展列表范围为100-199之间。protocol是个变量包括(eigrp  gre  icmp  igrp  ip  ipinip  nos  ospf  tcp  udp)
 precedence和tos 是可选变量,它们可以在ip报头的优先级字段和服类类型字段建寻找匹配。
router(config)#access-list <number> {permit|deny }tcp <SourceIP| wild>[operator port] <destinationIP|wild> [operator port] [established] [precedence<0-7>] [tos<0-15> <log>        基于tcp的访问列表
 注: operaor是指定逻辑操作,可选项是(eq等于 neq不等于 gt 大于lt 小于range指明包括的端口范围
port指明端口号,常用端口号telnet(23) ftp(20 21) smtp(25) snmp(169) dns(53) tftp(69) www(80)
 established 检查ack 和 rst标记
router(config)#access-list <number> {permit|deny }udp <SourceIP| wild>[operator port] <destinationIP|wild> [operator port] [precedence<0-7>] [tos<0-15> <log>        基于udp的访问列表
router(config)#access-list <number> {permit|deny }icmp<SourceIP| wild> <destinationIP|wild> [icmp-type] [icmp-code] [precedence<0-7>] [tos<0-15> <log>        基于icmp的访问列表
 注: 多个接口可以调用相同的访问列表,但是在任意一个接口上,对每种协议仅能有一个进入和离开的访问列表。
 安全过滤通常是做为入站过滤,流量过滤通常是出站过滤。标准访问列表尽可能被放置在靠近目标的地方,扩展访问列表应该放置在靠近源点的地方。
router(config)#no access-list 102    删除访问控制例表:
router(config-if)#no ip access-group 101 in    删除访问控制例表
 路由器的nat配置
Router(config-if)#ip nat inside              ;当前接口指定为内部接口
Router(config-if)#ip nat outside              ;当前接口指定为外部接口
Router(config)#ip nat inside source static <私有IP> <公网IP>    静态nat配置
Router(config)#access-list <1> permit 192.168.100.0 0.0.0.255 定义访问列表(动态nat)
 Router(config)#ip nat pool <name> <起始地址><中止地址> netmask<子网掩码>定义合法ip地址池(动态nat)
 Router(config)#ip nat inside destination list <1> pool <name>      访问列表与地址池邦定(动态nat)
 Router(config)#ip nat inside source list <2> interface <serial0/0> overload  复用外部接口地址
tcp负载均衡配置
Router(config)#access-list <1> permit <虚拟主机ip>    定义访问列表
Router(config)#ip nat pool <name> <起始地址><中止地址> prefix-length <24> type rotary
注: <起始地址><中止地址>需要实现负载的几个主机地址
Router(config)#ip nat inside destination list <1> pool <name>      访问列表与地址池邦定
Router#show ip nat translation
 rotary 参数是轮流的意思,地址池中的IP轮流与NAT分配的地址匹配。
overload参数用于PAT 将内部IP映射到一个公网IP不同的端口上。
 配置PPP验证:
RouterA(config)#usename <RouterB> password <word>
 RouterA(config)#int s0
 RouterA(config-if)#ppp authentication {chap|pap}
【路由器认证】:
 步骤:
 定义一个带名字的钥匙链
 定义在钥匙链上的钥匙
 在接口上启动认证并指定使用的钥匙链
 指定这个接口合用名文还是MD5认证
 可选地配置钥匙的管理
config)#key chain 钥匙链名
config-keychain)#key 1
 config-keychain-key)#key-string 口令
config-keychain-key)#interface ethernet 0
 config-if)#ip rip authentication key-chain 钥匙链名
config-if)#ip rip authentication mode md5

【cisco2600路由器密码恢复】
 重启路由器,在启动过程中按下ctrl+break键,使路由器进入rom monitor模式
 在提示符下输入命令修改配置寄存器的值,然后重器路由器
    router>confreg 0x2142    跳过配置文件
    router>reload    重新引导
 重新起动后为了路由器恢复密码后配置不变,把startup-config保存到running-config中然后重新设置密码。
 将配置寄存器的值改回来router(config)#config-register 0x2102
保存当前配置文件到startup-config

【路由交换存储设备简介】
RAM/DRAM动态内存,主要运配置文件,存放路由表,ARP缓存,快速交换缓存,数据包缓冲区和数据包队列,关机后该内容消失
NVRAM非易失RAM,存储了路由器的备份和启动配置文件
FLASH MEMORY 闪存,保存操作系统IOS,同一台机可以存放多个版本
ROM 只读存储器,存放开机自检程序,及一个最原始的IOS
使用TFTP软件进行IOS的备份和配置文件的上传与下载
 备份IOS
安装TFTP server
配置TFTP服务器根目录到指定位置
 用TELNET登陆到路由器  switch#copy flash tftp(从路由器考到服务器)
输入源文件名  如:IOS的文件名 (输入show version 可以看到源文件名)
输入目标主机(服务器)IP
输入目标文件名(可以不改)直接回车
 升级IOS
把要升级的IOS文件放在TFTP服务器根目录的指定位置
 用TELNET登陆到路由器  switch#copy tftp flash (从服务器考到路由器)
输入目标主机(服务器)IP
输入源文件名        ( 要升级的IOS文件名 )
输入目标文件名(可以不改)直接回车
 注: 保证网络的连通性      (升级时要在重起前完成否则IOS将不能起动)
配置文件的上传和下载同理copy running-config tftp    copy startup-config tftp
路由交换文本编辑键的使用

编辑键    说明                          编辑键              说明     
ctrl+A        移动光标至行首        ctrl+E                移到光标到行尾     
ctrl+F      光标向前移一个字符      ctrl+B          光标向后移一个字符     
ctrl+x        删除光标左边的内容      ctrl+k            删除光标右边的内容     
ctrl+u        删除一行                          ctrl+r          刷新命令和此前输入的肉容   

 


【OSI模型七个层的功能】

【物理层】(第1层)
• 提供传输介质(如电缆)
• 将数据转换为与传输介质相应的传输信号
• 在传输介质中发送信号
• 包括网络的物理布局
• 监视传输错误
• 确定数据信号传输的电压级并同步传输
• 确定信号类型是数字信号还是模拟信号
 【数据链路层】(第2层)
• 使用网络适当的格式构造数据帧
• 创建C R C信息
• 使用C R C信息检查错误
• 如果出现错误就重新传输数据
• 初始化通信链接,并且为了结点到结点的可靠性,要保证链接不被中断
• 检验设备地址
• 确认接收到了帧
 【网络层】(第3层)
• 确定路由包的网络路径
• 帮助减少网络阻塞
• 建立虚拟电路
• 将帧路由到其他网络,在需要时对包的传输进行重新排序
• 在协议间转换
 【传输层】(第4层)
• 确保结点与结点间包传输的可靠性
• 确保数据发送和接收时顺序相同
• 当包接收到后,给出确认信息
• 监控包传输错误,再发坏了的包
• 将大的数据单元分割成小的单元,对于采用不同协议的网络,需要在接收端重新构造这些单元
 【会话层】(第5层)
• 初始化通信链接
• 确保通信链接受到维护
• 确定在各个点上,要哪个结点及时传输数据。例如,哪一个结点首先传输
• 通信会话结束后,断开连接
• 转换结点地址
 【表示层】(第6层)
• 将数据转换为接收结点理解的格式,如从E B C D I C转换为A S C I I
• 执行数据加密
• 执行数据压缩
 【应用层】(第7层)
• 使得可以共享远程驱动器
• 使得可以共享远程打印机
• 处理电子邮件消息
• 提供文件传输服务
• 提供文件管理服务
• 提供终端仿真服务



Tags:

发布: admin 分类: CCIE思科 评论: 0 浏览: 81
留言列表
发表留言
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。