实验七:动态态路由协议的配置
这个和实验六静态路由协议的配置差不很多:总结上次的经验,这次把每一步的步骤和代码详细跟着,上次为啦贪图方便,就把代码一股脑的全放上面拉,今天同学问我实验代码,我也是第一次推销我的博客,为了方便看,这次特意写的详细一点:
首先我先介绍一下与静态路由协议的配置的不同之处。
由手动添加路由表信息即静态路由协议配置如下:
pc1~px3切换到全局模式下,ip route 172.16.3.0 255.255.255.0 172.16.2.2
第一个是目的网路号,第二个是目的网路号对应的子网掩码,第三个是到目的网路的下一跳端口。
show ip route
pc3~pc1
ip route 172.16.1.0 255.255.255.0 172.16.2.1
show ip route
而现在动态路由协议的配置如下:在全局配置模式下:
R1:
route rip
network 172.16.1.0 网络号
network 172.16.2.0
退出
show ip route
R2:
route rip
network 172.16.2.0 网络号
network 172.16.3.0
退出
show ip route
具体配置如下:(一)先在下图上设置网络拓扑图如下:
选用路由器是选R3620,1sot 选一个因特网口和一个串口的,路由器R1,R2
选取交换机S2950,交换机s1,s2
R1~R2 串口serial0/0 指定数据通信端DCE,R,serial0/0
R1 0/1~s1 0/1.....R2 0/1~S2 0/1
最后添加路由表,r1和r2互通,p1,p2,p3设置好网关,
一共有三个网络,上图已标记清楚,
二;在下图上设置如下:
(1)首先设置好路由器,让路由器R1和R2可以相通。并测试
R1: enable
configure terminal
hostname R1
interface serial 0/0
ip address 172.16.2.1 255.255.255.0
clock rate 64000 DCE端
no shutdown
r1
Router>
Router>
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R1
R1(config)#interface serial 0/0
R1(config-if)#ip address 172.16.2.1 255.255.255.0
R1(config-if)#clock rate 64000
R1(config-if)#no shutdown
%LINK-3-UPDOWN: Interface Serial0/0, changed state to up
%LINK-3-UPDOWN: Interface Serial0/0, changed state to down
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down
%LINK-3-UPDOWN: Interface Serial0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to up
R1(config-if)#end
R1#
R2:
configure terminal
hostname R1
interface serial 0/0
ip address 172.16.2.2 255.255.255.0
DP端
no shutdown
Router>
Router>
Router>enable
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R2
R2(config)#interface serial 0/0
R2(config-if)#no shutdown
%LINK-3-UPDOWN: Interface Serial0/0, changed state to up
R2(config-if)#ip address 172.16.2.2 255.255.255.0
R2(config-if)#exit
R2(config)#exit
R2#
并测试R1和R2是否可以通信:ping 172.16.2.1
R2#ping 172.16.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 172.16.2.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
R2#
R2#
(2)设置网关并测试
R1
enable
configure terminal
interface ehternet 0/0以太网端口
ip address 172.16.1.1 255.255.255.0
no shutdown
R1(config-if)#end
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#interface ethernet 0/0
R1(config-if)#ip address 172.16.1.1 255.255.255.0
R1(config-if)#no shutdown
%LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
R1(config-if)#exit
R1(config)#exit
PC1
ipconfig /ip 172.16.1.2 255.255.255.0
ipconfig /dg 172.16.1.1 网关的设置,
ipconfig /all
Press Enter to begin
C:>
C:>ipconfig /ip 172.16.1.2 255.255.255.0
C:>ipconfig /dg 172.16.1.1
C:>ipconfig /all
HELP
Manipulates ip address for Workstation.
IPCONFIG [/ip] [/dg]
/ip Adds the ip address and subnet mask to the workstation
/dg Adds the default gateway to the workstation
Examples:
¢ ipconfig /ip 157.1.1.12 255.0.0.0
¢ ipconfig /dg 157.1.1.1
Boson BOSS 5.0 IP Configuration
Ethernet adapter Local Area Connection:
IP Address. . . . . . . . . . . . : 172.16.1.2
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 172.16.1.1
You can also use winipcfg to configure the IP Address
Ethernet adapter Local Area Connection:
Description . . . . . . . . . . . : Realtek RTL8139/810X Family PCI Fast
Ethernet NIC
Physical Address. . . . . . . . . : 000C.8975.3749
PC2
ipconfig /ip 172.16.1.3 255.255.255.0
ipconfig /dg 172.16.1.1 网关的设置,
ipconfig /all
C:>
C:>
C:>ipconfig /ip 172.16.1.3 255.255.255.0
C:>ipconfig /dg 172.16.1.1
C:>ipconfig /all
HELP
Manipulates ip address for Workstation.
IPCONFIG [/ip] [/dg]
/ip Adds the ip address and subnet mask to the workstation
/dg Adds the default gateway to the workstation
Examples:
¢ ipconfig /ip 157.1.1.12 255.0.0.0
¢ ipconfig /dg 157.1.1.1
Boson BOSS 5.0 IP Configuration
Ethernet adapter Local Area Connection:
IP Address. . . . . . . . . . . . : 172.16.1.3
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 172.16.1.1
You can also use winipcfg to configure the IP Address
Ethernet adapter Local Area Connection:
Description . . . . . . . . . . . : Realtek RTL8139/810X Family PCI Fast
R2
enable
configure terminal
interface ehternet 0/0以太网端口
ip address 172.16.3.1 255.255.255.0
no shutdown
R2#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#interface enternet 0/0
R2(config-if)#ip address 172.16.3.1 255.255.255.0
R2(config-if)#no shutdown
%LINK-3-UPDOWN: Interface Ethernet0/0, changed state to up
R2(config-if)#exit
PC3
ipconfig /ip 172.16.3.2 255.255.255.0
ipconfig /dg 172.16.3.1 网关的设置,
ipconfig /all
C:>
C:>ipconfig /ip 172.16.3.2 255.255.255.0
C:>ipconfig /dg 172.16.3.1
C:>ipconfig /all
HELP
Manipulates ip address for Workstation.
IPCONFIG [/ip] [/dg]
/ip Adds the ip address and subnet mask to the workstation
/dg Adds the default gateway to the workstation
Examples:
¢ ipconfig /ip 157.1.1.12 255.0.0.0
¢ ipconfig /dg 157.1.1.1
Boson BOSS 5.0 IP Configuration
Ethernet adapter Local Area Connection:
IP Address. . . . . . . . . . . . : 172.16.3.2
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 172.16.3.1
You can also use winipcfg to configure the IP Address
Ethernet adapter Local Area Connection:
Description . . . . . . . . . . . : Realtek RTL8139/810X Family PCI Fast
Ethernet NIC
测试pc1到R1左端能否通信:
C:>ping 172.16.1.1
Pinging 172.16.1.1 with 32 bytes of data:
Reply from 172.16.1.1: bytes=32 time=60ms TTL=241
Reply from 172.16.1.1: bytes=32 time=60ms TTL=241
Reply from 172.16.1.1: bytes=32 time=60ms TTL=241
Reply from 172.16.1.1: bytes=32 time=60ms TTL=241
Reply from 172.16.1.1: bytes=32 time=60ms TTL=241
Ping statistics for 172.16.1.1: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>
C:>
测试pc3到R2左端
C:>ipconfig /ip 172.16.3.2 255.255.255.0
C:>ipconfig /dg 172.16.3.1
C:>ping 172.16.3.1
Pinging 172.16.3.1 with 32 bytes of data:
Reply from 172.16.3.1: bytes=32 time=60ms TTL=241
Reply from 172.16.3.1: bytes=32 time=60ms TTL=241
Reply from 172.16.3.1: bytes=32 time=60ms TTL=241
Reply from 172.16.3.1: bytes=32 time=60ms TTL=241
Reply from 172.16.3.1: bytes=32 time=60ms TTL=241
Ping statistics for 172.16.3.1: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
(3)本次实验的重点内容如下:
切换到R1特权模式下show ip route
R1#show 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
E1 - OSPF external type 1, E2 - OSPF 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
172.16.0.0/24 is subnetted, 2 subnets
C 172.16.2.0 is directly connected, Serial0/0
C 172.16.1.0 is directly connected, Ethernet0/0
可以看出与R1直接相连的网络有两条:172.16.2.0和172.16.1.0
R1上分组转发到pc3上,需要自学习:算法如下:
启动rip算法
进入到全局配置模式下:
route rip
路由配置模式下:
network 172.16.1.0 网络号
network 172.16.2.0
都是和R1直接相连的两个网络号
R1#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#route rip
R1(config-router)#network 172.16.1.0
R1(config-router)#
R1(config-router)#network 172.16.2.0
R1(config-router)#exit
R1(config)#exit
R2配置如下:
进入到全局配置模式下:
route rip
路由配置模式下:
network 172.16.2.0 网络号
network 172.16.3.0
都是和R2直接相连的两个网络号
最后测试如下:
pc1到pc3
ping 172.16.3.2
C:>ping 172.16.3.2
Pinging 172.16.3.2 with 32 bytes of data:
Reply from 172.16.3.2: bytes=32 time=60ms TTL=241
Reply from 172.16.3.2: bytes=32 time=60ms TTL=241
Reply from 172.16.3.2: bytes=32 time=60ms TTL=241
Reply from 172.16.3.2: bytes=32 time=60ms TTL=241
Reply from 172.16.3.2: bytes=32 time=60ms TTL=241
Ping statistics for 172.16.3.2: Packets: Sent = 5, Received = 5, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 50ms, Maximum = 60ms, Average = 55ms
C:>
r1路由信息如下:
R1#show 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
E1 - OSPF external type 1, E2 - OSPF 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
172.16.0.0/24 is subnetted, 3 subnets
C 172.16.1.0 is directly connected, Serial0/0
C 172.16.2.0 is directly connected, Ethernet0/0
R 172.16.3.0 [120/1] via 172.16.3.1, 00:08:41, Serial0/0
pc3到pc1如下:
C:>ping 172.16.1.2
Pinging 172.16.1.2 with 32 bytes of data:
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Request timed out.
Ping statistics for 172.16.1.2:
Packets: Sent = 5, Received = 0, Lost = 5 (100% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
r2路由信息如下:
R2#show 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
E1 - OSPF external type 1, E2 - OSPF 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
172.16.0.0/24 is subnetted, 3 subnets
C 172.16.2.0 is directly connected, Serial0/0
C 172.16.3.0 is directly connected, Ethernet0/0
R 172.16.1.0 [120/1] via 172.16.2.1, 00:08:41, Serial0/0
上面这行代码解释如下:1.0 这个为目的网络号 ,via经过2.0,通信时间,端口号。至此测试完毕