東南西北風

生活就像一杯加了糖的苦咖啡。
  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

模拟静态路由、默认路由实验

Posted on 2008-12-30 18:29  东南西北风  阅读(953)  评论(0)    收藏  举报
 

实验二:模拟静态路由、默认路由实验

 

一、 实验目的:

     1.掌握静态路由和默认路由的配置方法;

   2.理解静态路由和默认路由的意义和特点。

二、 实验要求:

利用静态路由、默认路由实现不同子网的通信。

三、 实验内容:

   

     基本概念

路由器在没有配置路由时,只能实现与它直连的网络间的通信,为了实现在更大范围的网络间通信,需要进行路由配置,路由包括静态路由、默认路由和动态路由几类。

1)、静态路由

  是一种由网管手工配置的路由路径,网管必需了解路由器的拓扑连接,通过手工方式指定路由路径,而且在网络拓扑发生变动时,也需要网管手工修改路由路径。

  (2)、默认路由

也是一种由网管手工配置的路由路径,它使路由器把所有地址不能识别的数据包通过指定的路径发送出去,由其它路由器进行处理。默认路由可看作是静态路由的特例,而且维护代价较低。 

3)、动态路由

  是一种通过某种路由协议,由路由器自学习到的路由,它不需要手工配置,而且可自动随着网络环境的变化而变化,维护代价很低,特别适合大范围的路由。

 

关键命令

   本实验的关键命令:

模式

命令

功能

(config)#

ip route address subnet-mask address

设置静态路由

(config)#

no ip route address subnet-mask address

删除静态路由

(config)#

ip route 0.0.0.0 0.0.0.0 address

设置默认路由

(config)#

no ip route 0.0.0.0 0.0.0.0 address

删除默认路由

#

show ip route

查看路由表

#

show ip interface brief

查看端口简表

1

如:

 

1

 网络192.168.2.0/24连接在路由器R2上,如果路由器R1收到了发往该网络的数据包,它应该把它送往R2,也即R2的端口10.0.0.2,这可以在R1上配置如下静态路由:

  ip route 192.168.2.0 255.255.255.0 10.0.0.2

  该命令告诉R1,遇到目的网络为192.168.2.0/24的数据包,就发送到10.0.0.2

  注意:在命令中前一个地址是个网络地址,其中的主机部分都写为0,它代表的是某个网络,而不是某台具体的设备。如果写成了某个主机的IP地址,则成了配置特定主机路由。

  另外也可以在R1上配置默认路由:

  ip route 0.0.0.0 0.0.0.0 10.0.0.2

  该命令是告诉R1,遇到目的地址无法识别的数据包就发送到10.0.0.2

  以上两种只需配置一种就可以使路由器R1能与192.168.2.0/24网络进行通信。

2、配置静态路由(两个实验)

静态路由实验1

按下图所示制作网络拓扑,路由器的型号自行选择(推荐805路由器),利用静态路由实现各网络间的通信。(假设R1S0端口DCE端)

 

router1的配置

Router>

Router>en

Router#conf t

Router(config)#hostname router1

router1(config)#interface e0

router1(config-if)#ip address 192.168.1.2 255.255.255.0

router1(config-if)#no shut

router1(config-if)#interface s0

router1(config-if)#ip address 192.168.2.1 255.255.255.0

router1(config-if)#clock rate 6400     //假设在设计拓扑图是定义Router1Serial 0端口为DCE端。

router1(config-if)#no shut

router1(config-if)#end

router1#config t

router1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.1   //设定静态路由

router1(config)#end

 

router2的配置:

Router>en

Router#conf t

Router#config t

Router(config)#hostname router2

router2(config)#interface s0

router2(config-if)#ip address 192.168.2.2 255.255.255.0

router2(config-if)#no shut

router2(config-if)#interface e0

router2(config-if)#ip address 192.168.3.1 255.255.255.0

router2(config-if)#no shut

router2(config-if)#end

router2#config t

router2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.2

router2(config)#end

