思科 cisco ip_route
思科ciscoip_route

思科ciscoip_route路由协议(routing protocol):用于routers动态寻找网络最佳路径,保证所有routers拥有相同的路由表.一般,路由协议决定数据包在网络上的行走的路径.这类协议的例子有OSPF,RIP,IGRP,EIGRP等可路由协议(routed protocol):当所有的routers知道了整个网络的拓扑结构以后,可路由协议就可以用来发送数据.一般的,可路由协议分配给接口,用来决定数据包的投递方式.这类例子有IP和IPX 路由:把1个数据包从1个设备发送到不同网络里的另1个设备上去.这些工作依靠routers来完成.routers并不关心主机,它们只关心网络的状态和决定网络中的最佳路径router可以路由数据包,必须至少知道以下状况:1.目标地址(destination address)2.可以学习到远端网络状态的邻居router3.到达远端网络的所有路线4.到达远端网络的最佳路径5.如何保持和验证路由信息The IP Routing Process路由原理:当IP子网中的一台主机发送IP包给同一IP子网的另一台主机时,它将直接把IP包送到网络上,对方就能收到.而要送给不同IP 于网上的主机时,它要选择一个能到达目的子网上的router,把IP包送给该router,由它负责把IP包送到目的地.如果没有找到这样的router,主机就把IP包送给一个称为缺省网关(default gateway)的router上.缺省网关是每台主机上的一个配置参数,它是接在同一个网络上的某个router接口的IP地址,router转发IP包时,只根据IP包目的IP地址的网络号部分,选择合适的接口,把IP包送出去.同主机一样,router也要判定接口所接的是否是目的子网,如果是,就直接把包通过接口送到网络上,否则,也要选择下一个router来传送包.router也有它的缺省网关,用来传送不知道往哪儿送的IP包.这样,通过router把知道如何传送的IP 包正确转发出去,不知道的IP包送给缺省网关,这样一级级地传送,IP包最终将送到目的地,送不到目的地的IP包则被网络丢弃了当主机A发送个IP包到主机B,目标MAC地址使用的是默认网关的以太网接口地址.这是因为帧不能放置在远端网络.show ip route:查看路由表信息,比如:Router#sh ip route(略)Gateway of last resort is not setC 192.168.10.0/24 is directly connected, FastEthernet0/0C 192.168.20.0/24 is directly connected, Serial 0/0Router#C代表的是:直接相连Configuring IP Routing in Our Network当1个router收到1个目标网络号没有在路由表中列出的包的时候,它并不发送广播寻找目标网络,而是直接丢弃它几种不同类型的路由:1.静态路由(static routing)2.默认路由(default routing)3.动态路由(dynamic routing)Static Routing静态路由:手动填加路由线路到路由表中,优点是:1.没有额外的router的CPU负担2.节约带宽3.增加安全性缺点是:1.网络管理员必须了解网络的整个拓扑结构2.如果网络拓扑发生变化,管理员要在所有的routers上手动修改路由表3.不适合在大型网络中静态路由的配置命令:ip route [dest-network] [mask] [next-hop address或exit interface][administrative distance] [permanent]ip route:创建静态路由dest-network:决定放入路由表的路由表mask:掩码next-hop address:下1跳的router地址exit interface:如果你愿意的话可以拿这个来替换next-hop address,但是这个是用于点对点(poi nt-to-point)连接上,比如广域网(WAN)连接,这个命令不会工作在LAN上administrative distance:默认情况下,静态路由的管理距离是1,如果你用exit interface代替next -hop address,那么管理距离是0 permanent:如果接口被shutdown了或者router不能和下1跳router通信,这条路由线路将自动从路由表中被删除.使用这个参数保证即使出现上述情况,这条路线仍然保持在路由表中静态路由的具体配置: Router Network Address Interface AddressRouterA 192.168.10.0 fa0/0 192.168.10.1192.168.20.0 s0/0 192.168.20.1RouterB 192.168.20.0 s0/0 192.168.20.2192.168.40.0 s0/1 192.168.40.1192.168.30.0 fa0/1 192.168.30.1RouterC 192.168.40.0 s0/0 192.168.40.2192.168.50.0 fa0/0 192.168.50.1准备工作:先配置RouterA,B和C的基本信息,注意RouterB作为DCE提供时钟频率:RouterA(config)#int fa0/0RouterA(config-if)#ip address 192.168.10.1 255.255.255.0RouterA(config-if)#no shutRouterA(config-if)#int s 0/0RouterA(config-if)#ip address 192.168.20.1 255.255.255.0RouterA(config-if)#no shutRouterA(config-if)#^ZRouterA#copy run startRouterB(config)#int fa0/0RouterB(config-if)#ip address 192.168.30.1 255.255.255.0RouterB(config-if)#no shutRouterB(config-if)#int s 0/0RouterB(config-if)#ip address 192.168.20.2 255.255.255.0RouterB(config-if)#clock rate 64000RouterB(config-if)#no shutRouterB(config-if)#ip address 192.168.40.1 255.255.255.0RouterB(config-if)#clock rate 64000RouterB(config-if)#no shutRouterB(config-if)#^ZRouterB#copy run startRouterC(config)#int fa0/0RouterC(config-if)#ip address 192.168.50.1 255.255.255.0RouterC(config-if)#no shutRouterC(config-if)#int s 0/0RouterC(config-if)#ip address 192.168.40.2 255.255.255.0RouterC(config-if)#no shutRouterC(config-if)#^ZRouterC#copy run start配置RouterA静态路由:RouterA了解自己的网络192.168.10.0和192.168.20.0(直接相连),所以RouterA的路由表必须加入192.168.30.0和192.168.40.0, 192.168.50.0的信息,注意下1跳接口,如下: RouterA(config)#ip route 192.168.30.0 255.255.255.0 192.168.20.2RouterA(config)#ip route 192.168.40.0 255.255.255.0 192.168.20.2RouterA(config)#ip route 192.168.50.0 255.255.255.0192.168.20.2验证路由信息:RouterA#sh ip route(略)S 192.168.50.0 [1/0] via 192.168.20.2(略)S代表静态路由,[1/0]分别为管理距离和度配置RouterB静态路由:RouterB所必须学习到的网络应该是192.168.10.0和192.168.50.0,注意它们的下1跳接口地址,配置如下:RouterB(config)#ip route 192.168.10.0 255.255.255.0 192.168.20.1RouterB(config)#ip route 192.168.50.0 255.255.255.0 192.168.40.2配置RouterC静态路由:RouterC所必须学习到的网络应该是192.168.10.0,192.168.20.0和192.168.30.0,注意它们的下1跳接口地址,配置如下:RouterC(config)#ip route 192.168.10.0 255.255.255.0 192.168.40.1RouterC(config)#ip route 192.168.20.0 255.255.255.0 192.168.40.1RouterC(config)#ip route 192.168.30.0 255.255.255.0 192.168.40.1Verifying Your Configuration根据上面的拓扑结构,我们来验证下是否能够端到端的ping通:RouterC#ping 192.168.10.1(略)Sending 5, 100-byte ICMP Echos to 192.168.10.1, timeout is 2 seconds:RouterA#ping 192.168.50.1(略)Sending 5, 100-byte ICMP Echos to 192.168.50.1, timeout is 2 seconds:(略)2端都能ping通,说明没问题Default Routing默认路由:一般使用在stub网络中,stub网络是只有1条出口路径的网络.使用默认路由来发送那些目标网络没有包含在路由表中的数据包.根据上面的拓扑图,你就不能把默认路由定义在RouterB上,因为RouterB拥有不止1个出口路径接口.其实你可以把默认路由理解成带通配符(wildcard)的静态路由配置默认路由:首先要去掉之前配置的静态路由RouterC(config)#no ip route 192.168.10.0 255.255.255.255 192.168.40.1RouterC(config)#no ip route 192.168.20.0 255.255.255.255 192.168.40.1RouterC(config)#no ip route 192.168.30.0 255.255.255.255 192.168.40.1接下来配置默认路由:RouterC(config)#ip route 0.0.0.0 0.0.0.0 192.168.40.1额外的命令,使各个接口打破分类IP规则,12.x的IOS默认包含这条命令,如下:RouterC(config)#ip classless再验证下:RouterC(config)#^ZRouterC#sh ip routeS* 0.0.0.0/0 [1/0] via 192.168.40.1S*代表默认路由Dynamic Routing动态路由协议,有很多优点,灵活等等,但是缺点也有,比如占用了额外的带宽,CPU负荷高组网利用到的2种路由协议:内部网关协议(Interior Gateway Protocols,IGPs)和外部网关协议(E xterior Gateway Protocols,EGPs) 自治系统(Autonomous System,AS):同1个管理域的网络集合,意味着在这里面的所有routers共享相同的路由表信息IGPs:在相同的AS内交换路由信息EGPs:AS间的通信Routing Protocol BasicsAdministrative Distances管理距离(AD): 0到255之间的1个数,它表示一条路由选择信息源的可信性值.该值越小,可信性级别越高.0为最信任,255为最不信任即没有从这条线路将没有任何流量通过.假如1个router收到远端的2条路由更新,router将检查AD,AD值低的将被选为新路线存放于路由表中.假如它们拥有相同的AD,将比较它们的度(metric).度低的将作为新线路.假如它们的AD和度都一样,那么将在2条线路做均衡负载.一些常用路由协议默认的AD:1.直接相连:02.静态路由:13.EIGRP:904.IGRP:1005.OSPF:1106.RIP:120记住,如果你在条线路上配置了静态路由,又配置了RIP,默认情况下,router只会使用静态路由,因为它的AD为1小于RIP的AD Routing Protocols3种路由协议:1.距离向量(distance vector)2.链路状态(link state)3.混合型(hybrid)距离向量:用于根据距离(distance)来判断最佳路径,当1个数据包每经过1个router时,被称之为经过1跳.经过跳数最少的则作为最佳路径.这类协议的例子有RIP和IGRP,它们将整个路由表向与它们直接相连的相邻routers链路状态:也叫最短路径优先(shortest-path-first)协议.每个router创建3张单独的表,1张用来跟踪与它直接相连的相邻router;1张用来决定网络的整个拓扑结构;另外1张作为路由表.所以这种协议对网络的了解程度要比距离向量高.这类协议例子有OSPF混合型:综合了前2者的特征,这类协议的例子有EIGRPDistance-Vector Routing Protocols距离向量路由算法将完整的路由表传给相邻router,然后这个router再把收到的表的选项加上自己的表来完成整个路由表,这个叫做routing by rumor,因为这个router是从相邻router接受更新而非自己去发现网络的变化。
思科协议——静态路由实验手册

