静态路由

root
233
文章
0
评论
2020年4月17日21:49:09 评论 8036字阅读26分47秒

配置静态路由

三台路由器,做到R1通联R3

分别配置IP地址

R1: 172.16.10.1 g0/0/0

华为:

<R1>sys
Enter system view, return user view with Ctrl+Z.
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 172.16.10.1 24

R2: 172.16.10.2 g0/0/0

<R2>sys
Enter system view, return user view with Ctrl+Z.
[R1]int g0/0/0
[R1-GigabitEthernet0/0/0]ip add 172.16.10.2 24

       172.16.20.1 g0/0/1

<R2>sys
Enter system view, return user view with Ctrl+Z.
[R1]int g0/0/1
[R1-GigabitEthernet0/0/0]ip add 172.16.20.1 24

R3: 172.16.20.2 g0/0/1

<R3>sys
Enter system view, return user view with Ctrl+Z.
[R1]int g0/0/1
[R1-GigabitEthernet0/0/0]ip add 172.16.20.2 24

 

分别配置IP地址

R1,R3添加路由表

如果是多个设备,比如说5个路由器R1要和R5通讯,那么R1-->R3上都要添加R5路由表的信息,但是R4路由器上不用添加R5的路由表,因为它们是直连的方式

R5-->R3设备上都要添加R1路由表的信息,但是R2路由器上不用添加R1的路由表,因为它们是直连的方式

R1:    

R1路由器上把R3的网段信息交给R2

[R1]ip route-static 172.16.20.0 24 172.16.10.2
[R1]dis cur | in ip rou
ip route-static 172.16.20.0 255.255.255.0 172.16.10.2

 

R3:

R3路由器上把R1的网段信息交给R2

[R3]ip route-static 172.16.10.0 24 172.16.20.1 
[R3]dis cur | in ip rou ip 
route-static 172.16.10.0 255.255.255.0 172.16.20.1

测试互通

<R1>ping 172.16.20.2
  PING 172.16.20.2: 56  data bytes, press CTRL_C to break
    Reply from 172.16.20.2: bytes=56 Sequence=1 ttl=254 time=40 ms
    Reply from 172.16.20.2: bytes=56 Sequence=2 ttl=254 time=40 ms
    Reply from 172.16.20.2: bytes=56 Sequence=3 ttl=254 time=30 ms
    Reply from 172.16.20.2: bytes=56 Sequence=4 ttl=254 time=30 ms
    Reply from 172.16.20.2: bytes=56 Sequence=5 ttl=254 time=20 ms

  --- 172.16.20.2 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/32/40 ms
<R3>ping 172.16.10.1
  PING 172.16.10.1: 56  data bytes, press CTRL_C to break
    Reply from 172.16.10.1: bytes=56 Sequence=1 ttl=254 time=50 ms
    Reply from 172.16.10.1: bytes=56 Sequence=2 ttl=254 time=30 ms
    Reply from 172.16.10.1: bytes=56 Sequence=3 ttl=254 time=40 ms
    Reply from 172.16.10.1: bytes=56 Sequence=4 ttl=254 time=40 ms
    Reply from 172.16.10.1: bytes=56 Sequence=5 ttl=254 time=40 ms

  --- 172.16.10.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/40/50 ms

 

lookbak接口

lookback接口是一个虚拟的接口,也是通过物理线路,存在的目的就是当物理线路上的IP地址down的时候,可以通过lookback接口连接交换机进行操作,每一条都会占用设备的内存

现在有三个接口,要求R1通过lookback接口访问到R3设备