router2#ping 192.168.1.2             //测试连通性

router2#ping 192.168.2.1

 

pc1的配置如下:

C:>ipconfig /ip 192.168.1.1 255.255.255.0 //设置IP地址和子网掩码,或者输入“w”,按回车,也可以输入IP地址、子网掩码和网关。

C:>ipconfig /dg 192.168.1.2 //指定网关为与本机直连的router1e0

 

pc2 的配置如下:

C:>ipconfig /ip 192.168.3.2 255.255.255.0

C:>ipconfig /dg 192.168.3.1         //IP和网关设好

C:>ping 192.168.1.1

C:>ping 192.168.1.2

C:>ping 192.168.2.1

C:>ping 192.168.2.2

C:>ping 192.168.3.1

 

在各个路由器的特权模式下运行show ip route查看路由表。 


静态路由实验2

按图2所示制作网络拓扑,路由器的型号自行选择(推荐R1选择1005路由器,R2选择1601路由器,其广域网接口选择1SerialR3选择1605路由器,广域网接口选择1Serial接口),DCE端请自行定义(这里我们把R1S0接口R2S1接口定义为DCE端),利用静态路由实现各网络间的通信。

 

2

  提示:在图2的拓扑中共有6个网络:190.1.0.0/16190.2.0.0/16200.200.1.0/24200.200.2.0/24200.200.3.0/24200.200.4.0/24,各路由器除了直连的网络外,其余的都由静态路由实现。一定要注意在DCE端配置同步时钟。

  结果分析:配置完成后,用ping命令检查,所有PC机之间都是可以连通的,查看各路由器的路由表,应能看到所有6个网络。

附:

1R1的静态路由配置

Router>

Router> en

Router# con

Router(config)# hostname R1

R1(config)# interface s0

R1(config-if)# ip address 190.1.0.1 255.255.0.0

R1(config-if)# no shutdown

R1(config-if)# clock rate 64000

R1(config-if)# interface e0

R1(config-if)# ip address 200.200.1.1 255.255.255.0

R1(config-if)# no shutdown

R1(config-if)# exit

R1(config)# ip route 200.200.2.0 255.255.255.0 190.1.0.2

R1(config)# ip route 200.200.3.0 255.255.255.0 190.1.0.2

R1(config)# ip route 200.200.4.0 255.255.255.0 190.1.0.2

R1(config)# ip route 190.2.0.0 255.255.0.0 190.1.0.2

R1(config)# end

查看R1的路由表:

R1# show ip route

C    200.200.1.0 is directly connected, Ethernet0

S    190.2.0.0 [1/0] via 190.1.0.2

C    190.1.0.0 is directly connected, Serial0

S    200.200.4.0 [1/0] via 190.1.0.2

S    200.200.3.0 [1/0] via 190.1.0.2

S    200.200.2.0 [1/0] via 190.1.0.2

2R2的静态路由配置

Router>

Router> en

Router# con

Router(config)# hostname R2

R2 (config)# interface s0

R2 (config-if)# ip address 190.1.0.2 255.255.0.0

R2(config-if)# no shutdown

R2 (config-if)# exit

R2 (config)# interface s1

R2 (config-if)# ip address 190.2.0.1 255.255.0.0

R2(config-if)# no shutdown

R2 (config-if)# clock rate 64000

R2(config-if)# exit

R2 (config)# interface e0

R2(config-if)# ip address 200.200.2.1 255.255.255.0

R2 (config-if)# no shutdown

R2 (config-if)# exit

R2 (config)# ip route 200.200.1.0 255.255.255.0 190.1.0.1

R2r(config)# ip route 200.200.3.0 255.255.255.0 190.2.0.2

R2 (config)# ip route 200.200.4.0 255.255.255.0 190.2.0.2

R2(config)# end

 

2R2的静态路由配置

R2# show ip route

C    190.1.0.0 is directly connected, Serial0

S   200.200.1.0 [1/0] via 190.1.0.1

S    200.200.3.0 [1/0] via 190.2.0.2