静态路由的语法格式:Ip route 目标网段掩码吓一跳地址(接口)例如R1(config)#ip route 45.1.1.0 255.255.255.0 12.1.1.2 //目标是一个网段R1(config)#ip route 23.1.1.1 255.255.255.255 12.1.1.2 //目标是一个地址R1(config)#ip route 0.0.0.0 0.0.0.0 12.1.1.2 ///目标是所有的网段,默认路由//默认路由的优先级是最低的。
R1:interface Loopback0 //loopback接口是一个逻辑接口,不接任何线,可以直接upip address 1.1.1.1 255.255.255.0 增加一个参考网段!interface Serial0/0ip address 12.1.1.1 255.255.255.0ip route 5.5.5.0 255.255.255.0 12.1.1.2 //全局模式下配置R2:interface Serial0/0ip address 12.1.1.2 255.255.255.0!interface Serial0/1ip address 23.1.1.2 255.255.255.0ip route 1.1.1.0 255.255.255.0 12.1.1.1ip route 5.5.5.0 255.255.255.0 23.1.1.3R3:interface Serial0/0ip address 34.1.1.3 255.255.255.0interface Serial0/1ip address 23.1.1.3 255.255.255.0ip route 1.1.1.0 255.255.255.0 23.1.1.2ip route 5.5.5.0 255.255.255.0 34.1.1.4R4:interface Serial0/0ip address 34.1.1.4 255.255.255.0interface Serial0/1ip address 45.1.1.4 255.255.255.0ip route 1.1.1.0 255.255.255.0 34.1.1.3ip route 5.5.5.0 255.255.255.0 45.1.1.5R5:interface Loopback0ip address 5.5.5.5 255.255.255.0interface Serial0/1ip address 45.1.1.5 255.255.255.0ip route 1.1.1.0 255.255.255.0 45.1.1.4r1ping 5.5.5.5 source loopback0!!!!!ping 5.5.5.5 不通解决需要全网可以ping通!R5R5#debug ip icmpICMP packet debugging is onR5#debug ip packetIP packet debugging is onR1#ping 5.5.5.5Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:Success rate is 0 percent (0/5R5上的debug信息*Mar 1 00:44:43.283: IP: s=5.5.5.5 (local), d=12.1.1.1, len 100, unroutable因为不指定ping源接口,就会从直连的接口发包,源地址也是直连的接口没有做12.1.1.0网段的路由,r5会显示无法路由R5(config)#ip route 12.1.1.0 255.255.255.0 45.1.1.4R4(config)#ip route 12.1.1.0 255.255.255.0 34.1.1.3R3(config)#ip route 12.1.1.0 255.255.255.0 23.1.1.2R1#ping 5.5.5.5Type escape sequence to abort.Sending 5, 100-byte ICMP Echos to 5.5.5.5, timeout is 2 seconds:!!!!!如果要让全网通呢?课后作业:在相应的机器上加上相应的网段的路由!。
思科路由器(CiscoRouter)常用配置命令大全

思科路由器(CiscoRouter)常用配置命令大全思科路由器(Cisco Router)常用配置命令大全1. Access-enable允许路由器在动态访问列表中创建临时访问列表入口2. Access-group把访问控制列表(ACL)应用到接口上3. Access-list定义一个标准的IP ACL4. Access-template在连接的路由器上手动替换临时访问列表入口5. Appn向APPN子系统发送命令6. Atmsig 执行ATM信令命令7. B 手动引导操作系统8. Bandwidth 设置接口的带宽9. Banner motd 指定日期信息标语10. Bfe 设置突发事件手册模式11. Boot system 指定路由器启动时加载的系统映像12. Calendar 设置硬件日历13. Cd 更改路径14. Cdp enable 允许接口运行CDP协议15. Clear 复位功能16. Clear counters 清除接口计数器17. Clear interface 重新启动接口上的件逻辑18. Clockrate 设置串口硬件连接的时钟速率,如网络接口模块和接口处理器能接受的速率19. Cmt 开启/关闭FDDI连接管理功能20. Config-register 修改设置寄存器设置21. Configure 允许进入存在的设置模式,在中心站点上维护并保存设置信息22. Configure memory 从NVRAM加载设置信息23. Configure terminal 从终端进行手动设置24. Connect 打开一个终端连接25. Copy 复制设置或映像数据26. Copy flash tftp 备份系统映像文件到TFTP服务器27. Copy running-config startup-config 将RAM中的当前设置存储到NVRAM28. Copy running-config tftp 将RAM中的当前设置存储到网络TFTP服务器上29. Copy tftp flash 从TFTP服务器上下载新映像到Flash30. Copy tftp running-config 从TFTP服务器上下载设置文件31. Debug 使用调试功能32. Debug dialer 显示接口在拨什么号及诸如此类的信息33. Debug ip rip 显示RIP路由选择更新数据34. Debug ipx routing activity 显示关于路由选择协议(RIP)更新数据包的信息35. Debug ipx sap 显示关于SAP(业务通告协议)更新数据包信息36. Debug isdn q921 显示在路由器D通道ISDN接口上发生的数据链路层(第2层)的访问过程37. Debug ppp 显示在实施PPP中发生的业务和交换信息38. Delete 删除文件39. Deny 为一个已命名的IP ACL设置条件40. Dialer idle-timeout 规定线路断开前的空闲时间的长度41. Dialer map 设置一个串行接口来呼叫一个或多个地点42. Dialer wait-for-carrier-time 规定花多长时间等待一个载体43. Dialer-group 通过对属于一个特定拨号组的接口进行设置来访问控制44. Dialer-list protocol 定义一个数字数据接受器(DDR)拨号表以通过协议或ACL和协议的组合来控制控制拨号45. Dir 显示给定设备上的文件46. Disable 关闭特许模式47. Disconnect 断开已建立的连接48. Enable 打开特许模式49. Enable password 确定一个密码以防止对路由器非授权的访问50. Enable password 设置本地口令控制不同特权级别的访问51. Enable secret 为enable password命令定义额外一层安全性(强制安全,密码非明文显示)52. Encapsulation frame-relay 启动帧中继封装53. Encapsulation novell-ether 规定在网络段上使用的Novell 独一无二的格式54. Encapsulation PPP 把PPP设置为由串口或ISDN接口使用的封装方法55. Encapsulation sap 规定在网络段上使用的以太网802.2格式Cisco的密码是sap56. End 退出设置模式57. Erase 删除闪存或设置缓存58. Erase startup-config 删除NVRAM中的内容59. Exec-timeout 设置EXEC命令解释器在检测到用户输入前所等待的时间60. Exit 退出所有设置模式或关闭一个激活的终端会话和终止一个EXEC61. Exit 终止所有设置模式或关闭一个活动的对话和结束EXEC62. format 格式化设备63. Frame-relay local-dlci 为使用帧中继封装的串行线路启动本地管理接口(LMI)64. Help 获得交互式帮助系统65. History 查看历史记录66. Hostname 使用一个主机名来设置路由器,该主机名以提示符或缺省文件名的方式使用67. Interface 设置接口类型并且输入接口设置模式68. Interface 设置接口类型和进入接口设置模式69. Interface serial 选择接口并且输入接口设置模式70. Ip access-group 控制对一个接口的访问71. Ip address 设定接口的网络逻辑地址72. Ip address 设置一个接口地址和子网掩码并开始IP处理73. Ip default-network 建立一条缺省路由74. Ip domain-lookup 允许路由器缺省使用DNS75. Ip host 定义静态主机名到IP地址映射76. Ip name-server 指定至多6个进行名字-地址解析的服务器地址77. Ip route 建立一条静态路由78. Ip unnumbered 在为给一个接口分配一个明确的IP地址情况下,在串口上启动互连网协议(IP)的处理过程79. Ipx delay 设置点计数80. Ipx ipxwan 在串口上启动IPXWAN协议81. Ipx maximum-paths 当转发数据包时设置Cisco IOS软件使用的等价路径数量82. Ipx network 在一个特定接口上启动互连网数据包交换(IPX)的路由选择并且选择封装的类型(用帧封装)83. Ipx router 规定使用的路由选择协议84. Ipx routing 启动IPX路由选择85. Ipx sap-interval 在较慢的链路上设置较不频繁的SAP(业务广告协议)更新86. Ipx type-20-input-checks 限制对IPX20类数据包广播的传播的接受87. Isdn spid1 在路由器上规定已由ISDN业务供给商为B1信道分配的业务简介号(SPID)88. Isdn spid2 在路由器上规定已由ISDN业务供给商为B2信道分配的业务简介号(SPID)89. Isdntch-type 规定了在ISDN接口上的中心办公区的交换机的类型90. Keeplive 为使用帧中继封装的串行线路LMI(本地管理接口)机制91. Lat 打开LAT连接92. Line 确定一个特定的线路和开始线路设置93. Line concole 设置控制台端口线路94. Line vty 为远程控制台访问规定了一个虚拟终端95. Lock 锁住终端控制台96. Login 在终端会话登录过程中启动了密码检查97. Login 以某用户身份登录,登录时允许口令验证98. Logout 退出EXEC模式99. Mbranch 向下跟踪组播地址路由至终端100. Media-type 定义介质类型101. Metric holddown 把新的IGRP路由选择信息和正在使用的IGRP路由选择信息隔离一段时间102. Mrbranch 向上解析组播地址路由至枝端103. Mrinfo 从组播路由器上获取邻居和版本信息104. Mstat 对组播地址多次路由跟踪后显示统计数字105. Mtrace 由源向目标跟踪解析组播地址路径106. Name-connection 命名已存在的网络连接107. Ncia 开启/关闭NCIA服务器108. Network 把一个基于NIC的地址分配给一个和他直接相连的路由器把网络和一个IGRP的路由选择的过程联系起来在IPX路由器设置模式下,在网络上启动加强的IGRP109. Network 指定一个和路由器直接相连的网络地址段110. Network-number 对一个直接连接的网络进行规定111. No shutdown 打开一个关闭的接口112. Pad 开启一个X.29 PAD连接113. Permit 为一个已命名的IP ACL设置条件114. Ping 把ICMP响应请求的数据包发送网络上的另一个节点检查主机的可达性和网络的连通性对网络的基本连通性进行诊断115. Ping 发送回声请求,诊断基本的网络连通性116. Ppp 开始IETF点到点协议117. Ppp authentication 启动Challenge握手鉴权协议(CHAP)或密码验证协议(PAP)或将两者都启动,并且对在接口上选择的CHAP和PAP验证的顺序进行规定118. Ppp chap hostname 当用CHAP进行身份验证时,创建一批似乎是同一台主机的拨号路由器119. Ppp chap password 设置一个密码,该密码被发送到对路由器进行身份验证的主机命令对进入路由器的用户名/密码的数量进行了限制120. Ppp pap sent-username 对一个接口启动远程PAP支持,并且在PAP对同等层请求数据包验证过程中使用sent-username和password121. Protocol 对一个IP路由选择协议进行定义,该协议能是RIP,内部网关路由选择协议。
思科路由器配置基础

思科路由器配置基础思科路由器配置基础思科(Cisco)路由器是智能信息网络的基础,为当今要求最严格的网络服务,包括IP 通信、视频、客户关系管理、金融交易和其他实时应用提供了高可用性、全面的安全性、易管理性和先进的服务质量( QoS )。
下面店铺准备了思科路由器配置基础,欢迎大家参考!一、基本设置方式一般来说,可以用5种方式来设置路由器:1.Console口接终端或运行终端仿真软件的微机;2.AUX口接MODEM,通过电话线与远方的终端或运行终端仿真软件的微机相连;3.通过Ethernet上的TFTP服务器;4.通过Ethernet上的TELNET程序;5.通过Ethernet上的SNMP网管工作站。
但路由器的第一次设置必须通过第一种方式进行,此时终端的硬件设置如下:波特率:9600数据位:8停止位:1奇偶校验: 无二、命令状态1. router>路由器处于用户命令状态,这时用户可以看路由器的连接状态,访问其它网络和主机,但不能看到和更改路由器的设置内容。
2. router#在router>提示符下键入enable,路由器进入特权命令状态router#,这时不但可以执行所有的用户命令,还可以看到和更改路由器的设置内容。
3. router(config)#在router#提示符下键入configure terminal,出现提示符router(config)#,此时路由器处于全局设置状态,这时可以设置路由器的全局参数。
4. router(config-if)#; router(config-line)#; router(config-router)#;…路由器处于局部设置状态,这时可以设置路由器某个局部的参数。
5. >路由器处于RXBOOT状态,在开机后60秒内按ctrl-break可进入此状态,这时路由器不能完成正常的功能,只能进行软件升级和手工引导。
6. 设置对话状态这是一台新路由器开机时自动进入的状态,在特权命令状态使用SETUP命令也可进入此状态,这时可通过对话方式对路由器进行设置。
Cisco路由器IP地址配置

本文覆盖了使用命令行界面的基本的Cisco路由器IP地址配置--------------------------------------------------------------------------------感谢以下的资源非常有用:Leinwand、Pinsky和Culpepper。
Cisco路由器的配置。
印第安纳州印第安纳波利斯:Cisco 公司出版,1998。
Cisco系统公司,感谢Newman给我上了配置Cisco路由器的第一节课。
本文的信息原先搜集于,或者说得自于James Hart先生所完成的计划。
他在Albuquerque,NM(美国新墨西哥州)的技术/职业学院教师。
非常感谢他允许我参加该计划的工作。
弃权书本文的传播无须明确或含蓄的授权,对本文包含的信息的正确性亦不作任何担保。
本文仅提供给需要帮助的人使用,但使用者必须自己承担风险。
如果使用者由于使用本文而造成的任何损失作者和T VI(技术/职业学院)概不负责。
约定在介绍重要的术语和概念时,或许以粗体显示。
正文所包含的命令以常体显示,用于实例的所有名称或地址亦是这样,同时不应该用到你的实际网络中。
配置你的系统时不要一字不差地输入名称或地址。
最后,在某些例子中,在命令要求I P地址作为参数的地方,IP 地址可能以xx.xx.xx.xx或.dd这种方式来表示。
实际上,配置你的系统时永远不会用到这些字符串。
本文的约定指出你应该把指明的地方替换成适当的I P地址。
--------------------------------------------------------------------------------1. 本文档覆盖的东西有好几种方法可用来配置Cisco路由器。
配置可以由TFTP服务器通过网络来完成;可以通过启动时提供的菜单界面来完成;并且可以由运行s etup命令所提供的菜单界面来完成;还可以由保存到内存中的配置来完成。
思科route命令大全

思科route命令大全cisco router and switch 配置命令精华压缩版时间: 2010-08-05 / 分类: +CCNA, ★CISCO技术 / 浏览次数: 105 views / 0个评论发表评论Router and switch 配置命令精华压缩版1、进入SETUP模式Router#setup2、时间设置router#clock set hh:mm:ss date moth year3、 router>show historyRouter>terminal history size lines4、 router#show version5、 router#show running-config6、 router#show starup-config7、 router(config)#hostname name 主机命名8、 router(config)#banner motd # message # 开机时的固定显示信息9、 router(config)#enable password password 特权模式明文密码10、 router(config)#no enable password11、router(config)#enable secret password 特权模式加密密码12、 router(config)#no enable secret13、 router(config)#service password-encryption特权模式把明文密码加密密码,但没enable secret安全可以反解14、 router(config)#line console控制台密码15、 router(config-line)#login16、 router(config-line)#password password17、 router(config-line)#exec-timeout mm ss 禁止控制台会话自动退出18、router(config-line)#logging synchronous重显被打乱的控制台输入router(config)#no ip domain-lookup 禁止域名解析19、 router(config)#line vty 0 4虚拟终端密码20、 router(config-line)#login21、 router(config-line)#password password22、router(config)#interface type number(slot/port)端口设置23、 router(config-if)#ip address ip summast24、 router(config-if)#clock rate 64000(时钟频率单位为bps,只在DCE 端设置)25、 router(config-if)#bandwith 64(带宽设置,单位为KB)26、 router(config-if)#no shutdown(shutdown)27、 router(config-if )#media-type type(10base) 为以太网端口选择适当的介质类型28、 router(config-if )#ctrl+z保存退出到特权模式29、 router#30、 router>用户模式enable进入router#特权模式config terminal进入router(config)#全局配置模式31、Interface Router(config-if)#端口设置Subinterface Router(config-subif)# 子端口设置Controller Router(config-controller)# 控制口设置Line Router(config-line)# 虚拟口设置Router Router(config-router)# 路由设置IPX router Router(config-ipx-router)#IPX路由设置32、 router#show interface33、 router#show interface Ethernet 034、 router#show interface serial 035、 router#show running-config36、 router#show starup-config37、 router#show flash38、 router#show controller39、 router#show controller interface type40、 router#show running-configrouter#copy running-config starup-configrouter#copy running-config tftprouter#copy starup-config tftprouter#copy flash tftprouter#copy tftp star-configrouter#copy tftp flash端口状态Serial1 is up, line protocol is up正常工作Serial1 is up, line protocol is down连接问题Serial1 is down, line protocol is down端口问题Serial1 is administratively down, line protocol is down人为关闭配置寄存器的值1、关闭路由器的电源重新启动按住ctrl+break键入进2、>3、>o/r 0×2142(跳过nvarm启动恢复密码)4、>I5、当系统提示是否进入setup模式时,按N6、 router>7、 router>enable8、 router#9、进入修改后(包括密码、寄存器的值:0×2100为rom monitor启动、0×2101为setup模式启动、0×2102为10、 router#copy running-config starup-config11、 router#reload12、也可以在router#setup进入setup模式静态路由协议设置router(config)#ip route network submask(要到达的网络号掩码)ip address(下一跳或出口ip地址)router(config)#ip route 0.0.0.0 s0(出口端口或下一跳IP地址)rip设置router(config)#router riprouter(config-router)#network network-numberrouter#show ip protocol查看RIP信息router#show ip route 查看路由表router#debug ip rip查看RIP更新信息router(config-router)#passive-interface e0(阻止发出作息)router(config-router)#ip rip receive version 1 2接收1、2RIP 版本信息igrp设置router(config)#router igrp as numberrouter(config-router)#network network numberrouter#show ip route 查看路由表router#debug ip igrp events 查看IGRP路由更新大概信息router#debug ip igrp transaction 查看IGRP路由更新详细信息Router(config-router)#variance multiplier 控制IGRP load balancingRouter(config-router)#traffic-share {balanced | min}控制load-balanced traffic 的分布eigrp设置router(config)#router eigrp as numberrouter(config-router)#network network numberrouter(config)#no auto-summry 关闭自动汇总router(config)# auto-summry 打开自动汇总(默认是打开的)router#show ip route eigrp 显示当前的路由表里的EIGRP条目router#show ip protocol 显示活动的路由协议进程的参数和当前的状态router#show ip eigrp neighbors 显示被EIGRP发现的邻居router#show ip eigrp traffic 显示发出和收到的IP EIGRP 包的数量router#show ip eigrp topology 显示IP EIGRP的拓扑表Router#debug ip eigrpospf设置1. Router(config)#router ospf process-idRouter(config-router)#network address(可以是网络号也可以是Ip地址 mask(通配掩码)area area-idRouter(config-if)# ip ospf priority numbe 配置OSPF的优先级Router#show ip protocols 验证OSPF的配置Router#show ip route 显示路由器学到的所有路由Router#show ip ospf interface type number 显示 area-ID 和邻接信息Router#show ip ospf neighbor 基于每接口显示OSPF邻居信息Router#debug ip ospf eventsRouter#debug ip ospf packet2. Router(config)# interface loopback number(lookback回路配置)Router(config-if)# ip address ip-address subnet-maskRouter(config-if)# ip ospf cost cost-numbe 修改OSPF 的Cost 数值Router(config-if)# ip ospf authentication-key key 配置明文口令Router(config-if)# ip ospf messge-digest-key keyid md5 key 配置MD5口令(keyid和key必须配对一致,两邻居才可以通信)Router(config-route)# area area-id authentication [message-digest]message-digest为可选项,使用后路由器只传送口令消息的摘要(或散列)配置OSPF区域的验证:3. Router(config-if)# ip ospf hello-interval seconds 配置hello 间隔:Router(config-if)# ip ospf dead-interval seconds配置down 机判断间隔访问列表1.标准访问列表(standard access lists):只使用源IP地址来做过滤决定Router(config)#access-list 10 deny 172.16.40.0 0.0.0.255Router(config)#access-list 10 permit anyRouter(config)#int e1Router(config-if)#ip access-group 10 out使用IP标准ACL来控制VTY线路的访问.Router(config)#access-list 50 permit 172.16.10.3Router(config)#line vty 0 4Router(config-line)#access-class 50 in删除IP标准ACLRouter(config-line)#no ip access-class 50 inRouter(config)#no access-list 502.扩展访问列表(extended access lists):它比较源IP地址和目标IP地址,层3的协议字段,层4端口号来做过滤决定Router(config)#access-list 110 deny tcp any host 172.16.30.5 eq 21Router(config)#access-list 110 deny tcp any host 172.16.30.5 eq 23Router(config)#access-list 110 permit ip any anyRouter(config)#int e1Router(config-if)#ip access-group 110 out3.虚拟通道访问router(config)#access-list 12 permit 192.89.55.0 0.0.0.255router(config)#line vty 0 4outer(config-line)#access-class 12 in3.show ip interface:只显示IP访问列表信息4.show ip interface:显示所有接口的信息和配置的ACL信息5.show ip interface [接口号]:显示具体某个接口的信息和配置的ACL信息6.show running-config:显示DRAM信息和ACL信息,以及接口对ACL的应用信息.交换机配置交换机上设置登陆口令Switch(config)# enable password level level passwordSwitch(config)# no enable password level level passwordhostname1900/2900(config)#hostname hostnameIP Address1900(config)#ip address {ip address} {mask}1900(config)#ip address 10.5.5.11 255.255.255.02950(config#interface vlan 12950(config-if)#ip address {ip_address} {mask}2950(config)#interface vlan 12950(config-if)#ip address 10.5.5.11 255.255.255.0default gateway1900/2950(config)#ip default-gateway {ip address}1900/2950(config)#ip default-gateway 172.20.137.1查看交换机的IP地址1900#show ipIP address: 10.5.5.11Subnet mask: 255.255.255.0Default gateway: 10.5.5.3Management VLAN: 12950#show interface vlan 1Vlan1 is up, line protocol is upHardware is Cat5k Virtual Ethernet, address is 0010.f6a9.9800 (bia 00 10.f6a9.9800)Internet address is 172.16.80.79/24Broadcast address is 255.255.255.255设置双工选项1900(config)#interface e0/11900(config-if)#duplex {auto | full |full-flow-control | half}2950(config)#interface fe0/12950(config-if)#duplex {auto | full | half}设置端口速度:switch(config-if)# speed {10|100|auto}查勘双工选项Switch#show interfaces fastethernet0/3查看MAC地址表1900/2950#show mac-address-table配置永久MAC地址1900(config)#mac-address-table permanent {mac-address type module/por t}1900(config)#mac-address-table permanent 2222.2222.2222 ethernet 0/31900#show mac-address-table2950(config)#mac-address-table static mac_addr {vlan vlan_id} [interf ace int1 [int2 ... int15]]配置受限静态MAC地址1900(config)#mac-address-table restricted static {mac-address type mo dule/port src-if-list}1900(config)#mac-address-table restricted static 1111.1111.1111 e0/4 e0/11900#show mac-address-table2950(config)#mac-address-table secure mac-addr interface[vlan vlan-i d]2950(config)#mac-address-table secure 0003.3333.3333 fa 0/1 vlan 12950#show mac-address-table配置端口安全性1900(config-if)#port secure max-mac-count count1900(config)#interface e0/41900(config-if)#port secure1900(config-if)#port secure max-mac-count 11900(config)#address-violation {suspend | disable | ignore 1900# show mac-address-table security2950(config-if)#port security max-mac-count count2950(config)#interface fa0/12950(config-if)#port security2950(config-if)#port security max-mac-count 102950(config-if)#port security action {shutdown | trap}2950#show mac-address-table secure2950#show port-security管理配置文件1900#copy nvram tftp://host/dst_file1900#copy tftp://host/src_file nvram1950#copy nvram tftp://10.1.1.1/wgswd.cfg2950#copy startup-config tftp://host/dst_file清除 NVRAM1900#delete nvram2950#erase startup-configvlan配置1900 VLAN建立1900下,使用vlan [vlan#] name [name] [vlan#]命令, 如下: >en #config t(config)#hostname 19001900(config)#vlan 2 name sales1900(config)#vlan 3 name marketing1900(config)#vlan 4 name mis1900(config)#exit端口分配1900(config)#int e0/21900(config-if)#vlan-membership static 21900(config)#int e0/41900(config-if)#vlan-membership static 31900(config)#int e0/51900(config-if)#vlan-membership static 41900(config-if)#exit1900(config)#exitVLAN验证1900#sh vlan2900 VLAN建立在2950下创建VLAN,在特权模式下使用vlan database命令2950#vlan database2950(vlan)#vlan 2 name MarketingVLAN 2 modified:Name: Marketing2950(vlan)#vlan 3 name AccountingVLAN 3 added:Name: Accounting2950(vlan)#applyAPPLY complete2950(vlan)#Ctrl+C2950#端口分配2950下的端口配置,使用switchport access vlan [vlan#]命令, 2950(config-if)#int f0/22950(config-if)#switchport access vlan 22950(config-if)#int f0/32950(config-if)#switchport access vlan 32950(config-if)#int f0/42950(config-if)#switchport access vlan 42950(config-if)#exit2950(config)#exit验证配置信息,如下:2950#sh vlan或2950#sh vlan brieftrunk配置1900 trunk配置1900(config)#int f0/261900(config-if)#trunk on2950下在接口配置模式,使用switchport命令,如下:2950(config)#int f0/122950(config-if)#switchport mode trunk2950(config-if)# switchport trunk encapsulation {isl|dot1q} 2950(config-if)#^Z将某VLAN从中继中删除2950(config-if)# switchport trunk allowed vlan remove vlan-list添加某个VLAN到中继线路2950(config-if)# switchport trunk allowed vlan add vlan-list Configuring Inter-VLAN Routing给连接1900的trunk端口配置,使用encapsulation isl [vlan#]命令,如下: 2600Router(config)#int f0/0.12600Router(config-subif)#encapsulation isl [vlan#]2600Router(config-subif)#ip add ip add submask给连接2950的这样配置,如下:2600Router(config)#int f0/0.12600Router(config-subif)#encapsulation dot1q [vlan#] 2600Router(config-subif)#ip add ip add submaskVTP配置1900(config)#vtp server1900(config)#vtp domain noco1900(config)#vtp password noko在特权模式下使用show vtp命令验证,如下:1900#sh vtpVTP version: 1Configuration revision: 0Maximum VLANs supported locally: 1005Number of existing VLANs: 5VTP domain name: nocoVTP password: nokoVTP operating mode: Server2950如下:2950(config)#vtp mode server2950(config)#vtp domain noco验证信息,如下:2950#sh vtp ?counters VTP statisticsstatus VTP domain status2950#sh vtp statusNAT配置配置静态转换Router(config)#ip nat inside source static local-ip global-ipRouter(config-if)#ip nat insideRouter(config-if)#ip nat outside配置动态地址转换Router(config)#ip nat pool name start-ip end-ip {netmask netmask | pr efix-length prefix-length}Router(config)#access-list access-list-number permit source [source-w ildcard]Router(config)#ip nat inside source listaccess-list-number pool name配置OverloadingRouter(config)#access-list access-list-number permitsource source-wildcardRouter(config)#ip nat inside source listaccess-list-number interface interface overload清除NAT Translation TableRouter#clear ip nat translation * 清除所有的动态地址转换条目Router#clear ip nat translation inside global-iplocal-ip [outside local-ip global-ip] 清除一个简单的动态地址转换条目(内、外)Router#clear ip nat translation outsidelocal-ip global-ip清除一个简单的动态地址转换(外)Router#clear ip nat translation protocol inside global-ipglobal-port local-ip local-port [outside local-iplocal-port global-ip global-port] 清除一个扩展动态地址转换条目Show命令输出信息Router#show ip nat translations1.在基于IOS的交换机上设置主机名/系统名:switch(config)# hostname hostname在基于CLI的交换机上设置主机名/系统名:switch(enable) set system name name-string2.在基于IOS的交换机上设置登录口令:switch(config)# enable password level 1 password在基于CLI的交换机上设置登录口令:switch(enable) set passwordswitch(enable) set enalbepass3.在基于IOS的交换机上设置远程访问:switch(config)# interface vlan 1switch(config-if)# ip address ip-address netmaskswitch(config-if)# ip default-gateway ip-address在基于CLI的交换机上设置远程访问:switch(enable) set interface sc0 ip-address netmask broadcast-address switch(enable) set interface sc0 vlan switch(enable) set ip route default gateway4.在基于IOS的交换机上启用和浏览CDP信息:switch(config-if)# cdp enableswitch(config-if)# no cdp enable为了查看Cisco邻接设备的CDP通告信息:switch# show cdp interface [type modle/port]switch# show cdp neighbors [type module/port] [detail]在基于CLI的交换机上启用和浏览CDP信息:switch(enable) set cdp {enable|disable} module/port为了查看Cisco邻接设备的CDP通告信息:switch(enable) show cdp neighbors[module/port] [vlan|duplex|capabilit ies|detail]5.基于IOS的交换机的端口描述:switch(config-if)# de脚本ion de脚本ion-string基于CLI的交换机的端口描述:switch(enable)set port name module/number de脚本ion-string6.在基于IOS的交换机上设置端口速度:switch(config-if)# speed{10|100|auto}在基于CLI的交换机上设置端口速度:switch(enable) set port speed moudle/number {10|100|auto} switch(enable) set port speed moudle/number {4|16|auto}7.在基于IOS的交换机上设置以太网的链路模式:switch(config-if)# duplex {auto|full|half}在基于CLI的交换机上设置以太网的链路模式:switch(enable) set port duplex module/number {full|half}8.在基于IOS的交换机上配置静态VLAN:switch# vlan databaseswitch(vlan)# vlan vlan-num name vlaswitch(vlan)# exitswitch# configure teriminalswitch(config)# interface interface module/numberswitch(config-if)# switchport mode accessswitch(config-if)# switchport access vlan vlan-numswitch(config-if)# end在基于CLI的交换机上配置静态VLAN:switch(enable) set vlan vlan-num [name name]switch(enable) set vlan vlan-num mod-num/port-list9. 在基于IOS的交换机上配置VLAN中继线:switch(config)# interface interface mod/portswitch(config-if)# switchport mode trunkswitch(config-if)# switchport trunk encapsulation {isl|dotlq} switch(config-if)# switchport trunk allowed vlan remove vlan-listswitch(config-if)# switchport trunk allowed vlan add vlan-list 在基于CLI的交换机上配置VLAN中继线:switch(enable) set trunk module/port[on|off|desirable|auto|nonegotia te]Vlan-range [isl|dotlq|dotl0|lane|negotiate]10.在基于IOS的交换机上配置VTP管理域:switch# vlan databaseswitch(vlan)# vtp domain domain-name在基于CLI的交换机上配置VTP管理域:switch(enable) set vtp [domain domain-name]11.在基于IOS的交换机上配置VTP 模式:switch# vlan databaseswitch(vlan)# vtp domain domain-nameswitch(vlan)# vtp {sever|cilent|transparent}switch(vlan)# vtp password password在基于CLI的交换机上配置VTP 模式:switch(enable) set vtp [domain domain-name] [mode{ sever|cilent|trans parent }][password password]12. 在基于IOS的交换机上配置VTP版本:switch# vlan databaseswitch(vlan)# vtp v2-mode在基于CLI的交换机上配置VTP版本:switch(enable) set vtp v2 enable13. 在基于IOS的交换机上启动VTP剪裁:switch# vlan databaseswitch(vlan)# vtp pruning在基于CL I 的交换机上启动VTP剪裁:switch(enable) set vtp pruning enable14.在基于IOS的交换机上配置以太信道:switch(config-if)# port group group-number [distribution {source|dest ination}]在基于CLI的交换机上配置以太信道:switch(enable) set port channel moudle/port-rangemode{on|off|desirab le|auto}15.在基于IOS的交换机上调整根路径成本:switch(config-if)# spanning-tree [vlan vlan-list] cost cost在基于CLI的交换机上调整根路径成本:switch(enable) set spantree portcost moudle/port costswitch(enable) set spantree portvlancost moudle/port [cost cost][vlan -list]16.在基于IOS的交换机上调整端口ID:switch(config-if)# spanning-tree[vlan vlan-list]port-priority port-pr iority在基于CLI的交换机上调整端口ID:switch(enable) set spantree portpri {mldule/port}priorityswitch(enable) set spantree portvlanpri {module/port}priority [vlans] 17. 在基于IOS的交换机上修改STP时钟:switch(config)# spanning-tree [vlan vlan-list] hello-time seconds switch(config)# spanning-tree [vlan vlan-list] forward-time seconds switch(config)# spanning-tree [vlan vlan-list] max-age seconds在基于CLI的交换机上修改STP时钟:switch(enable) set spantree hello interval[vlan]switch(enable) set spantree fwddelay delay [vlan]switch(enable) set spantree maxage agingtiame[vlan]18. 在基于IOS的交换机端口上启用或禁用Port Fast 特征:switch(config-if)#spanning-tree portfast。
思科交换机路由基本配置命令

思科交换机路由基本配置命令常用命令1.配置接口:interface {interface_type} {interface_number}2.配置IP地址:ip address {IP_address} {subnet_mask}3.配置默认网关:ip default-gateway {default_gateway_IP}4.开启接口:no shutdown5.配置路由协议:router {routing_protocol}6.配置路由器ID:router-id {router_ID}7.配置路由信息:network {network_address} {subnet_mask}8.配置静态路由:ip route {destination_network} {subnet_mask}{next-hop_IP}9.配置动态路由:router {routing_protocol} {network_address}10.保存配置:copy running-config startup-config注意:上述命令仅作为参考,具体配置应根据实际环境和设备型号进行调整。
下面是一些基本的 Cisco 交换机路由配置命令:1.配置 hostname: hostname <name>2.配置 IP 地址: interface <interface> 后进入接口模式,再输入 ipaddress <ip address> <subnet mask>3.配置默认路由: ip route 0.0.0.0 0.0.0.0 <next hop IP>4.启用路由协议: router <protocol> (例如: router rip)5.配置路由连接: network <network address> (例如: network192.168.1.0)6.查看路由表: show ip routeCisco 交换机路由配置步骤1.进入配置模式:configure terminal2.配置 IP 地址和子网掩码:interface [interface-name] ; ip address[ip-address] [subnet-mask]3.配置默认路由:ip route 0.0.0.0 0.0.0.0 [next-hop-IP-address]4.启用路由协议:router [protocol-name] (如:router ospf)5.配置路由协议参数: [protocol-name] [process-id] (如:ospf 1)6.配置路由连接:network [network-address] [wildcard-mask] area[area-id] (如:network 192.168.1.0 0.0.0.255 area 0)7.保存配置:copy running-config startup-config8.退出配置模式:exit。
思科交换机路由器命令大全

思科交换机路由器命令大全思科交换机和路由器命令大全本文档为思科交换机和路由器命令的最新最全范本,供参考使用。
以下是详细的命令列表,包括每个命令的说明和用法。
一、接口配置命令1、ip address:设置接口的IP地质示例:ip address 192.168.1.1 255.255.255:02、no shutdown:启用接口示例:no shutdown3、duplex:设置接口的双工模式示例:duplex auto4、speed:设置接口的速度示例:speed 1005、exit:退出接口配置模式示例:exit二、VLAN命令1、vlan database:进入VLAN数据库模式示例:vlan database2、vlan id name:创建VLAN并设置名称示例:vlan 10 name VLAN-103、vlan id:删除VLAN示例:no vlan 104、show vlan:显示VLAN信息示例:show vlan5、exit:退出VLAN数据库模式示例:exit三、路由命令1、ip route:设置静态路由示例:ip route 192.168.2:0 255.255.255:0 192.168.1.22、router rip:启用RIP路由协议示例:router rip3、network:将网络添加到RIP路由表中示例:network 10:0:0:04、redistribute:将静态路由或其他路由协议添加到RIP路由表中示例:redistribute static5、exit:退出路由配置模式示例:exit四、ACL命令1、access-list:创建标准或扩展ACL示例:access-list 10 permit 192.168.1:0 0:0:0.2552、ip access-group:应用ACL到接口示例:ip access-group 10 in3、show access-lists:显示ACL信息示例:show access-lists4、exit:退出ACL配置模式示例:exit五、SNMP命令1、snmp-server community:设置SNMP团体字符串示例:snmp-server community public RO2、snmp-server enable traps:启用SNMP陷阱示例:snmp-server enable traps3、snmp-server host:配置SNMP陷阱接收主机示例:snmp-server host 192.168.1.1004、exit:退出SNMP配置模式示例:exit六、SSH命令1、ip ssh version:设置SSH协议版本示例:ip ssh version 22、crypto key generate rsa:RSA密钥对示例:crypto key generate rsa3、username:创建新的本地用户示例:username admin privilege 15 password password1234、exit:退出SSH配置模式示例:exit七、其他命令1、show running-config:显示当前配置示例:show running-config2、copy running-config startup-config:将当前配置保存到启动配置中示例:copy running-config startup-config3、reload:重新启动设备示例:reload4、exit:退出CLI命令行模式示例:exit本文档涉及附件:1、无附件本文所涉及的法律名词及注释:1、ACL(Access Control List):访问控制列表,用于控制网络流量的进出。
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
路由协议(routing protocol):用于routers动态寻找网络最佳路径,保证所有routers拥有相同的路由表.一般,路由协议决定数据包在网络上的行走的路径.这类协议的例子有OSPF,RIP,IGRP,EIGRP等可路由协议(routed protocol):当所有的routers知道了整个网络的拓扑结构以后,可路由协议就可以用来发送数据.一般的,可路由协议分配给接口,用来决定数据包的投递方式.这类例子有IP和IPX 路由:把1个数据包从1个设备发送到不同网络里的另1个设备上去.这些工作依靠routers来完成.routers并不关心主机,它们只关心网络的状态和决定网络中的最佳路径router可以路由数据包,必须至少知道以下状况:1.目标地址(destination address)2.可以学习到远端网络状态的邻居router3.到达远端网络的所有路线4.到达远端网络的最佳路径5.如何保持和验证路由信息The IP Routing Process路由原理:当IP子网中的一台主机发送IP包给同一IP子网的另一台主机时,它将直接把IP包送到网络上,对方就能收到.而要送给不同IP于网上的主机时,它要选择一个能到达目的子网上的router,把IP包送给该router,由它负责把IP包送到目的地.如果没有找到这样的router,主机就把IP包送给一个称为缺省网关(default gateway)的router上.缺省网关是每台主机上的一个配置参数,它是接在同一个网络上的某个router接口的IP地址,router转发IP包时,只根据IP包目的IP地址的网络号部分,选择合适的接口,把IP包送出去.同主机一样,router也要判定接口所接的是否是目的子网,如果是,就直接把包通过接口送到网络上,否则,也要选择下一个router来传送包.router也有它的缺省网关,用来传送不知道往哪儿送的IP包.这样,通过router把知道如何传送的IP包正确转发出去,不知道的IP包送给缺省网关,这样一级级地传送,IP包最终将送到目的地,送不到目的地的IP包则被网络丢弃了当主机A发送个IP包到主机B,目标MAC地址使用的是默认网关的以太网接口地址.这是因为帧不能放置在远端网络.show ip route:查看路由表信息,比如:Router#sh ip route(略)Gateway of last resort is not setC 192.168.10.0/24 is directly connected, FastEthernet0/0C 192.168.20.0/24 is directly connected, Serial 0/0Router#C代表的是:直接相连Configuring IP Routing in Our Network当1个router收到1个目标网络号没有在路由表中列出的包的时候,它并不发送广播寻找目标网络,而是直接丢弃它几种不同类型的路由:1.静态路由(static routing)2.默认路由(default routing)3.动态路由(dynamic routing)Static Routing静态路由:手动填加路由线路到路由表中,优点是:1.没有额外的router的CPU负担2.节约带宽3.增加安全性缺点是:1.网络管理员必须了解网络的整个拓扑结构2.如果网络拓扑发生变化,管理员要在所有的routers上手动修改路由表3.不适合在大型网络中静态路由的配置命令:ip route [dest-network] [mask] [next-hop address或exit interface][administrative distance] [permanent]ip route:创建静态路由dest-network:决定放入路由表的路由表mask:掩码next-hop address:下1跳的router地址exit interface:如果你愿意的话可以拿这个来替换next-hop address,但是这个是用于点对点(poi nt-to-point)连接上,比如广域网(WAN)连接,这个命令不会工作在LAN上administrative distance:默认情况下,静态路由的管理距离是1,如果你用exit interface代替next -hop address,那么管理距离是0permanent:如果接口被shutdown了或者router不能和下1跳router通信,这条路由线路将自动从路由表中被删除.使用这个参数保证即使出现上述情况,这条路线仍然保持在路由表中静态路由的具体配置:Router Network Address Interface AddressRouterA 192.168.10.0 fa0/0 192.168.10.1192.168.20.0 s0/0 192.168.20.1RouterB 192.168.20.0 s0/0 192.168.20.2192.168.40.0 s0/1 192.168.40.1192.168.30.0 fa0/1 192.168.30.1RouterC 192.168.40.0 s0/0 192.168.40.2192.168.50.0 fa0/0 192.168.50.1准备工作:先配置RouterA,B和C的基本信息,注意RouterB作为DCE提供时钟频率:RouterA(config)#int fa0/0RouterA(config-if)#ip address 192.168.10.1 255.255.255.0RouterA(config-if)#no shutRouterA(config-if)#int s 0/0RouterA(config-if)#ip address 192.168.20.1 255.255.255.0RouterA(config-if)#no shutRouterA(config-if)#^ZRouterA#copy run startRouterB(config)#int fa0/0RouterB(config-if)#ip address 192.168.30.1 255.255.255.0RouterB(config-if)#no shutRouterB(config-if)#int s 0/0RouterB(config-if)#ip address 192.168.20.2 255.255.255.0RouterB(config-if)#clock rate 64000RouterB(config-if)#no shutRouterB(config-if)#ip address 192.168.40.1 255.255.255.0RouterB(config-if)#clock rate 64000RouterB(config-if)#no shutRouterB(config-if)#^ZRouterB#copy run startRouterC(config)#int fa0/0RouterC(config-if)#ip address 192.168.50.1 255.255.255.0RouterC(config-if)#no shutRouterC(config-if)#int s 0/0RouterC(config-if)#ip address 192.168.40.2 255.255.255.0RouterC(config-if)#no shutRouterC(config-if)#^ZRouterC#copy run start配置RouterA静态路由:RouterA了解自己的网络192.168.10.0和192.168.20.0(直接相连),所以RouterA的路由表必须加入192.168.30.0和192.168.40.0, 192.168.50.0的信息,注意下1跳接口,如下: RouterA(config)#ip route 192.168.30.0 255.255.255.0 192.168.20.2RouterA(config)#ip route 192.168.40.0 255.255.255.0 192.168.20.2RouterA(config)#ip route 192.168.50.0 255.255.255.0 192.168.20.2验证路由信息:RouterA#sh ip route(略)S 192.168.50.0 [1/0] via 192.168.20.2(略)S代表静态路由,[1/0]分别为管理距离和度配置RouterB静态路由:RouterB所必须学习到的网络应该是192.168.10.0和192.168.50.0,注意它们的下1跳接口地址,配置如下:RouterB(config)#ip route 192.168.10.0 255.255.255.0 192.168.20.1RouterB(config)#ip route 192.168.50.0 255.255.255.0 192.168.40.2配置RouterC静态路由:RouterC所必须学习到的网络应该是192.168.10.0,192.168.20.0和192.168.30.0,注意它们的下1跳接口地址,配置如下:RouterC(config)#ip route 192.168.10.0 255.255.255.0 192.168.40.1RouterC(config)#ip route 192.168.20.0 255.255.255.0 192.168.40.1RouterC(config)#ip route 192.168.30.0 255.255.255.0 192.168.40.1Verifying Your Configuration根据上面的拓扑结构,我们来验证下是否能够端到端的ping通:RouterC#ping 192.168.10.1(略)Sending 5, 100-byte ICMP Echos to 192.168.10.1, timeout is 2 seconds:!!!!!(略)RouterA#ping 192.168.50.1(略)Sending 5, 100-byte ICMP Echos to 192.168.50.1, timeout is 2 seconds:!!!!!(略)2端都能ping通,说明没问题Default Routing默认路由:一般使用在stub网络中,stub网络是只有1条出口路径的网络.使用默认路由来发送那些目标网络没有包含在路由表中的数据包.根据上面的拓扑图,你就不能把默认路由定义在RouterB上,因为RouterB拥有不止1个出口路径接口.其实你可以把默认路由理解成带通配符(wildcard)的静态路由配置默认路由:首先要去掉之前配置的静态路由RouterC(config)#no ip route 192.168.10.0 255.255.255.255 192.168.40.1RouterC(config)#no ip route 192.168.20.0 255.255.255.255 192.168.40.1RouterC(config)#no ip route 192.168.30.0 255.255.255.255 192.168.40.1接下来配置默认路由:RouterC(config)#ip route 0.0.0.0 0.0.0.0 192.168.40.1额外的命令,使各个接口打破分类IP规则,12.x的IOS默认包含这条命令,如下:RouterC(config)#ip classless再验证下:RouterC(config)#^ZRouterC#sh ip route(略)S* 0.0.0.0/0 [1/0] via 192.168.40.1S*代表默认路由Dynamic Routing动态路由协议,有很多优点,灵活等等,但是缺点也有,比如占用了额外的带宽,CPU负荷高组网利用到的2种路由协议:内部网关协议(Interior Gateway Protocols,IGPs)和外部网关协议(E xterior Gateway Protocols,EGPs)自治系统(Autonomous System,AS):同1个管理域的网络集合,意味着在这里面的所有routers共享相同的路由表信息IGPs:在相同的AS内交换路由信息EGPs:AS间的通信Routing Protocol BasicsAdministrative Distances管理距离(AD): 0到255之间的1个数,它表示一条路由选择信息源的可信性值.该值越小,可信性级别越高.0为最信任,255为最不信任即没有从这条线路将没有任何流量通过.假如1个router收到远端的2条路由更新,router将检查AD,AD值低的将被选为新路线存放于路由表中.假如它们拥有相同的AD,将比较它们的度(metric).度低的将作为新线路.假如它们的AD和度都一样,那么将在2条线路做均衡负载.一些常用路由协议默认的AD:1.直接相连:02.静态路由:13.EIGRP:904.IGRP:1005.OSPF:1106.RIP:120记住,如果你在条线路上配置了静态路由,又配置了RIP,默认情况下,router只会使用静态路由,因为它的AD为1小于RIP的ADRouting Protocols3种路由协议:1.距离向量(distance vector)2.链路状态(link state)3.混合型(hybrid)距离向量:用于根据距离(distance)来判断最佳路径,当1个数据包每经过1个router时,被称之为经过1跳.经过跳数最少的则作为最佳路径.这类协议的例子有RIP和IGRP,它们将整个路由表向与它们直接相连的相邻routers链路状态:也叫最短路径优先(shortest-path-first)协议.每个router创建3张单独的表,1张用来跟踪与它直接相连的相邻router;1张用来决定网络的整个拓扑结构;另外1张作为路由表.所以这种协议对网络的了解程度要比距离向量高.这类协议例子有OSPF混合型:综合了前2者的特征,这类协议的例子有EIGRPDistance-Vector Routing Protocols距离向量路由算法将完整的路由表传给相邻router,然后这个router再把收到的表的选项加上自己的表来完成整个路由表,这个叫做routing by rumor,因为这个router是从相邻router接受更新而非自己去发现网络的变化。