• 静态路由———初学


    实验需求:

    PC1 在 LAN1 中,PC2 在 LAN2 中,使用静态路由实现 pc1 和 pc2 之间的互相通信
    本实验使用Cisco Packet Tracer 模拟器搭建
    所有的路由器型号为“1841”
    在这里插入图片描述

    关键命令:

    静态路由

    ip route 	network 	mask 		ip-address/interface X[distance][permanent]
    		   (目的网络)  (目的网络掩码)	(下一跳地址) (本地出接口)
    
    例:ip router 10.0.0.0 255.0.0.0 20.1.1.1
    
    • 1
    • 2
    • 3
    • 4

    默认路由

    ip router 0.0.0.0 0.0.0.0 ip-address(下一跳地址)/interface X (本地出接口)
    
    例: ip route 0.0.0.0 0.0.0.0 interface f0/0
    
    • 1
    • 2
    • 3

    实验配置

    在这里插入图片描述
    直接no就行,

    R1:
    enable			\\进入配置视图
    config terminal			\\进入管理员视图
    hostname R1				\\修改设备名称
    interface f0/0			\\进入接口视图
    ip address 10.10.10.254 255.255.255.0		\\配置IP地址
    no shutdown				\\开启接口
    interface f0/1
    ip address 10.12.12.1 255.255.255.252
    no shutdown
    
    R2:
    enable
    config terminal
    hostname R2
    interface f0/1
    ip address 10.12.12.2 255.255.255.252
    no shutdown
    interface f0/0
    ip address 10.23.23.1 255.255.255.252
    no shutdown
    
    R3:
    enable
    config terminal
    hostname R3
    interface f0/0
    ip address 10.23.23.2 255.255.255.252
    no shutdown
    interface f0/1
    ip address 10.10.20.254 255.255.255.0
    no sh
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32

    在这里插入图片描述
    这是路由器的接口都开启时的状态

    接下来是配置pc的IP地址

    在这里插入图片描述
    在这里插入图片描述
    现在以及配置完pc的IP地址
    如果此时去用 pc1 去 ping ,pc2 能不能通?
    在这里插入图片描述
    在这里插入图片描述
    上图可以看出 R1 ping 不通 R2
    这是为什么呢?

    静态路由的配置

    进入管理员视图配置:
    R1R1(config)#ip route 10.10.20.0 255.255.255.0 10.12.12.0
    R1(config)#ip route 10.23.23.0 255.255.255.0 10.12.12.2 
    R2R2(config)#ip route 10.10.20.0 255.255.255.0 10.23.23.2
    R2(config)#ip route 10.10.10.0 255.255.255.0 10.12.12.1
    R3R3(config)#ip route 10.12.12.0 255.255.255.0 10.23.23.1 
    R3(config)#ip route 10.10.10.0 255.255.255.0 10.23.23.1
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    此时可以发现3个路由器都有两条静态路由了

    配置视图:
    #R1R1#sh ip route
    Codes: C - connected, S - static, I - IGRP, 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, E - EGP
           i - IS-IS, 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/8 is variably subnetted, 4 subnets, 2 masks
    C       10.10.10.0/24 is directly connected, FastEthernet0/0
    S       10.10.20.0/24 [1/0] via 10.12.12.2						\\此类“S”开头的为静态路由
    C       10.12.12.0/30 is directly connected, FastEthernet0/1
    S       10.23.23.0/24 [1/0] via 10.12.12.2
    
    #R2R2#sh ip route
    Codes: C - connected, S - static, I - IGRP, 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, E - EGP
           i - IS-IS, 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/8 is variably subnetted, 4 subnets, 2 masks
    S       10.10.10.0/24 [1/0] via 10.12.12.1
    S       10.10.20.0/24 [1/0] via 10.23.23.2
    C       10.12.12.0/30 is directly connected, FastEthernet0/1
    C       10.23.23.0/30 is directly connected, FastEthernet0/0
    
    #R3R3#sh ip route
    Codes: C - connected, S - static, I - IGRP, 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, E - EGP
           i - IS-IS, 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/8 is variably subnetted, 4 subnets, 2 masks
    S       10.10.10.0/24 [1/0] via 10.23.23.1
    C       10.10.20.0/24 is directly connected, FastEthernet0/1
    S       10.12.12.0/24 [1/0] via 10.23.23.1
    C       10.23.23.0/30 is directly connected, FastEthernet0/0
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54

    当路由器有路由信息后我们再去ping,能不能通?

    在这里插入图片描述
    现在可以看到pc1可以ping通pc2了,到此时我们的配置已经完成。

    保存

    现在需要保存拓扑图,在保存拓扑图之前我们先要把路由器的配置

    在配置模式下输入write
    R1#write 
    Building configuration...
    [OK]
    依次在路由器R1R2R3上输入write保存配置命令
    
    • 1
    • 2
    • 3
    • 4
    • 5

    然后再模拟器的左上角找到File
    在这里插入图片描述
    或者点击左上角的在这里插入图片描述
    都可以保存
    在这里插入图片描述
    保存了配置可以方便以后的查看 也可以已文件的形式发送给好友

  • 相关阅读:
    TOGAF标准第10版读书会第14场—加速数字化政府建设,离不开这个参考指导模型
    7月 致 -.-- -..- -
    web前端网页设计期末课程大作业:中华传统文化题材网页源码——基于HTML实现中国水墨风书画艺术网站(12个页面)
    文件上传下载
    面试必备!TCP协议经典十五连问!
    关于标准库中的string类 - c++
    传智健康产品需求说明书
    Docker Desktop安装以及MYSQL, GRAFANA安装
    Bytebase 2.20.0 - 支持为工单事件配置飞书个人通知
    Go——二、变量和数据类型
  • 原文地址:https://blog.csdn.net/m0_61703913/article/details/127784038