R3:[服务端】

     lookback 0

     10.1.1.1 24

     lookback 1

     10.1.2.1 24

     lookback 3

   10.1.3.1 24

<R3>sys
Enter system view, return user view with Ctrl+Z.
[R3]int l 0
[R3-LoopBack0]ip add 10.1.1.1 24

[R3]int l 1
[R3-LoopBack0]ip add 10.1.2.1 24

[R3]int l 2
[R3-LoopBack0]ip add 10.1.3.1 24

R1:【客户端】

[R1]ip route-static 10.10.0.0 22 172.16.10.2

R2: 【客户端】

[R2]ip route-static 10.10.0.0 22 172.16.20.2

测试连通性:

[R1]ping 10.1.1.1
  PING 10.1.1.1: 56  data bytes, press CTRL_C to break
    Reply from 10.1.1.1: bytes=56 Sequence=1 ttl=254 time=20 ms
    Reply from 10.1.1.1: bytes=56 Sequence=2 ttl=254 time=30 ms
    Reply from 10.1.1.1: bytes=56 Sequence=3 ttl=254 time=30 ms
    Reply from 10.1.1.1: bytes=56 Sequence=4 ttl=254 time=30 ms
    Reply from 10.1.1.1: bytes=56 Sequence=5 ttl=254 time=30 ms

  --- 10.1.1.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/28/30 ms
<R2>ping 10.1.2.1
  PING 10.1.2.1: 56  data bytes, press CTRL_C to break
    Reply from 10.1.2.1: bytes=56 Sequence=1 ttl=255 time=20 ms
    Reply from 10.1.2.1: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 10.1.2.1: bytes=56 Sequence=3 ttl=255 time=30 ms
    Reply from 10.1.2.1: bytes=56 Sequence=4 ttl=255 time=30 ms
    Reply from 10.1.2.1: bytes=56 Sequence=5 ttl=255 time=20 ms

  --- 10.1.2.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/24/30 ms

 

路由汇总【现网都要使用】

ip route-static 172.17.1.0 255.255.255.0 192.168.1.2 
ip route-static 172.17.2.0 255.255.255.0 192.168.1.2 
ip route-static 172.17.3.0 255.255.255.0 192.168.1.2

方式一:

  • ip route-static 172.17.0.0 255.255.255.0 192.168.1.2

缺点:

  • 范围太大

方式二:

更加精准的划分网段,VLSM的方式,比如这里就划分三个可用ip就行了

  • ip route-static 172.17.0.0 255.252.0

 

垃圾桶路由

有种三层环路情况是路由聚合+默认路由=环路

比如说:

R1的路由表中聚合的IP为 10.1.0.0 22

R2的路由表中向R1路由设置了默认路由0.0.0.0 0【一般都在最后一个或开始的地方】

这个时候R1 ping 10.1.0.1 应为这个0网络标签没有办法使用, 就会形成一个还路,R1与R2相互踢皮球,都认为对方才是接受人,只有当TTL值消耗完才会停下来

解决方法:

路由垃圾桶

在R1上配置

ip route-static 10.1.0.0 255.255.255.0 NULL0

现在在ping 10.1.0.1,通过抓包进行查看,一个包都抓不到,都去垃圾桶了

静态浮动路由

在静态路由里配置的方式一台路由器down机后备用路由能够立即接替工作,这种备用路由叫作浮动路由,首先你得实现全网通

在静态路由里,这里提一下思路,就是要设置多种线路连接到目的端,在到达目的端的路由表中,配置两个前提掩码一致IP网络地址一致,就通过调整AD值的大小来确定谁是主谁是备,路由表中只会显示出一条信息,当主设备挂掉后,备用路由的路由信息才会出现在路由表中

静态浮动路由练习

配置浮动静态路由,实现R1的lo0:1.1.1.1访问114.114.114.114的主线路为R1-R3-R4,备份线路为R1-R2-R4。要求来回路径一致,即R4回包,主线路为R4-R3-R1,备份线路为R4-R2-R1

R1路由器配置

[R1]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 14       Routes : 14       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.1.1.1/32  Direct  0    0           D   127.0.0.1       LoopBack0
       12.1.1.0/24  Direct  0    0           D   12.1.1.1        GigabitEthernet0/0/0
       12.1.1.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/0
     12.1.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/0
       13.1.1.0/24  Direct  0    0           D   13.1.1.1        GigabitEthernet0/0/1
       13.1.1.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/1
     13.1.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/1
       24.1.1.0/24  Static  60   0          RD   12.1.1.2        GigabitEthernet0/0/0
       34.1.1.0/24  Static  60   0          RD   13.1.1.2        GigabitEthernet0/0/1
114.114.114.114/32  Static  10   0          RD   13.1.1.2        GigabitEthernet0/0/1
      127.0.0.0/8   Direct  0    0           D   127.0.0.1       InLoopBack0
      127.0.0.1/32  Direct  0    0           D   127.0.0.1       InLoopBack0
127.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0

这里配置优先级不同的静态路由,路由器会选择最优先的一条加表,只会选择一条

[R1]ip route-static 114.114.114.114 255.255.255.255 13.1.1.2 preference 10

[R1]ip route-static 114.114.114.114 255.255.255.255 12.1.1.2

[R1]dis cur | in route
ip route-static 24.1.1.0 255.255.255.0 12.1.1.2
ip route-static 34.1.1.0 255.255.255.0 13.1.1.2
ip route-static 114.114.114.114 255.255.255.255 13.1.1.2 preference 10
ip route-static 114.114.114.114 255.255.255.255 12.1.1.2

R3路由器

[R3]ip route-static 114.114.114.114 255.255.255.255 34.1.1.2 preference 10

[R3]ip route-static 1.1.1.1 255.255.255.255 13.1.1.1 preference 10

[R3]dis cur | in route
ip route-static 1.1.1.1 255.255.255.255 13.1.1.1 preference 10
ip route-static 114.114.114.114 255.255.255.255 34.1.1.2 preference 10

R2路由器

[R2]ip route-static 1.1.1.1 255.255.255.255 34.1.1.1 preference 10

[R2]ip route-static 1.1.1.1 255.255.255.255 24.1.1.1

[R2]dis cur | in route                              
ip route-static 1.1.1.1 255.255.255.255 34.1.1.1 preference 10
ip route-static 1.1.1.1 255.255.255.255 24.1.1.1
ip route-static 12.1.1.0 255.255.255.0 24.1.1.1
ip route-static 13.1.1.0 255.255.255.0 34.1.1.1

R4路由器

[R4]dis cur | in route                                      
ip route-static 1.1.1.1 255.255.255.255 12.1.1.1
ip route-static 114.114.114.114 255.255.255.255 24.1.1.2

进行测试静态浮动路由

<R1>tracert 114.114.114.114
 traceroute to  114.114.114.114(114.114.114.114), max hops: 30 ,packet length: 40,press CTRL_C to break 
 1 13.1.1.2 30 ms  10 ms  10 ms 
 2 34.1.1.2 20 ms  30 ms  30 ms

然后关闭R3路由器的一个物理接口

[R3]dis ip int bri
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 1
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 1

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              34.1.1.1/24          up         up        
GigabitEthernet0/0/1              13.1.1.2/24          up         up        
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)
[R3]int g0/0/0

