静态路由及实验配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了静态路由及实验配置相关的知识,希望对你有一定的参考价值。

静态路由是指由用户或者网络管理员手动配置的路由信息。当网络的拓扑结构或者链路的状态发生变化时,网络管理员需要手工修改路由表中相关的静态路由信息。静态路由信息在缺省情况下是私有的,不会传递给其他的路由器。一般来说,静态路由用于网络规模较小、拓扑结构相对固定的网络中。

静态路由的特点

  1. 允许对路由的行为进行精确的控制。由于静态路由是手工配置的,因此管理员可以通过静态路由来控制数据包在网络中的流动。
  2. 静态路由是单向的。也就是说如果希望实现双向的通信,必须在通信双方配置双向的静态路由。
  3. 静态路由的不足之处是缺乏灵活性。静态路由虽然能够对包通过路由器的路径对数据包进行精确控制,但同时也限制了它的灵活性。

实验环境

GNS 3 模拟器

实验拓扑图

技术分享图片

配置命令

路由器R1

R1>en
R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#int f0/0
R1(config-if)#ip add 192.168.2.1 255.255.255.0                #配置接口IP地址
R1(config-if)#no shut                    #开启接口
R1(config-if)#ex
*Mar  1 00:06:18.167: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:06:19.167: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config)#int f0/1
R1(config-if)#ip add 192.168.1.1 255.255.255.0                #配置接口IP地址
R1(config-if)#no shut                    #开启接口
R1(config-if)#ex
*Mar  1 00:06:36.879: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:06:37.879: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2     #添加路由
R1(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2     #添加路由
R1(config)#do 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

S    192.168.4.0/24 [1/0] via 192.168.2.2
C    192.168.1.0/24 is directly connected, FastEthernet0/1
C    192.168.2.0/24 is directly connected, FastEthernet0/0
S    192.168.3.0/24 [1/0] via 192.168.2.2
R1(config)#

路由器R2

R2>en
R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#int f0/0
R2(config-if)#ip add 192.168.2.2 255.255.255.0                #配置接口IP地址
R2(config-if)#no shut                      #开启接口
R2(config-if)#ex
R2(config)#int f0/
*Mar  1 00:08:49.555: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:08:50.555: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config)#int f0/1
R2(config-if)#ip add 192.168.3.1 255.255.255.0                #配置接口IP地址
R2(config-if)#no shut                    #开启接口
R2(config-if)#ex
R2(config)#ip route
*Mar  1 00:09:09.459: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:09:10.459: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1     #添加路由
R2(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.2     #添加路由
R2(config)#do 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

S    192.168.4.0/24 [1/0] via 192.168.3.2
S    192.168.1.0/24 [1/0] via 192.168.2.1
C    192.168.2.0/24 is directly connected, FastEthernet0/0
C    192.168.3.0/24 is directly connected, FastEthernet0/1
R2(config)#

路由器R3

R3>en
R3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#int f0/0
R3(config-if)#ip add 192.168.3.2 255.255.255.0                #配置接口IP地址
R3(config-if)#no shut                    #开启接口
R3(config-if)#ex
R3(config)#int f0
*Mar  1 00:06:18.167: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:06:19.167: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R3(config)#int f0/1
R3(config-if)#ip add 192.168.4.1 255.255.255.0                #配置接口IP地址
R3(config-if)#no shut                    #开启接口
R3(config-if)#ex
R3(config)#ip
*Mar  1 00:06:36.879: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:06:37.879: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R3(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.1     #添加路由
R3(config)#ip route 192.168.1.0 255.255.255.0 192.168.3.1     #添加路由
R3(config)#do 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.4.0/24 is directly connected, FastEthernet0/1
S    192.168.1.0/24 [1/0] via 192.168.3.1
S    192.168.2.0/24 [1/0] via 192.168.3.1
C    192.168.3.0/24 is directly connected, FastEthernet0/0
R3(config)#

实验结果

技术分享图片

以上是关于静态路由及实验配置的主要内容,如果未能解决你的问题,请参考以下文章

静态路由原理及实验

静态路由及默认路由实验配置

静态路由原理及配置(超详细实验进行验证)

实验静态路由配置

MSTP+VRRP+静态路由+子网划分+DHCP实验案例

静态路由及默认路由基本配置