案例一 使用交换机的命令行管理界面 案例九 静态路由实现网络互连 【背景描述】 【实现功能】 【使用设备】 设备类型 设备名称 设备数量 交换机 switch 2 路由器 三层交换机 双绞线 4 计算机 pc 2 【实验拓扑】 【实现步骤】 步骤1 在路由器Router1上配置接口的ip地址和串口上的时钟频率 Red-Giant(config)#hostname Router1 Router1(config)#interface fastEthernet 0 Router1(config-if)#ip address 172.16.1.1 255.255.255.0 Router1(config-if)#no shutdown Router1(config-if)#exit Router1(config)#interface serial 1 Router1(config-if)#ip address 172.16.2.1 255.255.255.0 Router1(config-if)#clock rate 64000 !配置DCE端的时钟频率 Router1(config-if)#no shutdown 验证测试:验证路由器接口的配置 Router1#show ip interface brief Interface IP-Address OK? Method Status Protocol FastEthernet0 172.16.1.1 YES manual up up FastEthernet1 unassigned YES unset administratively down down FastEthernet2 unassigned YES unset administratively down down FastEthernet3 unassigned YES unset administratively down down Serial0 unassigned YES unset administratively down down Serial1 172.16.2.1 YES manual up up 查看接口的状态 Router1#show interfaces serial 1 Serial1 is up, line protocol is up !查看端口的状态 Hardware is HDLC4530B Internet address is 172.16.2.1/24 !配置IP地址 MTU 1500 bytes, BW 2048 Kbit, DLY 20000 usec, rely 255/255, load 1/ Encapsulation HDLC, loopback not set, keepalive set (10 sec) Last input 00:00:03, output 00:00:02, output hang never Last clearing of "show interface" counters never Input queue: 0/75/0 (size/max/drops); Total output drops: 0 Queueing strategy: weighted fair Output queue: 0/64/0 (size/threshold/drops) Conversations 0/2 (active/max active) Reserved Conversations 0/0 (allocated/max allocated) 5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec 11 packets input, 880 bytes, 0 no buffer Received 11 broadcasts 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort 74 packets output, 5780 bytes, 0 underruns 0 output errors, 0 collisions, 28 interface resets 0 output buffer failures, 0 output buffers swapped out 0 carrier transitions DCD=up DSR=up DTR=up RTS=up CTS=up 步骤2 在路由器Router1上配置静态路由. Router1(config)#ip route 172.16.3.0 255.255.255.0 172.16.2.2 或 Router1(config)#ip route 172.16.3.0 255.255.255.0 serial 1 验证测试:验证Router1上的静态路由的配置 Router1#show ip route Codes: C - connected, S - static, R - RIP O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2 Gateway of last resort is not set 172.16.0.0/24 is subnetted, 3 subnets C 172.16.1.0 is directly connected, FastEthernet0 C 172.16.2.0 is directly connected, Serial1 S 172.16.3.0 is directly connected 步骤3 在路由器router2上配置接口的IP地址和串口上的时钟频率 Router2(config)#interface fastEthernet 0 Router2(config-if)#ip address 172.16.3.1 255.255.255.0 Router2(config-if)#no shutdown Router2(config)#interface serial 1 Router2(config-if)#ip address 172.16.2.2 255.255.255.0 Router2(config-if)#no shutdown 验证测试:验证接口的配置 Router2#show ip interface brief Interface IP-Address OK? Method Status Protocol FastEthernet0 172.16.3.1 YES manual up up FastEthernet1 unassigned YES unset administratively down down FastEthernet2 unassigned YES unset administratively down down FastEthernet3 unassigned YES unset administratively down down Serial0 unassigned YES unset administratively down down Serial1 172.16.2.2 YES manual up up Router2#show interfaces serial 1 Serial1 is up, line protocol is up Hardware is HDLC4530B Internet address is 172.16.2.2/24 MTU 1500 bytes, BW 2048 Kbit, DLY 20000 usec, rely 255/255, load 1/255 Encapsulation HDLC, loopback not set, keepalive set (10 sec) Last input 00:00:02, output 00:00:04, output hang never Last clearing of "show interface" counters never Input queue: 0/75/0 (size/max/drops); Total output drops: 0 Queueing strategy: weighted fair Output queue: 0/64/0 (size/threshold/drops) Conversations 0/2 (active/max active) Reserved Conversations 0/0 (allocated/max allocated) 5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec 120 packets input, 4480 bytes, 0 no buffer Received 100 broadcasts 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort 155 packets output, 9360 bytes, 0 underruns 0 output errors, 0 collisions, 18 interface resets 0 output buffer failures, 0 output buffers swapped out 0 carrier transitions DCD=up DSR=up DTR=up RTS=up CTS=up 步骤4 在路由器router2上配置静态路由 Router2(config)#ip route 172.16.1.0 255.255.255.0 172.16.2.1 或 Router2(config)#ip route 172.16.1.0 255.255.255.0 serial 1 验证测试:验证router2上的静态路由配置 Router2#show ip route Codes: C - connected, S - static, R - RIP O - OSPF, IA - OSPF inter area E1 - OSPF external type 1, E2 - OSPF external type 2 Gateway of last resort is not set 172.16.0.0/24 is subnetted, 3 subnets S 172.16.1.0 [1/0] via 172.16.2.1 C 172.16.2.0 is directly connected, Serial1 C 172.16.3.0 is directly connected, FastEthernet0 步骤5测试网络的互联互通性 C:\Documents and Settings\Administrator>ping 172.16.3.2 !从PC1上ping PC2 Pinging 172.16.3.2 with 32 bytes of data: Reply from 172.16.3.2: bytes=32 time=1ms TTL=126 Reply from 172.16.3.2: bytes=32 time<1ms TTL=126 Reply from 172.16.3.2: bytes=32 time<1ms TTL=126 Reply from 172.16.3.2: bytes=32 time<1ms TTL=126 Ping statistics for 172.16.3.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 1ms, Average = 0ms C:\Documents and Settings\Administrator>ping 172.16.1.2 !从PC2 ping PC1 Pinging 172.16.1.2 with 32 bytes of data: Reply from 172.16.1.2: bytes=32 time=1ms TTL=126 Reply from 172.16.1.2: bytes=32 time<1ms TTL=126 Reply from 172.16.1.2: bytes=32 time<1ms TTL=126 Reply from 172.16.1.2: bytes=32 time<1ms TTL=126 Ping statistics for 172.16.1.2: Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), Approximate round trip times in milli-seconds: Minimum = 0ms, Maximum = 1ms, Average = 0ms 参考配置 Router1#show running-config !显示路由器router1上的全部配置 Building configuration... Current configuration: ! version 6.14(9coll) ! hostname "Router1" ! ip subnet-zero ! interface FastEthernet0 ip address 172.16.1.1 255.255.255.0 ! interface FastEthernet1 no ip address shutdown ! interface FastEthernet2 no ip address shutdown ! interface FastEthernet3 no ip address shutdown ! interface Serial0 no ip address shutdown ! interface Serial1 ip address 172.16.2.1 255.255.255.0 clock rate 64000 ! ip classless ip route 172.16.3.0 255.255.255.0 172.16.2.2 ! line con 0 line aux 0 line vty 0 4 login line vty 5 19 login ! end Router2#show running-config !显示路由器router2上的全部配置 Building configuration... Current configuration: ! version 6.14(9coll) ! hostname "Router2" ! ip subnet-zero ! interface FastEthernet0 ip address 172.16.3.1 255.255.255.0 ! interface FastEthernet1 no ip address shutdown ! interface FastEthernet2 no ip address shutdown ! interface FastEthernet3 no ip address shutdown ! interface Serial0 no ip address shutdown ! interface Serial1 ip address 172.16.2.2 255.255.255.0 ! ip classless ip route 172.16.1.0 255.255.255.0 172.16.2.1 ! line con 0 line aux 0 line vty 0 4 login line vty 5 19 login ! end 【注意事项】 如果两台路由器通过串口直接互连,则必须在其中一端设置时钟频率(DCE)。