静态路由中的默认路由配置方法,默认路由和静态路由配置

1、实验目的

掌握如下技能:

(1) 路由表的概念

(2) ip route 命令的使用

(3) 根据需求正确配置静态路由

2. 实验拓扑

静态路由及默认路由实战,一分钟掌握正确配置静态路由方法

3. 实验步骤

我们要使得 1.1.1.0/24、2.2.2.0/24、3.3.3.0/24 网络之间能够互相通信。

(1) 步骤 1:在各路由器上配置 IP 地址、保证直连链路的连通性

R1(config)# int loopback0

R1(config-if)# ip address 1.1.1.1 255.255.255.0

R1(config)# int s0/0/0

R1(config-if)# ip address 192.168.12.1 255.255.255.0

R1(config-if)# no shutdown

R2(config)# int loopback0

R2(config-if)# ip address 2.2.2.2 255.255.255.0

R2(config)# int s0/0/0

R2(config-if)# clock rate 128000

R2(config-if)# ip address 192.168.12.2 255.255.255.0

R2(config-if)# no shutdown

R2(config)# int s0/0/1

R2(config-if)# clock rate 128000

R2(config-if)# ip address 192.168.23.2 255.255.255.0

R2(config-if)# no shutdown

R3(config)# int loopback0

R3(config-if)# ip address 3.3.3.3 255.255.255.0

R3(config)# int s0/0/1

R3(config-if)# ip address 192.168.23.3 255.255.255.0

R3(config-if)# no shutdown

(2) 步骤 2:R1 上配置静态路由

R1(config)# ip route 2.2.2.0 255.255.255.0 s0/0/0

//下一跳为接口形式,s0/0/0 是点对点的链路,注意应该是 R1 上的 s0/0/0 接口

R1(config)# ip route 3.3.3.0 255.255.255.0 192.168.12.2

//下一跳为 IP 地址形式,192.168.12.2 是 R2 上的 IP 地址

(3) 步骤 3:R2 上配置静态路由

R2(config)# ip route 1.1.1.0 255.255.255.0 s0/0/0

R2(config)# ip route 3.3.3.0 255.255.255.0 s0/0/1

(4) 步骤 4:R3 上配置静态路由

R3(config)# ip route 1.1.1.0 255.255.255.0 s0/0/1

R3(config)# ip route 2.2.2.0 255.255.255.0 s0/0/1

4. 实验调试

(1) 在 R1、R2、R3 上查看路由表

R1# show ip route

Codes: C – connected, S – static, 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

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 192.168.12.0/24 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

2.0.0.0/24 is subnetted, 1 subnets

S 2.2.2.0 is directly connected, Serial0/0/0

3.0.0.0/24 is subnetted, 1 subnets

S 3.3.3.0 [1/0] via 192.168.12.2

2.0.0.0/24 is subnetted, 1 subnets

S 2.2.2.0 is directly connected, Serial0/0/0

3.0.0.0/24 is subnetted, 1 subnets

S 3.3.3.0 [1/0] via 192.168.12.2

R2# show ip route

Codes: C – connected, S – static, 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

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 192.168.12.0/24 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

S 1.1.1.0 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

S 1.1.1.0 is directly connected, Serial0/0/0

2.0.0.0/24 is subnetted, 1 subnets

C 2.2.2.0 is directly connected, Loopback0

3.0.0.0/24 is subnetted, 1 subnets

S 3.3.3.0 is directly connected, Serial0/0/1

3.0.0.0/24 is subnetted, 1 subnets

S 3.3.3.0 is directly connected, Serial0/0/1

C 192.168.23.0/24 is directly connected, Serial0/0/1

R3# show ip route

Codes: C – connected, S – static, 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

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

1.0.0.0/24 is subnetted, 1 subnets

S 1.1.1.0 is directly connected, Serial0/0/1

2.0.0.0/24 is subnetted, 1 subnets

S 2.2.2.0 is directly connected, Serial0/0/1

1.0.0.0/24 is subnetted, 1 subnets

S 1.1.1.0 is directly connected, Serial0/0/1

2.0.0.0/24 is subnetted, 1 subnets

S 2.2.2.0 is directly connected, Serial0/0/1

3.0.0.0/24 is subnetted, 1 subnets

C 3.3.3.0 is directly connected, Loopback0

C 192.168.23.0/24 is directly connected, Serial0/0/1

(2) 从各路由器的环回口 ping 其他路由器的环回口:

R1# ping

//不带任何参数的 ping 命令,允许我们输入更多的参数

Protocol [ip]:

Target IP address: 2.2.2.2 //目标 IP 地址

Repeat count [5]: //发送的 ping 次数

Datagram size [100]: //ping 包的大小

Timeout in seconds [2]: //超时时间

Extended commands [n]: y //是否进一步扩展命令

Source address or interface: 1.1.1.1 //源 IP 地址

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]:

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

Packet sent with a source address of 1.1.1.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/14/16 ms

//以上说明从 R1 的 loopback0 可以 ping 通 R2 上的 loopback0。也可以直接使用命令:

R1# ping 2.2.2.2 source loopback 0

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

Packet sent with a source address of 1.1.1.1

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/14/16 ms

R2# ping 1.1.1.1 source loopback 0

R2# ping 3.3.3.3 source loopback 0

//从 R2 的 loopback0 应该可以 ping 通 R1 和 R3 的 lopback0 接口。

R3# ping 1.1.1.1 source loopback 0

R3# ping 2.2.2.2 source loopback 0

//从 R3 的 loopback0 也应该可以 ping 通 R1 和 R2 的 lopback0 接口。

【提示】虽然从 R1 的 loopback0 可以 ping 通 R3 的 loopback0,数据需要经过