S    200.200.4.0 [1/0] via 190.2.0.2

C    200.200.2.0 is directly connected, Ethernet0

C    190.2.0.0 is directly connected, Serial1

3R3的静态路由配置

Router>

Router> en

Router# con

Router(config)# hostname R3

R3(config)# interface s0

R3(config-if)# ip address 190.2.0.2 255.255.0.0

R3(config-if)# no shutdown

R3(config-if)# exit

R3(config)# interface e0

R3(config-if)# ip address 200.200.3.1 255.255.255.0

R3 (config-if)# no shutdown

R3 (config-if)# interface e1

R3(config-if)# ip address 200.200.4.1 255.255.255.0

R3(config-if)# no shutdown

R3(config-if)# exit

R3(config)# ip route 190.1.0.0 255.255.0.0 190.2.0.1

R3(config)# ip route 200.200.1.0 255.255.255.0 190.2.0.1

R3(config)# ip route 200.200.2.0 255.255.255.0 190.2.0.1

R3(config)# end

 

R3# show ip route

C    190.2.0.0 is directly connected, Serial0

C    200.200.3.0 is directly connected, Ethernet0

C    200.200.4.0 is directly connected, Ethernet1

S    190.1.0.0 [1/0] via 190.2.0.1

S    200.200.1.0 [1/0] via 190.2.0.1

S    200.200.2.0 [1/0] via 190.2.0.1

PC机的配置略,但要注意

PC1的网关为200.200.1.1

PC2的网关为200.200.2.1

PC3的网关为200.200.3.1

PC4的网关为200.200.4.1

 

 


3、默认路由的配置

默认路由实验1

 

r1的配置

Router>

Router>en

Router#conf t

Router(config)#hostname router1

router1(config)#interface e0

router1(config-if)#ip address 192.168.1.2 255.255.255.0

router1(config-if)#no shut

router1(config-if)#interface s0

router1(config-if)#ip address 192.168.2.1 255.255.255.0

router1(config-if)#clock rate 64000 //假定Router1s0端为DCE端,也可以直接输入clock rate 64,按回车,配置的同步时钟也为64000

router1(config-if)#no shut

router1(config-if)#exit

router1(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.1

router1(config-if)#exit

router1(config)#exit

 

r2 的配置

Router>en

Router#conf t

Router(config)#hostname router2

router2 (config)#interface s0

router2 (config-if)#ip address 192.168.2.2 255.255.255.0

router2 (config-if)#no shut

router2 (config-if)#interface e0

router2 (config-if)#ip address 192.168.3.1 255.255.255.0

router2 (config-if)#no shut

router2 (config-if)#exit

router2 (config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2

router2 (config)#exit

router2#ping 192.168.1.2                      //先试ping下路由

 

pc1的配置

C:>ipconfig /ip 192.168.1.1 255.255.255.0

C:>ipconfig /dg 192.168.1.2

pc2的配置:

C:>ipconfig /ip 192.168.3.2 255.255.255.0

C:>ipconfig /dg 192.168.3.1

C:>ping 192.168.1.1                          //开始检测

C:>ping 192.168.1.2

C:>ping 192.168.2.1

C:>ping 192.168.2.2

 

在各个路由器的特权模式下运行show ip route查看路由表。

默认路由实验2

拓扑图仍使用静态路由实验2的拓扑图:

 

路由器各个端口的配置同静态路由完全相同,在此省略,只写出默认路由配置部分取代静态路由的配置部分。

R1的默认路由配置:

R1(config)# ip route 0.0.0.0 0.0.0.0 190.1.0.2

R2 与多个路由器相连,不适合配置默认路由,仍可使用静态路由。或者使用以下方法(不推荐)

R2 (config)# ip route 200.200.1.0 255.255.255.0 190.1.0.1

R2r(config)# ip route 0.0.0.0 0.0.0.0 190.2.0.2

R3的默认路由配置:

R3(config)# ip route 0.0.0.0 0.0.0.0 190.2.0.1