• 静态路由


    1. 路由基础

    1.1 路由概述

    路由的作用:

    • 指引数据的转发
    • 三层查询:目的IP地址

    路由查询:

    • 不用关心网络地址和广播地址能不能用
    • 每经过一台三层设备都会进行查询路由表
    • 数据传输:
      • 变化:MAC地址(源和目的),每经过一个三层转发都会改变
      • 不变:IP地址(源和目的)
    • 命令:
      • 思科:show ip route
      • 华为:display ip routing

    路由的组成:

    • 网段:网络地址 + 掩码
    • 出口:接口、下一跳的IP地址
    • 更新源:
      • 直连:设备上配置的路由接口

    1.2 路由的分类

    1)动态路由

    • IGP(内部网关协议):企业内部使用
      • rip
      • ospf
      • isis
      • eigrp
    • EGP(外部网关协议)
      • BGP:边界网关协议
      • EGP:被淘汰

    2)静态路由

    •  静态路由是由网络管理员手动指定的,网络变化时,它不会跟着变化。

    1.3 路由选路原则

    1)最长掩码匹配

    • 前提:有多条路由,且多条路径都能匹配
    • 掩码越长越优

    2)管理距离(AD值)

    • 管理距离:路由优先级、AD值
    • 前提:掩码长度一样
    • AD值越小越优先
      • 192.168.1.0/24  10
      • 192.168.1.0/24  20
    • AD值:(AD值一样则表示是同一个路由协议)
      • 思科:
        • 直连:0
        • 静态:1
        • EIGRP:90
        • OSPF:110
        • RIP:120
      • 华为:
        • 直连:0
        • OSPF:10
        • ISIS:15
        • 静态路由:60
        • RIP:100

    3)度量值(开销,metric,cost)

    • 度量值:开销、metric、cost
    • 越小越优先
      • 192.168.1.0/24  AD=10  COST=10
      • 192.168.1.0/24  AD=10  COST=5

    4)等价路由

    • 等价路由表示的是,以上几个条件都一样的路由
    • 数据负载的方式:
      • 包负载:交换机捆绑路线
      • 流负载:等价路由就是采用流负载

    2. 静态路由

    2.1 静态路由的配置

    • 思科:
      • ip route 172.16.23.0  255.255.255.0  172.16.12.2
      • ip route 172.16.23.0  255.255.255.0  172.16.12.2  9 (最后一个数字是设置优先级,AD值)
    • 华为:
      • ip  route-static  172.16.23.0  24  g0/0/0  172.16.12.2
      • ip  route-static  172.16.23.0  24  172.16.12.2
      • ip  route-static  172.16.23.0  24  172.16.12.2  preference  9(preference是表示设置优先级)

    2.2 黑洞路由

    • 黑洞路由null0:表示下一跳为null0直接丢包
    • 命令:ip  route-static  192.168.0.0  24  null0

    2.3 浮动路由

    • 浮动路由:
      • 在网段一样的情况下,根据优先级、度量值来加载最优的路由
      • 做备用线路,下一跳的接口down掉才会切换
    • 配置:
      • ip  route-static  192.168.100.0  24  172.16.13.3
      • ip  route-static  192.168.100.0  24  172.16.12.2  preference  61

    2.4 常用命令

    思科:

    • 查看配置:show  running-config
    • 查看特定配置:show  run | include  ip route
    • 查看接口情况:show  ip interface brief

    华为:

    • 查看配置:display  cur
    • 查看特定配置:display  cur | include ip route
    • 查看接口情况:display  ip  interface  brief

    3. 静态路由实验

    3.1 实验环境

    实验目的及要求:

    1. 配置静态路由使得R1能ping通R3
    2. 根据优先级来加载最优的路由(做浮动路由
    3. 在R3的回环接口上分别绑定3个IP地址,使得R1能ping通这些IP地址,并做好路由汇总

    3.2 配置IP地址

    R1:
        configure terminal
        interface fastEthernet 0/0
        ip address 192.168.12.1 255.255.255.0
        no shutdown
        interface fastEthernet 0/1
        ip address 192.168.14.1 255.255.255.0
        no shutdown
        do show ip interface brief
    R2:
        configure terminal
        interface fastEthernet 0/0
        ip address 192.168.12.2 255.255.255.0
        no shutdown
        interface fastEthernet 0/1
        ip address 192.168.23.2 255.255.255.0
        no shutdown
        do show ip interface brief
    R3:
        configure terminal
        interface fastEthernet 0/1
        ip address 192.168.23.3 255.255.255.0
        no shutdown
        interface fastEthernet 0/0
        ip address 192.168.34.3 255.255.255.0
        no shutdown
        ### 在环回口上配置IP地址 ###
        interface Loopback 0
        ip address 10.1.1.1 255.255.255.0 
        no shutdown
        interface Loopback 1
        ip address 10.1.2.1 255.255.255.0 
        no shutdown
        interface Loopback 2
        ip address 10.1.3.1 255.255.255.0 
        no shutdown
        do show ip interface brief        
    R4:
        configure terminal
        interface fastEthernet 0/0
        ip address 192.168.34.4 255.255.255.0
        no shutdown
        interface fastEthernet 0/1
        ip address 192.168.14.4 255.255.255.0
        no shutdown
        do show ip interface brief

    3.3 配置路由

    R1:
        configure terminal
        ip route 192.168.23.0 255.255.255.0 192.168.12.2 
        ip route 192.168.34.0 255.255.255.0 192.168.14.4
    R3:
        configure terminal
        ip route 192.168.12.0 255.255.255.0 192.168.23.2
        ip route 192.168.14.0 255.255.255.0 192.168.34.4

    3.4 对环回地址配置路由

    1)没有进行路由汇总

    R1:
        configure terminal
        ip route 10.1.1.0 255.255.255.0 192.168.12.2
        ip route 10.1.2.0 255.255.255.0 192.168.12.2
        ip route 10.1.3.0 255.255.255.0 192.168.12.2
        ip route 10.1.1.0 255.255.255.0 192.168.14.4 10
        ip route 10.1.2.0 255.255.255.0 192.168.14.4 10
        ip route 10.1.3.0 255.255.255.0 192.168.14.4 10    
    R2:
        configure terminal
        ip route 10.1.1.0 255.255.255.0 192.168.23.3 
        ip route 10.1.2.0 255.255.255.0 192.168.23.3 
        ip route 10.1.3.0 255.255.255.0 192.168.23.3 
    R4:
        configure terminal
        ip route 10.1.1.0 255.255.255.0 192.168.34.3 
        ip route 10.1.2.0 255.255.255.0 192.168.34.3 
        ip route 10.1.3.0 255.255.255.0 192.168.34.3 

    2)对环回地址的路由进行汇总

    • 对10.1.1.0和10.1.2.0和10.1.3.0进行路由汇总,掩码为22位,对应掩码为255.255.252.0
    R1:
        configure terminal
        ip route 10.1.0.0 255.255.252.0 192.168.12.2 
        ip route 10.1.0.0 255.255.252.0 192.168.14.4 10
        ip route 10.1.0.0 255.255.255.0 null 0
    R2:
        configure terminal
        ip route 10.1.0.0 255.255.252.0 192.168.23.3 
    R4:
        configure terminal
        ip route 10.1.0.0 255.255.252.0 192.168.34.3

  • 相关阅读:
    替换gitlab自带的Nginx,并修改仓库存储路径
    linux 内网scp 无密码传输
    centos7 安装docker及Hyperf
    VMware 安装centos 7 及自动挂载共享文件夹
    基于 Thrift + Laravel RPC 调用实现
    PHP计算两个经纬度地点之间的距离
    sql server 2008安装过程中服务器配置出错
    SQL Server2008如何设置开启远程连接
    向上下左右不间断无缝滚动图片的效果(兼容火狐和IE)
    彻底解决Google浏览器CSS居中问题
  • 原文地址:https://www.cnblogs.com/hgzero/p/13786951.html
Copyright © 2020-2023  润新知