zoukankan      html  css  js  c++  java
  • 包格式及IP地址,网络层协议

    包格式及IP地址,网络层协议

    1. 案例1:配置静态路由
    2. 案例2:配置浮动路由
    3. 案例3:配置多路由的静态路由
    4. 案例4:配置默认路由

    1 案例1:配置静态路由

    1.1 问题

    配置路由接口IP地址并通过静态路由的配置实现全网的互通。

    1.2 方案

    按如下网络拓扑配置接口IP地址并通过静态路由的配置实现全网的互通如图-1所示:

    -1

    1.3 步骤

    实现此案例需要按照如下步骤进行。

    步骤一:配置静态路由

    1)R1上配置接口IP

    1. R1(config)#interface fastEthernet 0/0
    2. R1(config-if)#ip address 192.168.1.254 255.255.255.0
    3. R1(config-if)#no shutdown
    4. R1(config-if)#exit
    5. R1(config)#interface fastEthernet 0/1
    6. R1(config-if)#ip address 192.168.2.1 255.255.255.0
    7. R1(config-if)#no shutdown

    2)R2上配置接口IP

    1. R2(config)#interface fastEthernet 0/1
    2. R2(config-if)#ip address 192.168.2.2 255.255.255.0
    3. R2(config-if)#no shutdown
    4. R2config-if)#exit
    5. R2(config)#interface fastEthernet 0/0
    6. R2(config-if)#ip address 192.168.4.254 255.255.255.0
    7. R2(config-if)#no shutdown

    3)R1上添加静态路由

    1. R1(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2

    4)R1上查看路由表

    1. R1#show ip route
    2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
    3. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
    4. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
    5. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
    6. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
    7. * - candidate default, U - per-user static route, o - ODR
    8. P - periodic downloaded static route
    9. Gateway of last resort is not set
    10. C    192.168.1.0/24 is directly connected, FastEthernet0/0
    11. C    192.168.2.0/24 is directly connected, FastEthernet0/1
    12. S    192.168.4.0/24 [1/0] via 192.168.2.2                     //S表示静态路由

    5)R2上添加静态路由

    1. R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1

    6)R2上查看路由条目

    1. R2#show ip route
    2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
    3. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
    4. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
    5. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
    6. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
    7. * - candidate default, U - per-user static route, o - ODR
    8. P - periodic downloaded static route
    9. Gateway of last resort is not set
    10. S    192.168.1.0/24 [1/0] via 192.168.2.1                     //S表示静态路由
    11. C    192.168.2.0/24 is directly connected, FastEthernet0/1
    12. C    192.168.3.0/24 is directly connected, FastEthernet0/0

    7)配置PC1的IP地址为192.168.1.1,网关为192.168.1.254

    8)配置PC2的IP地址为192.168.4.1,网关为192.168.4.254

    9)测试网络连通性,PC1 ping 192.168.4.1

    1. PC>ping 192.168.4.1
    2. Pinging 192.168.4.1 with 32 bytes of data:
    3. Reply from 192.168.4.1: bytes=32 time=1ms TTL=126
    4. Reply from 192.168.4.1: bytes=32 time=11ms TTL=126
    5. Reply from 192.168.4.1: bytes=32 time=10ms TTL=126
    6. Reply from 192.168.4.1: bytes=32 time=11ms TTL=126
    7. Ping statistics for 192.168.4.1:
    8. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    9. Approximate round trip times in milli-seconds:
    10. Minimum = 1ms, Maximum = 11ms, Average = 8ms

    2 案例2:配置浮动路由

    2.1 问题

    配置浮动静态路由

    2.2 方案

    按如下网络拓扑配置接口IP地址配置浮动路由实现链路的冗余,如图-2所示

     

    -2

    2.3 步骤

    实现此案例需要按照如下步骤进行。

    步骤一:配置静态路由并添加模块

    1)R1上配置接口IP

    在以上静态路由实验的基础上,先分别进入R1与R2的特权模式输入write命令保存配置信息,然后分别进入R1与R2的物理配置界面,点击开关按钮关闭路由器,添加NM-1FE-TX模块并再次点击开关按钮,如下图-3所示。

     

    图-3

    2)添加模块后将R1的F1/0接口连接到R2的F1/0接口修改拓扑如下图-4所示:

     

    图-4

    3)配置R1的F1/0接口IP

    1. R1(config)#interface fastEthernet 1/0
    2. R1(config-if)#ip address 192.168.3.1 255.255.255.0
    3. R1(config-if)#no shutdown

    4)配置R2的F1/0接口IP

    1. R2(config)#interface fastEthernet 1/0
    2. R2(config-if)#ip address 192.168.3.2 255.255.255.0
    3. R2(config-if)#no shutdown

    5)R1上添加静态浮动路由

    1. R1(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.2 50   //管理距离50

    6)R2上添加静态浮动路由

    1. R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.3.1 50  //管理距离50

    7)R1上查看路由表

    1. R1#show ip route
    2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
    3. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
    4. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
    5. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
    6. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
    7. * - candidate default, U - per-user static route, o - ODR
    8. P - periodic downloaded static route
    9. Gateway of last resort is not set
    10. C    192.168.1.0/24 is directly connected, FastEthernet0/0
    11. C    192.168.2.0/24 is directly connected, FastEthernet0/1
    12. C    192.168.3.0/24 is directly connected, FastEthernet1/0
    13. S    192.168.4.0/24 [1/0] via 192.168.2.2  //只有下一跳为192.168.2.2的静态路由

    8)禁用F/01接口

    1. R1(config)#interface fastEthernet 0/1
    2. R1(config-if)#shutdown

    9)R1上查看路由表

    1. C    192.168.1.0/24 is directly connected, FastEthernet0/0
    2. S    192.168.4.0/24 [50/0] via 192.168.3.2//下一跳接口为192.168.4.2的路由生效
    3. C    192.168.4.0/24 is directly connected, FastEthernet1/0

    10)测试网络连通性,PC1 ping 192.168.4.1

    1. PC>ping 192.168.4.1
    2. Pinging 192.168.4.1 with 32 bytes of data:
    3. Reply from 192.168.4.1: bytes=32 time=0ms TTL=126
    4. Reply from 192.168.4.1: bytes=32 time=10ms TTL=126
    5. Reply from 192.168.4.1: bytes=32 time=11ms TTL=126
    6. Reply from 192.168.4.1: bytes=32 time=1ms TTL=126
    7. Ping statistics for 192.168.4.1:
    8. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    9. Approximate round trip times in milli-seconds:
    10. Minimum = 0ms, Maximum = 11ms, Average = 5ms

    3 案例3:配置多路由的静态路由

    3.1 问题

    配置多路由的静态路由

    3.2 方案

    网络环境及IP地址规划,如图-5所示

    -5

    3.3 步骤

    实现此案例需要按照如下步骤进行。

    步骤一:配置路由IP和静态路由

    1) R1上配置接口IP

    1. Router(config)#interface fastEthernet 0/0
    2. R1(config-if)#ip address 192.168.1.254 255.255.255.0
    3. R1(config-if)#no shutdown
    4. R1(config-if)#exit
    5. R1(config)#interface fastEthernet 0/1
    6. R1(config-if)#ip address 192.168.2.1 255.255.255.0
    7. R1(config-if)#no shutdown

    2)R2上配置接口IP

    1. R2(config)#interface f0/1
    2. R2(config-if)#ip address 192.168.2.2 255.255.255.0
    3. R2(config-if)#no shutdown
    4. R2(config-if)#exit
    5. R2(config)#interface fastEthernet 0/0
    6. R2(config-if)#ip address 192.168.3.1 255.255.255.0
    7. R2(config-if)#no shutdown

    3)R3上配置接口IP

    1. R3(config)#interface fastEthernet 0/1
    2. R3(config-if)#ip address 192.168.3.2 255.255.255.0
    3. R3(config-if)#no shutdown
    4. R3(config-if)#exit
    5. R3(config)#interface fastEthernet 0/0
    6. R3(config-if)#ip address 192.168.4.254 255.255.255.0
    7. R3(config-if)#no shutdown

    4)R1、R2、R3上分别添加静态路由

    1. R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
    2. R1(config)#ip route 192.168.4.0 255.255.255.0 192.168.2.2
    3. R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
    4. R2(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.2
    5. R3(config)#ip route 192.168.1.0 255.255.255.0 192.168.3.1
    6. R3(config)#ip route 192.168.2.0 255.255.255.0 192.168.3.1

    5)R1上查看路由表

    1. R1#show ip route
    2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
    3. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
    4. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
    5. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
    6. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
    7. * - candidate default, U - per-user static route, o - ODR
    8. P - periodic downloaded static route
    9. Gateway of last resort is not set
    10. C    192.168.1.0/24 is directly connected, FastEthernet0/0
    11. C    192.168.2.0/24 is directly connected, FastEthernet0/1
    12. S    192.168.3.0/24 [1/0] via 192.168.2.2    //静态路由
    13. S    192.168.4.0/24 [1/0] via 192.168.2.2    //静态路由

    6)R2上查看路由表

    1. R2#show ip route
    2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
    3. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
    4. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
    5. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
    6. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
    7. * - candidate default, U - per-user static route, o - ODR
    8. P - periodic downloaded static route
    9. Gateway of last resort is not set
    10. S    192.168.1.0/24 [1/0] via 192.168.2.1    //静态路由
    11. C    192.168.2.0/24 is directly connected, FastEthernet0/1
    12. C    192.168.3.0/24 is directly connected, FastEthernet0/0
    13. S    192.168.4.0/24 [1/0] via 192.168.3.2    //静态路由

    7)R3上查看路由表

    1. R3#show ip route
    2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
    3. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
    4. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
    5. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
    6. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
    7. * - candidate default, U - per-user static route, o - ODR
    8. P - periodic downloaded static route
    9. Gateway of last resort is not set
    10. S    192.168.1.0/24 [1/0] via 192.168.3.1    //静态路由
    11. S    192.168.2.0/24 [1/0] via 192.168.3.1    //静态路由
    12. C    192.168.3.0/24 is directly connected, FastEthernet0/1
    13. C    192.168.4.0/24 is directly connected, FastEthernet0/0

    8)按图-4配置PC的IP地址

    9)测试网络连通性,PC1 ping 192.168.2.2、192.168.3.1、192.168.3.2、192.168.4.1

    1. PC>ping 192.168.2.2                            //ping 192.168.2.2
    2. Pinging 192.168.2.2 with 32 bytes of data:
    3. Reply from 192.168.2.2: bytes=32 time=0ms TTL=254
    4. Reply from 192.168.2.2: bytes=32 time=0ms TTL=254
    5. Reply from 192.168.2.2: bytes=32 time=0ms TTL=254
    6. Reply from 192.168.2.2: bytes=32 time=0ms TTL=254
    7. Ping statistics for 192.168.2.2:
    8. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    9. Approximate round trip times in milli-seconds:
    10. Minimum = 0ms, Maximum = 0ms, Average = 0ms
    11. PC>ping 192.168.3.1                          //ping 192.168.3.1
    12. Pinging 192.168.3.1 with 32 bytes of data:
    13. Reply from 192.168.3.1: bytes=32 time=0ms TTL=254
    14. Reply from 192.168.3.1: bytes=32 time=3ms TTL=254
    15. Reply from 192.168.3.1: bytes=32 time=0ms TTL=254
    16. Reply from 192.168.3.1: bytes=32 time=0ms TTL=254
    17. Ping statistics for 192.168.3.1:
    18. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    19. Approximate round trip times in milli-seconds:
    20. Minimum = 0ms, Maximum = 3ms, Average = 0ms
    21. PC>ping 192.168.3.2                          //ping 192.168.3.2
    22. Pinging 192.168.3.2 with 32 bytes of data:
    23. Reply from 192.168.3.2: bytes=32 time=0ms TTL=253
    24. Reply from 192.168.3.2: bytes=32 time=12ms TTL=253
    25. Reply from 192.168.3.2: bytes=32 time=0ms TTL=253
    26. Reply from 192.168.3.2: bytes=32 time=12ms TTL=253
    27. Ping statistics for 192.168.3.2:
    28. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    29. Approximate round trip times in milli-seconds:
    30. Minimum = 0ms, Maximum = 12ms, Average = 6ms
    31. PC>ping 192.168.4.1                          //ping 192.168.4.1
    32. Pinging 192.168.4.1 with 32 bytes of data:
    33. Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
    34. Reply from 192.168.4.1: bytes=32 time=10ms TTL=125
    35. Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
    36. Reply from 192.168.4.1: bytes=32 time=22ms TTL=125
    37. Ping statistics for 192.168.4.1:
    38. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    39. Approximate round trip times in milli-seconds:
    40. Minimum = 0ms, Maximum = 22ms, Average = 8ms

    4 案例4:配置默认路由

    4.1 问题

    配置默认路由

    4.2 方案

    网络环境及IP地址规划,如图-6所示

     

    -6

    4.3 步骤

    1)在案例3基础上删除R1与R3的静态路由

    1. R1(config)#no ip route 192.168.3.0 255.255.255.0 192.168.2.2
    2. R1(config)#no ip route 192.168.4.0 255.255.255.0 192.168.2.2
    3. R3(config)#no ip route 192.168.1.0 255.255.255.0 192.168.3.1
    4. R3(config)#no ip route 192.168.2.0 255.255.255.0 192.168.3.1

    2)R1、R3添加默认路由

    1. R1(config)#ip route 0.0.0.0 0.0.0.0 192.168.2.2
    2. R3(config)#ip route 0.0.0.0 0.0.0.0 192.168.3.1
    3. 12R1上查看路由表
    4. R1#show ip route
    5. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
    6. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
    7. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
    8. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
    9. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
    10. * - candidate default, U - per-user static route, o - ODR
    11. P - periodic downloaded static route
    12. Gateway of last resort is 192.168.2.2 to network 0.0.0.0
    13. C    192.168.1.0/24 is directly connected, FastEthernet0/0
    14. C    192.168.2.0/24 is directly connected, FastEthernet0/1
    15. S*   0.0.0.0/0 [1/0] via 192.168.2.2     //默认路由

    3)R1、R3上查看路由表

    1. R1#show ip route
    2. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
    3. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
    4. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
    5. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
    6. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
    7. * - candidate default, U - per-user static route, o - ODR
    8. P - periodic downloaded static route
    9. Gateway of last resort is 192.168.3.1 to network 0.0.0.0
    10. C    192.168.1.0/24 is directly connected, FastEthernet0/0
    11. C    192.168.2.0/24 is directly connected, FastEthernet0/1
    12. S*   0.0.0.0/0 [1/0] via 192.168.2.2     //默认路由
    13. R3#show ip route
    14. Codes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP
    15. D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
    16. N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
    17. E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
    18. i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
    19. * - candidate default, U - per-user static route, o - ODR
    20. P - periodic downloaded static route
    21. Gateway of last resort is 192.168.3.1 to network 0.0.0.0
    22. C    192.168.3.0/24 is directly connected, FastEthernet0/1
    23. C    192.168.4.0/24 is directly connected, FastEthernet0/0
    24. S*   0.0.0.0/0 [1/0] via 192.168.3.1     //默认路由

    4)测试网络连通性,PC1 ping 192.168.4.1

    1. PC>ping 192.168.4.1
    2. Pinging 192.168.4.1 with 32 bytes of data:
    3. Reply from 192.168.4.1: bytes=32 time=1ms TTL=125
    4. Reply from 192.168.4.1: bytes=32 time=0ms TTL=125
    5. Reply from 192.168.4.1: bytes=32 time=14ms TTL=125
    6. Reply from 192.168.4.1: bytes=32 time=14ms TTL=125
    7. Ping statistics for 192.168.4.1:
    8. Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
    9. Approximate round trip times in milli-seconds:
    10. Minimum = 0ms, Maximum = 14ms, Average = 7ms = 0ms,平均 = 0ms
  • 相关阅读:
    Java实现 LeetCode 461 汉明距离
    在Linux运行期间升级Linux系统(Uboot+kernel+Rootfs)
    AM335x(TQ335x)学习笔记——挂载Ramdisk
    Ramdisk文件系统的制作与调试运行
    u-boot向linux内核传递启动参数(详细)
    uboot环境变量与内核MTD分区关系
    MMU
    INTERRUPT CONTROLLER
    UART
    GPIO
  • 原文地址:https://www.cnblogs.com/qingbai/p/11970400.html
Copyright © 2011-2022 走看看