思科Cisco静态路由配置实例 - 鲨鱼抓包
首页 博客文章 思科Cisco静态路由配置实例

思科Cisco静态路由配置实例

日期: 2022年5月21日 02:31
阅读: 48
作者: 鲨鱼抓包

摘要: 在CCNA课程中除了TCP/IP协议栈学习就的各种路由和协议的配置,静态路由配置是其中比较简单,但是又比较中要的内容,这篇文章详细讲解思科Cisco静态路由配置实验。

在CCNA课程中除了TCP/IP协议栈学习就的各种路由和协议的配置,静态路由配置是其中比较简单,但是又比较中要的内容,这篇文章详细讲解思科Cisco静态路由配置实验。

思科Cisco静态路由配置实例

一、实验IP地址配置

1.R1配置:

R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#interface f0/0
R1(config-if)#ip address 10.1.1.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#
*Mar  1 00:01:04.119: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:01:05.119: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0,           changed state to up
R1(config-if)#end
R1#
*Mar  1 00:01:06.919: %SYS-5-CONFIG_I: Configured from console by console
R1#write memory
Building configuration...
[OK]

2.R2配置:

R2#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#interface f0/0
R2(config-if)#ip address 10.1.1.2 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#end
R2#
*Mar  1 00:01:40.871: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
R2#
*Mar  1 00:01:41.519: %SYS-5-CONFIG_I: Configured from console by console
*Mar  1 00:01:41.871: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2#write memory
Building configuration...
[OK]

 

R2#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#interface f0/1
R2(config-if)#ip address 10.1.2.1 255.255.255.0
R2(config-if)#no shutdown
R2(config-if)#end
R2#
*Mar  1 00:02:41.411: %SYS-5-CONFIG_I: Configured from console by console
R2#
*Mar  1 00:02:41.491: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:02:42.491: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R2#write memory
Building configuration...
[OK]

 3.R3配置:

R3#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#interface f0/0
R3(config-if)#ip address 10.1.2.2 255.255.255.0
R3(config-if)#no shutdown
R3(config-if)#end
R3#
*Mar  1 00:02:40.235: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
R3#
*Mar  1 00:02:41.071: %SYS-5-CONFIG_I: Configured from console by console
*Mar  1 00:02:41.235: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R3#write memory
Building configuration...
[OK]

4.R1 ping R2

R1#ping 10.1.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.2.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

 5.查看路由表

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

     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, FastEthernet0/0

只有一条直连路由指向R1所在网段。

二、静态路由配置

1.配置静态路由

R1#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#ip route 10.1.2.0 255.255.255.0 f0/0

//ip route【配置路由协议语法】
//10.1.2.0   255.255.255.0 【目标网络号和掩码=网段】
//f0/0【是R1的出接口】

这时候R1 ping R2的0/1接口就可以了,但是R1 ping R3的0/0还是不行,是因为ICMP协议有去有回,在R3所在网段找不到R1的出接口。

配置R3的路由协议:R3(config)#ip route   10.1.1.0   255.255.255.0   10.1.2.1
//这里最后的10.1.2.1是下一跳的地址,表示数据包通过10.1.2.1这个地址向下传

2.查看路由表

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

     10.0.0.0/24 is subnetted, 2 subnets
S       10.1.2.0 is directly connected, FastEthernet0/0
C       10.1.1.0 is directly connected, FastEthernet0/0

3.查看连接情况

R1#ping 10.1.2.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.2.1, timeout is 2 seconds:
.!!!!
Success rate is 80 percent (4/5), round-trip min/avg/max = 8/21/36 ms
R1#ping 10.1.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.2.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)

可以看出来连通情况,这时候R1 ping R2的0/1接口就可以了,但是R1 ping R3的0/0还是不行,是因为ICMP协议有去有回,在R3所在网段找不到R1的出接口。

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

     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.2.0 is directly connected, FastEthernet0/0

4.配置R3静态路由

R3#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#ip route 10.1.1.0 255.255.255.0 10.1.2.1
//这里最后的10.1.2.1是下一跳的地址,表示数据包通过10.1.2.1这个地址向下传

 

R3(config)#end
R3#
*Mar  1 00:33:08.487: %SYS-5-CONFIG_I: Configured from console by console
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

     10.0.0.0/24 is subnetted, 2 subnets
C       10.1.2.0 is directly connected, FastEthernet0/0
S       10.1.1.0 [1/0] via 10.1.2.1

5.再次查看连通情况

R1#ping 10.1.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.1.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/22/36 ms

 

鲨鱼博客版权说明:本站文章以原创为主,部分来自网络,请转载时保留原文链接!
# 相关文章
回顶部