HCIA-静态路由

本文介绍了静态路由的基本原理,特别强调了其在小型、简单网络环境中的应用。默认路由作为静态路由的一种,用于在找不到匹配目的地址时的数据包转发。文章还提及了静态路由特殊情况,即下一跳为出接口的配置,并提到了在以太网中启用代理ARP以实现全网互通的重要性。同时,还指导了如何查看ARP表和路由表以验证配置效果。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

静态路由

原理

静态路由是管理员手动配置的路由,相比于动态路由协议,静态路由无需频繁的交换各自的路由表,配置简单,适合小型,简单的网络环境

默认路由是一种特殊的静态路由,当路由表中与数据包目的地址没有匹配的表项时,数据包根据默认路由条目进行转发。默认路由在某些时候非常有效,如在末梢网络中,默认路由可以简化路由器配置,减轻网管成本。

拓扑图

在这里插入图片描述

配置命令

<!--
ip routing-static 目的网段 掩码 下一条/出接口
(删除)undo ip routing-static 目的网段 掩码 下一条/出接口
-->
<!--R1和R3通信-->
[R1]ip route-static 192.168.2.0 24 192.168.1.2(请求包)
[R3]ip route-static 192.168.1.0 24 192.168.2.2(响应包)
r1静态路由
ip route-static 192.168.2.0 255.255.255.0 192.168.1.2
ip route-static 192.168.3.0 255.255.255.0 192.168.1.2
ip route-static 192.168.4.0 255.255.255.0 192.168.1.2
r2静态路由
ip route-static 192.168.3.0 255.255.255.0 192.168.2.3
ip route-static 192.168.4.0 255.255.255.0 192.168.2.3
r3静态路由
ip route-static 192.168.1.0 255.255.255.0 192.168.2.2
ip route-static 192.168.4.0 255.255.255.0 192.168.3.4
r4静态路由
ip route-static 192.168.1.0 255.255.255.0 192.168.3.3
ip route-static 192.168.2.0 255.255.255.0 192.168.3.3
r5静态路由
ip route-static 192.168.1.0 255.255.255.0 192.168.4.4
ip route-static 192.168.2.0 255.255.255.0 192.168.4.4
ip route-static 192.168.3.0 255.255.255.0 192.168.4.4
r1 ping r5 测试能ping通
ping 192.168.4.5
  PING 192.168.4.5: 56  data bytes, press CTRL_C to break
    Reply from 192.168.4.5: bytes=56 Sequence=1 ttl=252 time=50 ms
    Reply from 192.168.4.5: bytes=56 Sequence=2 ttl=252 time=40 ms
    Reply from 192.168.4.5: bytes=56 Sequence=3 ttl=252 time=40 ms
    Reply from 192.168.4.5: bytes=56 Sequence=4 ttl=252 time=40 ms
    Reply from 192.168.4.5: bytes=56 Sequence=5 ttl=252 time=40 ms

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

特殊情况-静态路由的下一跳为出接口

在这里插入图片描述

当以太网网络中,如果下一跳地址是一个AR8的g/0/0口而不是192.168.1.2时,在AR8的g0/0/0口和g0/0/1口上开启代理arp。来进行全网互通

[AR7-GigabitEthernet0/0/0]ip address 192.168.1.1 255.255.255.0
[AR7]ip route-static 192.168.2.0 255.255.255.0 GigabitEthernet0/0/0

[AR8-GigabitEthernet0/0/0]ip address 192.168.1.2 255.255.255.0
[AR8-GigabitEthernet0/0/0]arp-proxy enable
[AR8-GigabitEthernet0/0/1]ip address 192.168.2.2 255.255.255.0
[AR8-GigabitEthernet0/0/1]arp-proxy enable

[AR9-GigabitEthernet0/0/0]ip address 192.168.2.3 255.255.255.0 
[AR9]ip route-static 192.168.1.0 24 192.168.2.2

配置完成后进行测试

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

  --- 192.168.2.3 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/28/30 ms
查看arp表
[AR7]dis arp all
IP ADDRESS      MAC ADDRESS     EXPIRE(M) TYPE        INTERFACE   VPN-INSTANCE 
                                          VLAN/CEVLAN PVC                      
------------------------------------------------------------------------------
192.168.1.1     00e0-fc1d-3f10            I -         GE0/0/0
192.168.2.2     00e0-fcaf-8043  14        D-0         GE0/0/0
192.168.1.2     00e0-fcaf-8043  14        D-0         GE0/0/0
192.168.2.3     00e0-fcaf-8043  14        D-0         GE0/0/0
------------------------------------------------------------------------------
Total:4         Dynamic:3       Static:0     Interface:1  
[AR8]dis arp all
IP ADDRESS      MAC ADDRESS     EXPIRE(M) TYPE        INTERFACE   VPN-INSTANCE 
                                          VLAN/CEVLAN PVC                      
------------------------------------------------------------------------------
192.168.1.2     00e0-fcaf-8043            I -         GE0/0/0
192.168.1.1     00e0-fc1d-3f10  13        D-0         GE0/0/0
192.168.2.2     00e0-fcaf-8044            I -         GE0/0/1
192.168.2.3     00e0-fcd5-176c  13        D-0         GE0/0/1
------------------------------------------------------------------------------
Total:4         Dynamic:2       Static:0     Interface:2 
[AR9]dis arp all
IP ADDRESS      MAC ADDRESS     EXPIRE(M) TYPE        INTERFACE   VPN-INSTANCE 
                                          VLAN/CEVLAN PVC                      
------------------------------------------------------------------------------
192.168.2.3     00e0-fcd5-176c            I -         GE0/0/0
192.168.2.2     00e0-fcaf-8044  12        D-0         GE0/0/0
------------------------------------------------------------------------------
Total:2         Dynamic:1       Static:0     Interface:1   
查看路由表
[AR7]dis ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 8        Routes : 8        

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      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
    192.168.1.0/24  Direct  0    0           D   192.168.1.1     GigabitEthernet0/0/0
    192.168.1.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/0
  192.168.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/0
    192.168.2.0/24  Static  60   0           D   192.168.1.1     GigabitEthernet0/0/0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
[AR8]dis ip rou
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 10       Routes : 10       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      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
****192.168.1.0/24  Direct  0    0           D   192.168.1.2     GigabitEthernet0/0/0
    192.168.1.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/0
  192.168.1.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/0
****192.168.2.0/24  Direct  0    0           D   192.168.2.2     GigabitEthernet0/0/1
    192.168.2.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/1
  192.168.2.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/1
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
[AR9]dis ip rou
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 8        Routes : 8        

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

      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
****192.168.1.0/24  Static  60   0          RD   192.168.2.2     GigabitEthernet0/0/0
    192.168.2.0/24  Direct  0    0           D   192.168.2.3     GigabitEthernet0/0/0
    192.168.2.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/0
  192.168.2.255/32  Direct  0    0           D   127.0.0.1       GigabitEthernet0/0/0
255.255.255.255/32  Direct  0    0           D   127.0.0.1       InLoopBack0
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值