[R3-GigabitEthernet0/0/0]shutdown 

[R3]dis ip int bri
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 2
The number of interface that is DOWN in Protocol is 2

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              34.1.1.1/24          *down      down      
GigabitEthernet0/0/1              13.1.1.2/24          up         up        
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)
<R1>tracert 114.114.114.114
 traceroute to  114.114.114.114(114.114.114.114), max hops: 30 ,packet length: 40,press CTRL_C to break 
 1  *  *  * 
 2

测试了关闭一条路的接口还不行,要全部关闭

[R3]dis ip int bri
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 1
The number of interface that is DOWN in Physical is 3
The number of interface that is UP in Protocol is 1
The number of interface that is DOWN in Protocol is 3

Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              34.1.1.1/24          *down      down      
GigabitEthernet0/0/1              13.1.1.2/24          *down      down      
GigabitEthernet0/0/2              unassigned           down       down      
NULL0                             unassigned           up         up(s)
<R1>tracert 114.114.114.114
 traceroute to  114.114.114.114(114.114.114.114), max hops: 30 ,packet length: 40,press CTRL_C to break 
 1 12.1.1.2 50 ms  10 ms  10 ms 
 2 24.1.1.2 20 ms  20 ms  20 ms

 

在次开启R3的接口,路由选路再次恢复

<R1>tracert 114.114.114.114
 traceroute to  114.114.114.114(114.114.114.114), max hops: 30 ,packet length: 40,press CTRL_C to break 
 1 13.1.1.2 40 ms  1 ms  20 ms 
 2  * 34.1.1.2 40 ms  30 ms

 

OSPF动态浮动路由

使用直接修改的方式

 

 

 

继续阅读
weinxin
我的微信
这是我的微信扫一扫
  • 文本由 发表于 2020年4月17日21:49:09
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
OSPF综合练习 Route

OSPF综合练习

OSPF综合练习   IP地址规划 R5/R6/R7之间的网段为:172.16.146.X R5/R6/R2之间的网段为:172.16.100.X 所有路由器都有一个Loopbacck 0接...
IS-IS链路状态路由协议 Route

IS-IS链路状态路由协议

IS-IS链路状态路由协议   IS-IS的由来 IS-IS是国际标准组织ISO为OSI中的无连接网络协议CLNP设计的一种动态路由协议。 现网使用TCP/IP协议,为了提供对IP路由的支持...
路由引入 Route

路由引入

路由引入 什么情况下需要路由引入 不同的路由协议需要互相学习到对方的路由信息 外部路由协议的优先级全都按照OSPF外部路由优先级150计算   情况有很多种 单点单向重分发 单点双向重分发 ...
OSPF其它特性 Route

OSPF其它特性

OSPF其它特性 只要有5类 LSA或7类 LSA产生就会产生LSA 静默接口/被动接口 启用找接口,PC机不会收到hello包了,不收到LSA报文了 ospf silent-interface g0...
匿名

发表评论

匿名网友 填写信息

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: