配置路由器Router1 Press Enter to Start Router> Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname Router1 Router1(config)#interface ethernet 0 Router1(config-if)#ip address 192.168.1.1 255.255.255.0 Router1(config-if)#no shutdown %LINK-3-UPDOWN: Interface Ethernet0, changed state to up Router1(config-if)#interface serial 0 Router1(config-if)#encapsulation hdlc Router1(config-if)#ip address 192.168.2.1 255.255.255.0 Router1(config-if)#no shutdown %LINK-3-UPDOWN: Interface Ethernet0, changed state to up %LINK-3-UPDOWN: Interface Ethernet0, changed state to down %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to down Router1(config-if)# 同理配置路由器Router2、Router3。 配置2台PC 用ipconfig命令配置PC1和PC2,如图所示。
路由器Router1的路由表信息 Router1#show ip route Codes: C – connected, S – static, I – IGRP, R – RIP, M – mobile, B – BGP D – EIGRP, EX – EIGRP external, 0 – 0SPF, IA – OSPE inter area E1 – OSPE external type 1, E2 – OSPE external type 2, E – EGP i – IS-IS, L1 – IS-IS level-1, L2 – IS-IS level-2, * – candidate default U – per-user static route Gateway of last resort is not set C 192.168.1.0/24 is directly connected, Ethernet0 C 192.168.2.0/24 is directly connected, Serial0 可以看到,路由器Router1只有两个直连路由分别到达网络192.168.1.0和192.168.2.0,没有到达网络192.168.3.0和192.168.4.0的路由,所以,在Router1上ping网络192.168.3.0和192.168.4.0是ping不通的。 同样,路由器Router2只有两个直连路由分别到达网络192.168.2.0和192.168.3.0,没有到达网络192.168.1.0和192.168.4.0的路由,所以,在Router2上ping网络192.168.1.0和192.168.4.0是ping不通的。 为了能够使非直连的网络可以互通,可以通过手工配置的方法来添加静态路由。 4.配置静态路由 配置Router1到网络192.168.3.0和192.168.4.0的静态路由 Router1#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2 Router1(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2 Router1(config)# 5.再次查看路由表信息 查看路由器Router1的路由表信息 Router1#show ip route 6.再次测试PC1和PC2之间的连通性 可以看到,PC2可以ping通PC1,这表明PC1和PC2之间的3个路由器配置的静态路由在发挥作用。 C:>ping 192.168.1.2 7.再次查看路由器的配置 可以通过show running-config命令再次查看各个路由器的配置信息。 (2)动态路由RIP配置 动态路由RIP拓扑图
配置路由器Router1的各个接口及其OSPF协议 Router> Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname Router1 Router1(config)#interface ethernet 0 Router1(config-if)#ip address 192.168.5.1 255.255.255.0 Router1(config-if)#no shutdown %LINK-3-UPDOWN: Interface Ethernet0, changed state to up Router1(config-if)#interface serial 0 Router1(config-if)#ip address 192.168.2.1 255.255.255.0 Router1(config-if)#clock rate 56000 Router1(config-if)#no shutdown %LINK-3-UPDOWN: Interface Serial0, changed state to up %LINK-3-UPDOWN: Interface Serial0, changed state to down %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to down Router1(config-if)#interface serial 1 Router1(config-if)#ip address 192.168.1.1 255.255.255.0 Router1(config-if)#clock rate 56000 Router1(config-if)#no shutdown %LINK-3-UPDOWN: Interface Serial1, changed state to up %LINK-3-UPDOWN: Interface Serial1, changed state to down %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1, changed state to down Router1(config-if)#exit Router1(config)#router ospf 1 Router1(config-router)#network 192.168.1.0 0.0.0.255 area 0 Router1(config-router)#network 192.168.2.0 0.0.0.255 area 0 Router1(config-router)#network 192.168.5.0 0.0.0.255 area 0 Router1(config-router)#end %LINK-3-UPDOWN: Interface Serial0, changed state to up %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to up
2.利用show running-config命令来显示各个路由器的配置信息
路由器Router1的配置信息 Router1#show running-config 3.利用show ip route命令来查看各个路由器的路由表信息 查看路由器Router1的路由表信息 Router1#show ip route 4.测试各个路由器接口的连通性 以路由器Router1为例,与路由器Router1非直接相连的有9个对应的接口IP地址,可以用ping命令测试其连通性。如果ping通,表明路由已经生效。 5.查看邻居路由信息 查看路由器Router1的邻居路由信息 Router1#show ip ospf neighbor 6.查看路由器上直接连接的端口信息 查看路由器Router1上直接连接的端口信息 Router1#show ip ospf interface 三、实验内容 1、Boson Netsim的安装 2、静态路由配置 3、动态路由RIP/OSPF配置 四、实验设备 1、计算机 2、局域网络 3、Boson Netsim软件
Router>Router>enable (进入特权模式,有将权限提升到root的意思)Router#conf t (进入全局配置模式,这是要更改或配置路由器时,必须进入的模式.完整的命令是config terminal)Enter configuration commands, one per line. End with CNTL/Z.Router(config)#host r2 (命名路由器名称为R2,完整命令是hostname R2)r2(config)#ena se c1 (设置进入特权模式的密文为C1,注意密文和密码不是一个意思,一般密文是加密存放的,密码是明文保存的.完整命令是enable secret c1)r2(config)#line vty 0 4 (进入配置telnet线路的模式,并且针对的线路是0号线到4号线)r2(config-line)#pass c2 (在此线路配置模式下,设置密码为C2.完整命令是password c2)r2(config-line)#int eth 0 (进入0号以太端口的端口配置模式,完整命令是interface ethernet 0)r2(config-if)#ip add 192.168.2.1 255.255.255.0 (为端口配置IP地址和掩码.完整命令是ip address)r2(config-if)#no shut (开启端口,完整命令是no shutdown)%LINK-3-UPDOWN: Interface Ethernet0, changed state to upr2(config-if)#int se 0 (进入0号串行口的端口配置模式.完整命令interface serial 0)r2(config-if)#ip add 10.0.0.2 255.0.0.0 (同之前一样,为此端口配置IP和掩码)r2(config-if)#clock rate 64000 (设置链路时钟频率为64000)r2(config-if)#no shut (开启端口,也就是no shutdown) %LINK-3-UPDOWN: Interface Serial0, changed state to upr2(config-if)#end (退到特权模式)%LINK-3-UPDOWN: Interface Serial0, changed state to down%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0, changed state to downr2#copy run start (将正在运行中的配置复制到启动配置,也就是保存配置的意思.完整命令是copy running-config startup-config)Destination filename [startup-config]? (问你是否确定目标文件为stratup-config,如果是直接按回车)Building configuration... (保存中....) 补充:CNTL/Z意思就是退到特权模式,也就是"router#"这样的模式.作用和命令end一样.还有CNTL/Z是指ctrl键和Z键一起按.