- 拓扑图

- 步骤1:在各路由器上IP 地址,保证直连链路的连通性
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int
R1(config)#interface loo
R1(config)#interface loopback0
R1(config-if)#ip address 1.1.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#int
R1(config)#interface et
R1(config)#interface ethernet 1/0
R1(config-if)#ip add
R1(config-if)#ip address 192.168.1.1 255.255.255.0
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int loo
R2(config)#int loopback0
R2(config-if)#ip
*Mar 1 00:14:18.299: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
R2(config-if)#ip address
R2(config-if)#ip address 2.2.2.2 255.255.255.0
R2(config-if)#int e
R2(config-if)#exit
R2(config)#int
R2(config)#interface e1/0
R2(config-if)#ip addr
R2(config-if)#ip address 192.168.1.2 255.255.255.0
R2(config-if)# no shutdown
R2(config-if)#int e1/1
R2(config-if)#ip address 192.168.2.2 255.255.255.0
R2(config-if)#no shutdown
R3(config)#int loopback0
*Mar 1 00:17:16.819: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up
R3(config-if)#ip address 3.3.3.3 255.255.255.0
R3(config-if)#exit
R3(config)#int e1/0
R3(config-if)#ip address 192.168.2.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#no shutdown
- 步骤2:在R1 上配置静态路由
R1(config)#ip route 2.2.2.0 255.255.255.0 e1/0
//下一跳为接口形式,e1/0是点对点的链路,注意:应该是R1 上的e1/0
R1(config)#ip route 3.3.3.0 255.255.255.0 192.168.2.2
//下一跳为IP 地址形式,192.168.2.2 是R2 上的IP 地址
- 步骤3:在R2 上配置静态路由
R2(config)#ip route 1.1.1.0 255.255.255.0 e1/0
R2(config)#ip route 3.3.3.0 255.255.255.0 e1/1
- 步骤4:在R3 上配置静态路由
R3(config-if)#ip route 1.1.1.0 255.255.255.0 e1/0
R3(config)#ip route 2.2.2.0 255.255.255.0 e1/0
- 实验调试:在R1,R2,R3 上查看路由表



- 从各路由器的环回口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 的loopback 0 可以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 的loopback 0 应该可以ping 通R1 和R3 的loopback 9 接口
R2#ping 1.1.1.1 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 2.2.2.2
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 64/64/64 ms
R2#ping 3.3.3.3 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 2.2.2.2
..!!!
Success rate is 60 percent (3/5), round-trip min/avg/max = 60/64/68 ms
//从R3 的loopback 0 也应该可以ping 通R1 和R2 的loopback 9 接口
R3#ping 1.1.1.1 source loopback 0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
Packet sent with a source address of 3.3.3.3
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 96/98/100 ms
R3#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 3.3.3.3
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 64/64/64 ms
- 从R1 上ping 2.2.2.2,从R1 上ping 3.3.3.3
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 = 64/65/72 ms
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 = 64/66/72 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.1.2.1)
作为IP 数据包的源IP 地址。当R3 上响应R1 的数据包时,数据包是发向192.168.12.1 的。然而,由于R3 没有
192.168.12.0/24 的路由,数据包无法发送。即:数据包人R1 到了R3 后,无法返回R1 。