實驗目的:
了解路由的在資料傳輸過程中的作用。
通過該實驗學會配置靜态路由,并通過ping指令體會靜态路由的效果。
掌握ping指令的使用。
實驗拓撲:
(2台路由與3台路由環境)
實驗内容:
2台路由器靜态路由協定的基本配置
首先将所有的路由器起名稱,并且将所有的鍊路層調試通
Router>
Router> en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#host r1 起名稱
r1(config)#int e0 進e0端口
r1(config-if)#ip add 199.99.1.1 255.255.255.0 配置IP位址
r1(config-if)#no shut
r1(config-if)#int s0
r1(config-if)#ip add 199.99.2.1 255.255.255.0
00:43:00: %LINK-3-UPDOWN: Interface Ethernet0, changed state to up
00:43:01: %LINEPROTO-5-UPDOWN: Line protocol on Interface Ethernet0, changed state to up 系統狀态提示接口雙UP
r1(config-if)#^Z
r1#sh contr
r1#sh controllers s 0 檢視R1的s0口是否為DCE
HD unit 0, idb = 0x16DFD8, driver structure at 0x175B00
buffer size 1524 HD unit 0, V.35 DTE cable
cpb = 0xE1, eda = 0x5140, cda = 0x5000
RX ring with 16 entries at 0xE15000
00 bd_ptr=0x5000 pak=0x177400 ds=0xE18908 status=80 pak_size=0
01 bd_ptr=0x5014 pak=0x1776D4 ds=0xE18FC4 status=80 pak_size=0
02 bd_ptr=0x5028 pak=0x1779A8 ds=0xE19680 status=80 pak_size=0
03 bd_ptr=0x503C pak=0x177C7C ds=0xE19D3C status=80 pak_size=0
04 bd_ptr=0x5050 pak=0x177F50 ds=0xE1A3F8 status=80 pak_size=0
05 bd_ptr=0x5064 pak=0x178224 ds=0xE1AAB4 status=80 pak_size=0
06 bd_ptr=0x5078 pak=0x1784F8 ds=0xE1B170 status=80 pak_size=0
07 bd_ptr=0x508C pak=0x1787CC ds=0xE1B82C status=80 pak_size=0
08 bd_ptr=0x50A0 pak=0x178AA0 ds=0xE1BEE8 status=80 pak_size=0
09 bd_ptr=0x50B4 pak=0x178D74 ds=0xE1C5A4 status=80 pak_size=0
10 bd_ptr=0x50C8 pak=0x179048 ds=0xE1CC60 status=80 pak_size=0
11 bd_ptr=0x50DC pak=0x17931C ds=0xE1D31C status=80 pak_size=0
12 bd_ptr=0x50F0 pak=0x1795F0 ds=0xE1D9D8 status=80 pak_size=0
13 bd_ptr=0x5104 pak=0x1798C4 ds=0xE1E094 status=80 pak_size=0
14 bd_ptr=0x5118 pak=0x179B98 ds=0xE1E750 status=80 pak_size=0
15 bd_ptr=0x512C pak=0x179E6C ds=0xE1EE0C status=80 pak_size=0
16 bd_ptr=0x5140 pak=0x17A140 ds=0xE1F4C8 status=80 pak_size=0
cpb = 0xE1, eda = 0x5800, cda = 0x5814
TX ring with 1 entries at 0xE15800
bd_ptr=0x5800 pak=0x000000 ds=0xE0124C status=80 pak_size=22
01 bd_ptr=0x5814 pak=0x11EDA8 ds=0xE015DC status=80 pak_size=22
0 missed datagrams, 0 overruns
0 bad datagram encapsulations, 0 memory errors
0 transmitter underruns
0 residual bit errors
r1#conf t
r1(config)#int s0
到目前為止R1的鍊路操作完畢
Router>en
Router#contf t
Router(config)#host r2
r2(config)#
r2(config)#int s0
r2(config-if)#ip add 199.99.2.2 255.255.255.0
r2(config-if)#clock rate 64000 進行時鐘速率的配置
r2(config-if)#no shut
r2(config-if)#ine 0
r2(config-if)#ip add 199.99.3.1 255.255.255.0
r2(config-if)#^Z
r2# ping 199.99.2.1 測試直連鍊路接口是否可以通信
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 199.99.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/32/32 ms
r2#
R2的鍊路配置完畢
r1#sh ip route
Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
ia - IS-IS inter area, * - candidate default, U - per-user static route
o - ODR, P - periodic downloaded static route
Gateway of last resort is not set
C 199.99.2.0/24 is directly connected, Serial0
C 199.99.1.0/24 is directly connected, Ethernet0
r1#
00:44:33: %SYS-5-CONFIG_I: Configured from console by console
r1#sh ip int bri
Interface IP-Address OK? Method Status Protocol
Ethernet0 199.99.1.1 YES manual up up
Serial0 199.99.2.1 YES manual up up
Serial1 unassigned YES unset administratively down down
r1(config)#ip route 199.99.3.0 255.255.255.0 199.99.2.2 定義路由
r1(config)#^Z
r1#ping 199.99.3.1
Sending 5, 100-byte ICMP Echos to 199.99.3.1, timeout is 2 seconds:
!!!!! 可以通信
Success rate is 100 percent (5/5), round-trip min/avg/max = 32/34/44 ms
我們還需要裡同擴充Ping去測試是否真的R1的E0口的資料包可以到達R2口E0。
r1#ping
Protocol [ip]:
Target IP address: 199.99.3.1 定義目的
Repeat count [5]:
Datagram size [100]:
Timeout in seconds [2]:
Extended commands [n]: y
Source address or interface: 199.99.1.1 定義源
Type of service [0]:
Set DF bit in IP header? [no]:
Validate reply data? [no]:
Data pattern [0xABCD]:
Loose, Strict, Record, Timestamp, Verbose[none]:
Sweep range of sizes [n]:
Packet sent with a source address of 199.99.1.1
.....
r2#conf t
r2(config)#ip route 0.0.0.0 0.0.0.0 199.99.2.1 定義到所有地方去的路由的 包下一跳都是199.99.2.1
r2(config)#?
r1#ping 再次進行擴充ping的測試
Target IP address: 199.99.3.1
Source address or interface: 199.99.1.1
那麼兩台路由器的路由實驗完全成功了。
r1#sh run
Building configuration...
Current configuration : 429 bytes
!
version 12.2
service timestamps debug uptime
service timestamps log uptime
no service password-encryption
hostname r1
ip subnet-zero
interface Ethernet0
ip address 199.99.1.1 255.255.255.0
interface Serial0
ip address 199.99.2.1 255.255.255.0
interface Serial1
no ip address
shutdown
ip http server
ip classless
ip route 199.99.3.0 255.255.255.0 199.99.2.2
line con 0
line aux 0
line vty 0 4
end
r2#sh run
Configured from console by console
Current configuration : 437 bytes
hostname r2
ip address 199.99.3.1 255.255.255.0
ip address 199.99.2.2 255.255.255.0
clockrate 64000
ip route 0.0.0.0 0.0.0.0 199.99.2.1
S 199.99.3.0/24 [1/0] via 199.99.2.2
r2#sh ip route
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
Gateway of last resort is 199.99.2.1 to network 0.0.0.0
C 199.99.3.0/24 is directly connected, Ethernet0
S* 0.0.0.0/0 [1/0] via 199.99.2.1
3台路由器靜态路由協定的基本配置
Current configuration : 474 bytes
ip route 199.99.3.0 255.255.255.0 199.99.2.2 到R2去的路由
ip route 199.99.4.0 255.255.255.0 199.99.2.2 到R3去的路由
Current configuration : 499 bytes
ip route 0.0.0.0 0.0.0.0 199.99.2.1 到R1的傳回路由
ip route 199.99.4.0 255.255.255.0 199.99.3.2 到R3的路由
r3#sh run
Current configuration : 420 bytes
hostname r3
ip address 199.99.4.1 255.255.255.0
ip address 199.99.3.2 255.255.255.0
ip route 0.0.0.0 0.0.0.0 199.99.3.1 隻有一條傳回路由就可以了。
r3#
S 199.99.4.0/24 [1/0] via 199.99.2.2
C 199.99.3.0/24 is directly connected, Serial1
S 199.99.4.0/24 [1/0] via 199.99.3.2
r3#sh ip route
Gateway of last resort is 199.99.3.1 to network 0.0.0.0
C 199.99.4.0/24 is directly connected, Ethernet0
S* 0.0.0.0/0 [1/0] via 199.99.3.1
實驗總結:
靜态路由使我們開始學習路由方面的第一步它也是我們經常用到的一種配置路由的方法,是我們以後學習其他動态路由協定的基礎,隻有完全了解了靜态路由的工作原理,并掌握了其配置方法才能更好的學習後面的各種動态路由協定。