静态路由2

实验目的:

1、 路由表的概念

2、 Ip route 命令的使用

3、 根据要求正确配置静态路由

实验拓扑:

1

实验步骤:

1、 在各个路由器上配置IP地址,并保证直连链路的连通性(这个火星人都知道)

2、 在R1、R2、R3上分别配置静态路由

R1(config)#ip route 3.3.3.0 255.255.255.0 12.0.0.2 //目标网络3.3.3.0

R1(config)#ip route 2.2.2.2 255.255.255.255 12.0.0.2 //目标主机3.3.3.3,注意掩码

3、 在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

1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

2.0.0.0/32 is subnetted, 1 subnets

S 2.2.2.2 [1/0] via 12.0.0.2

3.0.0.0/24 is subnetted, 1 subnets

S 3.3.3.0 [1/0] via 12.0.0.2

12.0.0.0/24 is subnetted, 1 subnets

C 12.0.0.0 is directly connected, Serial2/1

R1#

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

1.0.0.0/24 is subnetted, 1 subnets

S 1.1.1.0 [1/0] via 12.0.0.1

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 [1/0] via 23.0.0.3

23.0.0.0/24 is subnetted, 1 subnets

C 23.0.0.0 is directly connected, Serial2/1

12.0.0.0/24 is subnetted, 1 subnets

C 12.0.0.0 is directly connected, Serial2/2

R2#

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 [1/0] via 23.0.0.2

2.0.0.0/24 is subnetted, 1 subnets

S 2.2.2.0 [1/0] via 23.0.0.2

3.0.0.0/24 is subnetted, 1 subnets

C 3.3.3.0 is directly connected, Loopback0

23.0.0.0/24 is subnetted, 1 subnets

C 23.0.0.0 is directly connected, Serial2/2

R3#

4、 实验调试

R1#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 = 4/42/88 ms

R1#

//从R1上的loopback0可以ping通R2上的loopbacl0,我们也可以直接使用以下命令:

R1#ping 2.2.2.2 source 1.1.1.1

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 = 8/30/44 ms

R1#

其他同理,需要指明源接口,虽然我们从R1的loopback0可以ping通R3上的loopback0,数据包需要经过23.0.0.0/24的路由。路由器转发数据包时完全根据路由表进行转发。但是当R1的loopback0口ping R3的loopback0时,IP数据包的源IP为1.1.1.1,目标IP为3.3.3.3.R1路由器首先查找路由表,数据包被发送到R2(12.0.0.2),R2路由器也进行路由表查询发现存在(3.3.3.0/24)路由条目,那么数据报被发送到了R3上,R3知道3.3.3.0/24为直连路由,那么R3就开始响应R1的数据包,进行的过程类似。

那么我们不添加源IP或接口会是什么现象呢?

R1#debug ip packet detail

IP packet debugging is on (detailed)

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:

*Jul 23 13:41:34.727: IP: tableid=0, s=12.0.0.1 (local), d=3.3.3.3 (Serial2/1), routed via FIB

*Jul 23 13:41:34.731: IP: s=12.0.0.1 (local), d=3.3.3.3 (Serial2/1), len 100, sending

*Jul 23 13:41:34.735: ICMP type=8, code=0.

*Jul 23 13:41:36.727: IP: tableid=0, s=12.0.0.1 (local), d=3.3.3.3 (Serial2/1), routed via FIB

*Jul 23 13:41:36.731: IP: s=12.0.0.1 (local), d=3.3.3.3 (Serial2/1), len 100, sending

*Jul 23 13:41:36.731: ICMP type=8, code=0.

*Jul 23 13:41:38.727: IP: tableid=0, s=12.0.0.1 (local), d=3.3.3.3 (Serial2/1), routed via FIB

*Jul 23 13:41:38.731: IP: s=12.0.0.1 (local), d=3.3.3.3 (Serial2/1), len 100, sending

*Jul 23 13:41:38.731: ICMP type=8, code=0.

*Jul 23 13:41:40.735: IP: tableid=0, s=12.0.0.1 (local), d=3.3.3.3 (Serial2/1), routed via FIB

*Jul 23 13:41:40.739: IP: s=12.0.0.1 (local), d=3.3.3.3 (Serial2/1), len 100, sending

*Jul 23 13:41:40.743: ICMP type=8, code=0.

*Jul 23 13:41:42.747: IP: tableid=0, s=12.0.0.1 (local), d=3.3.3.3 (Serial2/1), routed via FIB

*Jul 23 13:41:42.751: IP: s=12.0.0.1 (local), d=3.3.3.3 (Serial2/1), len 100, sending

*Jul 23 13:41:42.755: ICMP type=8, code=0.

Success rate is 0 percent (0/5)

R1#u all

显示数据包发送出去没有响应,这是为什么呢?我们再次根据转发数据完全是根据路由表进行转发的。以上ping不同的原因是什么呢?在于我们使用ping命令时,如果不指明源接口的话,则R1路由器使用Serial2/1接口的IP地址(12.0.0.1)作为IP数据包的源IP地址。但是在R3上的路由表中不存在12.0.0.0/24的路由条目,所以在R3响应R1数据包时,数据包时无法发送回去!即:数据包从R1到了R3后,就无法回到R1了。

你可能感兴趣的:(资源,路由器,管理员,休闲,路由表)