192.168.23.0/24 网络,但是在 R1 上我们并没有添加 192.168.23.0/24 的路由。路由器转

发数据包完成是根据路由表的,并且数据是一跳一跳地被转发的,就像接力赛似的。从 R1

的loopback0口ping R3的loopback0口时,IP数据包的源IP为1.1.1.1,目的IP为3.3.3.3。

R1 路由器首先查路由表,数据包被发到了 R2;R2 路由器也查路由表(3.3.3.0/24 路由),

数据包被发到了 R3;R3 知道这是直连路由。R3 响应 R1 的数据包进行类似的过程。

(3) 从 R1 上 ping 2.2.2.2、从 R1 上 ping 3.3.3.3

R1# ping 2.2.2.2

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/14/16 ms

//可以 ping 通。

R1# ping 3.3.3.3

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:

…..

Success rate is 0 percent (0/5)

//以上无法ping通,原因在于使用ping命令时,如果不指明源接口,则R1路由器使用s0/0/0

接口的 IP 地址(192.168.12.1)作为 IP 数据包的源 IP 地址了。R3 上响应 R1 的数据包时,

数据包是发向 192.168.12.1 的,然而由于 R3 没有 192.168.12.0/24 的路由,数据包无法发

送。即:数据包从 R1 到了 R3 后,无法返回 R1。

5. 静态路由

在实验 1 的基础上进行

(1) 步骤 1:R1、R3 上删除原有静态路由

R1(config)# no ip route 2.2.2.0 255.255.255.0 Serial0/0/0

//要删除路由,在原有命令前面加 no 即可

R1(config)# no ip route 3.3.3.0 255.255.255.0 192.168.12.2

R3(config)# no ip route 1.1.1.0 255.255.255.0 Serial0/0/1

R3(config)# no ip route 2.2.2.0 255.255.255.0 Serial0/0/1

(2) 步骤 2: R1、R3 上配置默认路由

R1(config)# ip route 0.0.0.0 0.0.0.0 s0/0/0

R3(config)# ip route 0.0.0.0 0.0.0.0 s0/0/1

声明:本网页内容旨在传播知识,若有侵权等问题请及时与本网联系,我们将在第一时间删除处理。E-MAIL:dandanxi6@qq.com

(0)
上一篇 2023年 9月 12日 下午12:25
下一篇 2023年 9月 12日 下午12:32

相关推荐

  • 学棋3小时浪费2小时?你需要掌握这5个方法英语

    对于正在学习国际象棋得小棋手和国际象棋爱好者来说,如何充分利用有限的时间,提高自己练棋的效率,进而提高棋力水平?看看下面这5点。 01、认清自己的实力 制定计划是很多人开始做一件事…

    2023年 8月 26日
  • 原来微信长按2秒还隐藏着10个功能

    大家每天都在使用微信,它里面其实有很多小功能,学会了非常实用! 可能很多朋友还没有发现!微信长按2秒,其实可以打开10个隐藏功能,好用还方便,相信您看完这篇文章,一定有所收获! 1…

    2023年 1月 19日
  • 美图秀秀抠图怎么把抠出来的单独保存

    王先生 happy birthday 人生进度3⃣0⃣岁啦!往后余生 大宝贝小宝贝都会在你身边 我亲爱的王先生 谢谢你 做我和宝宝的盖世英雄 愿你在未来的日子里一如既往的宠我✨“三…

    2023年 6月 6日
  • 作业帮智能教辅怎么用

    学习焦虑,其实不仅仅是孩子,也是很多家长的焦虑,不要说小升初,从四五年级开始,对于孩子学习问题,家长们都开始发愁。因为随着年段的提升,学习的内容也并不像小学二三年级那么简单,而且很…

    2023年 6月 1日
  • cad怎么标注尺寸基本操作,如何修改cad标注尺寸数字大小

    很多从事CAD制图的朋友都了解,图纸中尺寸标注是比较重要的一点,标注功能可以帮助我们分辨CAD图纸中的图层位置关系等,把图层、形状进行数字化,更直观的表达出来,也是施工员判定的主要…

    2023年 1月 31日
  • windows 无法连接到此网络

    试图连接到网络时遇到错误?不要担心,并执行这些简单有效的解决办法。 在过去的几年里,计算机和互联网已经成为同义词。每当你打开电脑,你首先要检查的是你是否连接到了互联网。然而,许多用…

    2023年 6月 14日
  • 发财中国年集卡分5亿2021

    既支付宝集五福之后,今天头条本年又来了集生肖卡平分红包的活动,意图就是让我们开开心心的过个兴隆的大年,而自己途径又能获益许多新用户,一举两得的事。 下面来说说怎样集生肖卡? 一、能…

    2023年 3月 18日
  • app软件开发流程

    一款app的开发,从开发萌发想法到app上架用户使用,期间需要多人的配合和严谨的开发流程步骤,下面我们那山东艾思软件科技有限公司的开发步骤举例: 1. 需求分析:确定app的功能、…

    互联网 2023年 7月 13日
  • 农业银行绑定微信余额提醒,中国农业银行微信公众号查询余额

    农业银行绑定微信查询余额的方法是在微信中打开“中国农业银行”公众号,在业务大厅中打开我的账户,登录进入即可查看银行卡的余额。 01 怎么查询 详细操作步骤如下: 1、在微信首页,点…

    2023年 2月 22日
  • 自己安装的windows10系统怎么激活

    给电脑安装系统是一个工作中可能会遇到的一个问题,网络上一堆安装教程五花八门,一不小心就安装了自带很多广告和病毒的系统,本文就教你从零开始安装最新纯净版windows10系统,并数字…

    2023年 9月 9日