星辰笔记-路由交换命令集_第1页
星辰笔记-路由交换命令集_第2页
星辰笔记-路由交换命令集_第3页
星辰笔记-路由交换命令集_第4页
星辰笔记-路由交换命令集_第5页
已阅读5页,还剩17页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

星辰笔记 星辰笔记-路由交换命令集星辰笔记-路由交换命令集 11.常用命令 222. Cisco交换机的几种操作模式 .23. 配置主机名 34. 查看交换机的配置 35. 配置 enable明文口令 36. 配置 enable加密口令 37. 配置 Console口令 38. 配置管理用 IP地址 39. 配置管理用 IP地址的网关 410. 查看 MAC地址表 411. 使用 CDP协议 412. 保存交换机的配置 413. 恢复设备出厂默认值 414. Cisco交换机上静态 VLAN的配置 .415. 删除已创建的 VLAN.516. 将端口加入 VLAN.517. 验证 VLAN的配置 518. 使用缓存命令 516. 配置接口为 Trunk模式 517. 使用 show命令检查配置 618. VTP的运行模式与配置 .619. STP协议 .720. 三层交换 821. 路由器的配置模式 922. 静态路由的配置 1023. 默认路由的配置 1024. 查看路由器配置 1125. 路由器配置密码 1126. 路由器的描述信息 1127. 配置路由器的控制台会话 12星辰笔记 28. 路由器密码恢复 1229. 单臂路由的配置 1230. RIP路由协议的版本 .1331. RIP v1路由协议的配置 .1332. RIP v2配置 .1433.在路由上配置 DHCP 1434.路由交换的远程管理 1435. 传系统 1536. PPP协议 .1637. OSPF协议 .17OSPF 的多区域配置 .18OSPF 和辅助地址 .19重分发路由器配置命令 208. 热备份路由协议(HSRP) 211.常用命令2. Cisco交换机的几种操作模式 用户模式:Switch 特权模式:SwitchenableSwitch# 全局配置模式:Switch#config terminalSwitch(config)# 接口配置模式: Switch(config)#interface fa0/1Switch(config-if)# Line 模式: Switch(config)#line console 0Switch(config-line)#星辰笔记 3. 配置主机名 Switchen Switch#conf t Switch(config)# hostname sjd sjd(config)#4. 查看交换机的配置Benet-sw1(config)# show running-config5. 配置 enable明文口令 Benet-sw1(config)#enable password 123 Benet-sw1(config)#exit Benet-sw1#show running-config6. 配置 enable加密口令 Benet-sw1(config)# enable secret 123 Benet-sw1#show running-config 查看7. 配置 Console口令 Benet-sw1(config)#line console 0 Benet-sw1(config-line)#password 123 Benet-sw1(config-line)#login Benet-sw1#show run8. 配置管理用 IP地址 Benet-sw1(config)# interface vlan 1 Benet-sw1(config-if)# ip address Benet-sw1(config-if)# no shutdown Benet-sw1# show running-config星辰笔记 9. 配置管理用 IP地址的网关 Benet-sw1(config)#ip default-gateway 0010. 查看 MAC地址表 Benet-sw1#show mac-address-table11. 使用 CDP协议Benet-swl#show cdp interface-numberBenet-sw1#show cdp neighborBenet-sw1#show cdp neighbors detailBenet-swl#show cdp trafficBenet-swl#show cdp entry *| WORD12. 保存交换机的配置 Benet-sw1# copy running-config startup-config Benet-sw1# write13. 恢复设备出厂默认值Benet-sw1# erase startup-config 删除配置文件Benet-sw1#reload 重新启动交换机,交换机在启动时,加载出厂配置14. Cisco交换机上静态 VLAN的配置在全局配置模式下创建 VLAN Switch(config)#vlan vlan-id 添加一个 VLAN Switch(config-vlan)#name vlan-name 给 VLAN 命名,此命令可选 进入 VLAN 数据库创建 VLAN Switch#vlan database 进入 VLAN database Switch(vlan)#vlan 2 name v1 添加 VLAN 2 名为 v2如果不给 VLAN 指定名称,交换机自动添加 VLAN 2 的名称为默认的 VLAN0002星辰笔记 15. 删除已创建的 VLAN Switch#vlan database Switch(vlan)#no vlan 2或:Switch(config)#no vlan 216. 将端口加入 VLAN Switch(config)# interface f0/1 Switch(config-if)# switchport access vlan vlan-id Switch(config-if)# no switchport access vlan vlan-id也可以同时将多个端口添加到某个 VLAN 中:Switch(config)# interface range f0/1 10Switch(config-if-range)# switchport access vlan vlan-id17. 验证 VLAN的配置 Switch# show vlan brief 查看所有 VLAN 的摘要信息 Switch# show vlan id vlan-id 查看指定 VLAN 的信息18. 使用缓存命令 Switch# show history16. 配置接口为 Trunk模式Switch(config)# interface interface-idSwitch(config-if)#switchport mode ?access 接口为接入模式 Set trunking mode to ACCESS unconditionallydynamic 接口为动态协商模式 Set trunking mode to dynamically negotiate access or trunk modetrunk 接口为中继模式 Set trunking mode to TRUNK unconditionallySwitch(config-if)#switchport mode trunk配置接口为动态协商模式 Switch(config-if)#switchport mode dynamic ?auto 自动 Set trunking mode dynamic negotiation parameter to AUTOdesirable 企望 Set trunking mode dynamic negotiation parameter 星辰笔记 to DESIRABLE查看接口模式Switch#show interface interface-id switchport查看端口状态SW1#show interface f0/24 switchport从 Trunk 中添加、删除 Vlan 去除 VLANSwitch (config-if )# switchport trunk allowed vlan remove vlan-list 添加 VLAN Switch (config-if)# switchport trunk allowed vlan add vlan-list 检查中继端口允许 VLAN 的列表Switch # show interface interface-id switchport17. 使用 show命令检查配置 查看端口状态SW1#show interface interface-id switchport 查看 VLAN 信息SW1#show vlan brief 查看配置SW1#show run18. VTP的运行模式与配置 VTP 模式有 3 种 服务器模式(Server) 客户机模式(Client) 透明模式(Transparent) 创建 VTP 域 (有的交换机只有在 VLAN 数据库模式里才能用)switch(config)# vtp domian domain_name 域名星辰笔记 配置交换机的 VTP 模式switch(config)# vtp mode server | client | transparent 模式 配置 VTP 口令switch(config)# vtp password password 配置 VTP 修剪 switch(config)# vtp pruning VTP 版本的配置 switch(config)# vtp version 2 查看 VTP 的配置switch# show vtp status19. STP协议PVST 的配置命令 启用生成树Switch(config)#spanning-tree vlan vlan-list 每 vlan 的 设置根网桥Switch(config)#spanning-tree vlan vlan-list root primary | secondary设置为根网桥后,优先级变成 24576 修改网桥的优先级Switch(config)#spanning-tree vlan vlan-list priority Bridge-priority优先级的值为 4096 的倍数 修改端口成本星辰笔记 Switch(config-if)#spanning-tree vlan vlan-list cost cost 修改端口优先级Switch(config-if)#spanning-tree vlan vlan-list port-priority priority 配置上行速链路Switch(config)#spanning-tree uplinkfast 配置端口速链路Switch(config-if)#spanning-tree portfast 查看生成树的配置Switch#show spanning-tree 查看某个 VLAN 的生成树详细信息Switch#show spanning-tree vlan vlan-id detail20. 三层交换三层交换机的配置 在三层交换机上启动路由Switch(config)#ip routing 配置 VLAN 的 IP 地址Switch (config)#interface vlan vlan-idSwitch (config-if)#ip address Ip-address Subnet-maskSwitch (config-if)#no shutdown 查看 FIB 表Switch (config)#show ip cef 查看邻接关系表Switch (config)#show adjacency detail 在三层交换机上配置路由接口Switch (config-if)#no switchport 配置 DHCP 中继转发Switch(config)#interface vlan vlan-id vlanIDSwitch(config-if)#ip helper-address Dhcpserver-address dhcp 服务器的 IP星辰笔记 在 3 层交换机上配置各 VLAN 的 IP 地址SW-3L(config)#interface vlan 1SW-3L(config-if)#ip address SW-3L(config-if)#no shutSW-3L(config)#interface vlan 2SW-3L(config-if)#ip address SW-3L(config-if)#no shutSW-3L(config)#interface vlan 3SW-3L(config-if)#ip address SW-3L(config-if)#no shut 在三层交换机上配置路由接口SW-3L(config)#inter f0/23SW-3L(config-if)#no switchport 配置接口为 3 层模式SW-3L(config-if)#ip address 52 配置接口的 IP 地址SW-3L(config)#ip route 配置静态路由或动态路由 在路由器上配置路由Router(config)#ip route Router(config)#ip route Router(config)#ip route 三层交换机配置 DHCP 中继实例 在各 VLAN 互通的前提下,配置 DHCP 中继服务SW-3L(config)#interface vlan 1SW-3L(config-if)#ip helper-address 00 SW-3L(config)#interface vlan 3SW-3L(config-if)#ip helper-address 00 DHCP 服务器的地址21. 路由器的配置模式 用户模式:Router 特权模式:Router#星辰笔记 全局配置模式:Router(config)# 接口配置模式:Router(config-if)# 子接口配置模式: Router(config)#interface fa0/0.1Router(config-subif)# Line 模式: Router(config-line)# 路由模式:Router(config-router)# 配置 enable 明文口令 Router (config)#enable password 123 Router (config)#exit Router #show running-config 6. 配置 enable 加密口令 Router (config)# enable secret 123 Router #show running-config 查看 7. 配置 Console 口令 Router (config)#line console 0 Router (config-line)#password 123 Router (config-line)#login Router #show run22. 静态路由的配置Router Aenable 进入特权模式 Router A#config terminal 进入全局配置模式Router A(config) #interface f0/0 进入接口配置模式Router A(config-if) #ip address 配置接口 IP 地址Router A(config-if)#no shutdown 激活端口Router A(config-if)#exitRouter A(config)#ip route 配置静态路由目标网段 目标网段的掩码 下一跳地址23. 默认路由的配置Router B(config)#ip route 星辰笔记 表示任何网络 下一跳地址24. 查看路由器配置Router A#show running-config查看路由表RouterA#show ip route25. 路由器配置密码 配置控制台密码teacher(config)#line console 0teacher(config_line)#loginteacher(config_line)#password cisco 配置特权模式密码teacher(config)#enable password cisco 配置加密保存的密码teacher(config)#enable secret 1234 对所有密码加密teacher(config)#service password-encryption26. 路由器的描述信息 配置路由器的 banner 信息teacher(config)#banner motd $This is Aptech companys Router! Please dont change the configuration without permission! $ 配置路由器接口的描述信息teacher(config)#interface fastethernet 0/0teacher(config_if)#description This is a fast ethernetport used to connecting the companys intranet! 星辰笔记 27. 配置路由器的控制台会话 配置控制台会话时间teacher(config)#line console 0teacher(config_line)#exec-timeout 0 0 配置控制台输出日志同步teacher(config)#line console 0teacher(config_line)#logging synchronous 配置禁用 DNSteacher(config)#no ip domain-lookup28. 路由器密码恢复 重新起动路由,按下 ctrl+break 键,使路由进入 ROM Monitor 模式 进入 ROM Monitor 模式 只能在超级终端里才能按下 ctrl+break 键有用 修改配置寄存器的值,启动时绕过 startup-config 文件: rommon1confreg 0x2142 rommon2reset 用 startup-config 覆盖 running-config: Router#copy startup-config running-config 修改密码: Router(config)#enable password cisco 修改配置寄存器的值: Router(config)#config-register 0x2102查看路由器配置teacher #show version29. 单臂路由的配置Router(config)# interface f0/0.1星辰笔记 Router(config-subif)# encapsolution dot1q 1 1 为 Vlan ID 封装 vlan 端口为dot1qRouter(config-subif)# ip address 子接口 IPRouter(config)# interface f0/0.2Router(config-subif)# encapsolution dot1q 2 Vlan ID 2Router(config-subif)# ip address 30. RIP路由协议的版本 RIP v1 发送路由更新时不携带子网掩码,属于有类路由协议 发送路由更新时,目标地址为广播地址:55 RIP v2 发送路由更新时携带子网掩码,属于无类路由协议 发送路由更新时,目标地址为组播地址:31. RIP v1路由协议的配置Router(config)# router rip 宣告主网络号Router(config-router)# network network-number1、哪个接口向外宣告 RIP 路由,并能接收 RIP 更新2、向外宣告哪个网段验证配置 查看路由表Router# show ip route 查看路由协议配置Router# show ip protocols 打开 RIP 协议调试命令Rouetr# debug ip rip星辰笔记 查看路由表RouetrA# show ip route查看路由协议配置RouterA# show ip protocol打开 RIP 协议调试命令RouterA# debug ip rip32. RIP v2配置 配置 RIP 协议使用版本 2Router(config)# router ripRouter(config-router)# version 2Router(config-router)# no auto-summary版本 2 默认情况下边界自动汇总,如果需要支持可变长子网,需要配置为不进行自动汇总33.在路由上配置 DHCPRouter(config)#server dhcpRouter(dhcp-config)#ip dhcp pool sjd 地址池名字Router(dhcp-config)#network 分配地址的网段Router(dhcp-config)#default-router 网关Router(dhcp-config)#dns-server 自动获取 DNS34.路由交换的远程管理Router(config)#enable password 123 配置使能密码Router(config)#line vty 0 4 进入线路配置模式Router(config-line)#password 123 加密Router(config-line)#login 登陆时生效Router(config-line)#endRouter#write 保存到 Startup-config 中。Router(config)#inter F0/0Router(config-if)#ip add 09 Router(config-if)#no shutRouter(config-if)#ip default-gateway 网关Switch (config)#in vlan 1Switch (config)#ip add 给 vlan1 配置 IP 用于管理Switch (config)#no shutdown星辰笔记 Switch (config)#ip default-gateway 配置网关用于过程管理35. 传系统在没有系统的时候可以用 console 口传rommon 0 setrommon 1 IP_ADDRESS=25 路由器自己 IPrommon 2 IP_SUBNET_MASK= 子网掩码rommon 3 DEFAULT_GATEWAY= 网关rommon 4 TFTP_SERVER= PC 自己 IPrommon 5 TFTP_FILE=c2600-ipbase-mz.124-5.binrommon 6 tftpdnldrommon 7 confreg 0x2102rommon 8 reset用 TFTP 上传系统下面是在登陆 09 之后的具体配置:R5#copy flash tftp 将路由器上 flash 中的文件复制到 tftp 服务器上。Source filename c2600-ik8o3s-mz.122-11.T.bin? c2600-ik8o3s-mz.122-11.T.bin 输入需要复制的系统名Address or name of remote host ? TFTP 服务器对应的主机的具体地址Destination filename c2600-ik8o3s-mz.122-11.T.bin?回车确认!15108540 bytes copied in 174.982 secs (86343 bytes/sec)复制已经完成实验二:通过 TFTP 服务器给 Cisco 路由器上传配置文件R5#copy tftp flash 复制 TFTP 服务器输出目录里的 confit.text 文件到路由器的 flash 中。Address or name of remote host ? TFTP 服务器对应的主机地址。Source filename ? config.textDestination filename config.text?Accessing t/config.text.Erase flash: before copying? confirmj 任意输入一个字母(注意:不可直接按回车,否则,Flash 里的所有文件,包括系统也被擦除了。Loading config.text from (via FastEthernet0/0): !OK - 20 bytesVerifying checksum. OK (0xE9E9)20 bytes copied in 0.221 secs (90 bytes/sec)R5#show flash System flash directory:星辰笔记 File Length Name/status1 15108540 c2600-ik8o3s-mz.122-11.T.bin2 20 config.text 可以看出文件已经复制到 FLASH 中了15108688 bytes used, 18445744 available, 33554432 total32768K bytes of processor board System flash (Read/Write)可以看出上传成功了36. PPP协议配置 PPP 协议 进入串口配置模式Router(config)# interface serial 0/0 配置接口的链路层协议为 PPPRouter(config-if)# encapsulation ppp 配置接口的 IP 地址Router(config-if)# ip address ip_addr ip_mask 配置认证用户名和密码Router(config)# username user_name password 0 pass_word 0 表示密码为明文保存 启用 PAP 认证Router(config-if)# ppp authentication pap 配置认证用户名和密码Router(config-if)# ppp pap sent-username user_name password 0 pass_word 配置认证用户名和密码Router(config)# username user_name password 0 pass_word 启用 CHAP 认证Router(config-if)# ppp authentication chap 配置认证用的用户名Router(config-if)# ppp chap hostname user_name 如果不配置此命令,默认使用路由器的主机名作为主认证方的用户名 配置认证用户名和密码Router(config)# username user_name password 0 pass_word 配置认证用的用户名星辰笔记 Router(config-if)# ppp chap hostname user_name 配置认证用的密码Router(config-if)# ppp chap password 0 pass_word 当没有配置认证的用户名和密码时,可以使用此命令配置默认的密码 服务器端Router(config-if)# peer default ip address ip_addr 客户端Router(config-if)# ip address negotiated 启用 PPP 压缩Router(config-if)# compress predictor | stac 需要在 PPP 链路的两端均配置才能生效当路由器负载过大时,最好不要启用 PPP 压缩 启用 TCP/IP 头压缩Router(config-if)# ip tcp header-compression需要在 PPP 链路的两端均配置才能生效在高速线路上最好不要启用此功能PPP 的调试和排错Router#show interface serial 0/1debug ppp packet 命令37. OSPF协议 配置 loopback 接口地址Router(config)# interface loopback 0Router(config-if)# ip address IP 地址 掩码 启动 OSPF 路由进程Router(config)# router ospf 进程号 本路由器的进程号,用于标识同一路由器上的多个 OSPF 进程 定 OSPF 协议运行的接口和所在的区域Router(config-router)# network 网络号 反向掩码 area 区域号 可以是网络地址、子网地址、接口地址指明网络所属区域,此处是 0-骨干区域/24 子网掩码: 反向掩码:55子网掩码为 1 的位,在反向掩码中为 0;子网掩码为 0 的位,在反向掩码中为 1。星辰笔记 修改接口的 Cost 值Router(config-if)#ip ospf cost 取值范围 165535例如:Router(config)#interface s0Router(config-if)#ip ospf cost 1000 OSPF 路由器在接口上使用 cost 值来决定最佳路径 配置 OSPF 计时器Router(config-if)#ip ospf hello-interval 时间 (s) Router(config-if)#ip ospf dead-interval 时间 (s) 例如:Router(config)#interface e0Router(config-if)#ip ospf hello-interval 5Router(config-if)#ip ospf dead-interval 20 为了交换信息,相邻由器必须有相同的 hello 和 dead 间隔,通常 dead 时间是 hello 时间的4 倍 查看邻居列表Router#show ip ospf neighbor 查看链路状态数据库Router#show ip ospf database 查看路由表Router#show ip route 查看 OSPF 的配置Router#show ip ospf 查看 OSPF 接口数据结构Router#show ip ospf interface 接口OSPF 的多区域配置 配置一个 stub area(末梢区域)Router(config-router)# area area-id stub 配置一个 totally stubby area (完全末梢区域)Router(config-router)# area area-id stub no-summary常用的检查命令Show ip route 查看路由表信息(直连/学习)星辰笔记 Show ip route ospf 只查看 OSPF 学习到的路由Show ip ospf 查看在路由器上 OSPF 是如何配置的和 ABRShow ip ospf database 查看 LSDB 内的所有 LSA 数据信息Show ip ospf neighbor查看 OSPF 邻居和邻接的状态(FULL 表示邻居状态正常)Show ip protocol 查看 OSPF 协议配置信息Show ip interface 接口上 OSPF 的配置信息(如进程 ID,cost,优先级等)Debug ip ospf adj 查看路由“邻接”的整个过程Clear ip route 清空路由表 配置 NSSARouter(config-router)#area area-id nssa no-summary完全非纯末梢区域,阻止 LSA 3 和 LSA 4 型在 NSSA 区域内泛洪OSPF 和辅助地址DNS 服务器和路由器 F 位于子网 /25 中,并给路由器 D的 E0 接口分配一个辅助地址 5/25:配置命

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论