diff --git "a/38 \345\272\204\346\200\277/20260509 \347\254\224\350\256\260.txt" "b/38 \345\272\204\346\200\277/20260509 \347\254\224\350\256\260.txt" new file mode 100644 index 0000000000000000000000000000000000000000..1148deffbbceb507fdb0d899d7b452aff31d08b4 --- /dev/null +++ "b/38 \345\272\204\346\200\277/20260509 \347\254\224\350\256\260.txt" @@ -0,0 +1,17 @@ +## 三、技术原理: + +- 路由器属于网络层设备,能够根据IP数据报的首部信息,选择一条最佳路径(这一过程称为"路由选择"),将数据报转发到下一跳路由地址,并最终传送到目的结点(这一过程称为"分组转发"),从而实现不同局域网(或逻辑子网)的主机之间的互相访问。 + +- 路由器是根据路由表进行选路和转发的。而路由表里就是由一条条路由信息组成。不同厂商路由器生成的路由表结构及内容可能有所差异,内容主要包括:路由源码(路由选择方式)、目的网络及其掩码、下一跳路由地址或端口、默认路由等信息。 + +- 生成路由表主要有两种方法:手工配置和动态配置,即静态路由协议配置和动态路由协议配置。 + + - 静态路由:由网络管理员手工配置固定的路由信息。具有简单、高效、可靠以及安全保密性高等优点。 + + - 动态路由:路由器利用动态路由协议(如RIP、OSPF等)自动建立路由表,并能根据实际网络拓扑结构的变化适时更新,无需管理员手工维护,适用于网络规模大、拓扑复杂的网络。 + +- 缺省/默认路由:静态路由的一种特殊情况。当数据包在査找路由表时,没有找到和目标相匹配的路由表项时,若没有配置默认路由,即指定路由器默认的下一跳地址,则路由器会将该数据包丢弃。 + +- 由于采用串行通信方式,一般DCE设备上需设置时钟频率才可实现通信,而另一端DTE设备则无需设置。另外,目前很多路由器已支持电缆DCE类型及时钟频率的自适应,如思科的ISR路由器等。 + +- **注意**:在现代企业网络中,这种接口已被**以太网(如 GE)**和**光接口**取代,很少再见到新的部署。如果你在设备上看到这个接口,可能是在较老的路由器或模拟器(如 GNS3、EVE-NG)中进行学习。 \ No newline at end of file diff --git "a/38 \345\272\204\346\200\277/20260512 \345\212\250\346\200\201\350\267\257\347\224\261\347\232\204\351\205\215\347\275\256 .md" "b/38 \345\272\204\346\200\277/20260512 \345\212\250\346\200\201\350\267\257\347\224\261\347\232\204\351\205\215\347\275\256 .md" new file mode 100644 index 0000000000000000000000000000000000000000..50b861eb6abcfd6306053e672bda80cfa6b2bc04 --- /dev/null +++ "b/38 \345\272\204\346\200\277/20260512 \345\212\250\346\200\201\350\267\257\347\224\261\347\232\204\351\205\215\347\275\256 .md" @@ -0,0 +1,386 @@ +``` +Switch>en +Switch#config t +Enter configuration commands, one per line. End with CNTL/Z. +Switch(config)#vlan 2 +Switch(config-vlan)# vlan + ^ +% Invalid input detected at '^' marker. + +Switch(config-vlan)#vlan 3 +Switch(config-vlan)#exit +Switch(config)#inter f0/1 +Switch(config-if)#switchport access vlan 2 +Switch(config-if)#exit +Switch(config)#inter f0/2 +Switch(config-if)#switchport access vlan 3 +Switch(config-if)#exit +Switch(config)#ip routing +Switch(config)#interface vlan 2 +Switch(config-if)# +%LINK-5-CHANGED: Interface Vlan2, changed state to up + +Switch(config-if)#ip address 192.168.3.1 255.255.255.0 +Switch(config-if)#e +%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (3), with Switch FastEthernet0/1 (1). + +Switch(config)#interface vlan 3 +Switch(config-if)# +%LINK-5-CHANGED: Interface Vlan3, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan3, changed state to up + +Switch(config-if)#ip address 192.168.1.1 255.255.255.0 +Switch(config-if)#exit +Switch(config)#router rip +Switch(config-router)# +%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (3), with Switch FastEthernet0/1 (1). + +Switch(config-router)#version 2 +Switch(config-router)#network 192.168.1.0 +Switch(config-router)#network 192.168.3.0 +Switch(config-router)#^z + ^ +% Invalid input detected at '^' marker. + +Switch(config-router)#^Z + ^ +% Invalid input detected at '^' marker. + +Switch(config-router)#^Z + ^ +% Invalid input detected at '^' marker. + +Switch(config-router)# +%CDP-4-NATIVE_VLAN_MISMATCH: Native VLAN mismatch discovered on FastEthernet0/2 (3), with Switch FastEthernet0/1 (1). + +Switch(config-router)#exit +Switch(config)#exit +Switch# +%SYS-5-CONFIG_I: Configured from console by console + +Switch#show r +Building configuration... + +Current configuration : 1435 bytes +! +version 12.2(37)SE1 +no service timestamps log datetime msec +no service timestamps debug datetime msec +no service password-encryption +! +hostname Switch +! +! +! +! +! +! +ip routing +! +! +! +! +! +! +! +! +! +! + +Switch#show 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 + +C 192.168.1.0/24 is directly connected, Vlan3 + +Switch# +``` + +``` +Router>enable +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#inter f0/0 +Router(config-if)#ip address 192.168.3.2 255.255.255.0 +Router(config-if)#no shutdown + +Router(config-if)# +%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up + +Router(config-if)#exit +Router(config)#interface serial 2/0 +Router(config-if)#ip address 10.254.10.1 255.255.255.0 +Router(config-if)#clock rate 64000 +This command applies only to DCE interfaces +Router(config-if)#no shutdown + +%LINK-5-CHANGED: Interface Serial2/0, changed state to down +Router(config-if)#exit +Router(config)#router rip +Router(config-router)#version 2 +Router(config-router)#network 192.168.3.0 +Router(config-router)#network 10.254.10.0 +Router(config-router)#^z + ^ +% Invalid input detected at '^' marker. + +Router(config-router)#exit +Router(config)#exit +Router# +%SYS-5-CONFIG_I: Configured from console by console + +Router#show r +Building configuration... + +Current configuration : 775 bytes +! +version 12.2 +no service timestamps log datetime msec +no service timestamps debug datetime msec +no service password-encryption +! +hostname Router +! +! +! +! +! +! +! +! +ip cef +no ipv6 cef +! +! + +Router#show 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 + +R 192.168.1.0/24 [120/1] via 192.168.3.1, 00:00:26, FastEthernet0/0 +C 192.168.3.0/24 is directly connected, FastEthernet0/0 + +Router# +``` + +``` +Router>enable +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#inter f0/0 +Router(config-if)#ip address 192.168.2.1 255.255.255.0 +Router(config-if)#no shutdown + +Router(config-if)# +%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up + +Router(config-if)#exit +Router(config)#interface serial 2/0 +Router(config-if)#ip address 10.254.10.2 255.255.255.0 +Router(config-if)#no shutdown + +Router(config-if)# +%LINK-5-CHANGED: Interface Serial2/0, changed state to up + +Router(config-if)#exit +Router(config)#rout +%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up + +% Incomplete command. +Router(config)#router rip +Router(config-router)#version 2 +Router(config-router)#network 192.168.2.0 +Router(config-router)#network 10.254.10.0 +Router(config-router)#^Z + ^ +% Invalid input detected at '^' marker. + +Router(config-router)#exit +Router(config)#exit +Router# +%SYS-5-CONFIG_I: Configured from console by console + +Router#show r +Building configuration... + +Current configuration : 795 bytes +! +version 12.2 +no service timestamps log datetime msec +no service timestamps debug datetime msec +no service password-encryption +! +hostname Router +! +! +! +! +! +! +! +! +ip cef +no ipv6 cef +! +! +! + +Router# +Router#show 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/24 is subnetted, 1 subnets +C 10.254.10.0 is directly connected, Serial2/0 +R 192.168.1.0/24 [120/2] via 10.254.10.1, 00:00:08, Serial2/0 +C 192.168.2.0/24 is directly connected, FastEthernet0/0 +R 192.168.3.0/24 [120/1] via 10.254.10.1, 00:00:08, Serial2/0 + +Router# +``` + +``` + +Packet Tracer PC Command Line 1.0 +C:\>ping 192.168.1.1 + +Pinging 192.168.1.1 with 32 bytes of data: + +Reply from 192.168.1.1: bytes=32 time<1ms TTL=255 +Reply from 192.168.1.1: bytes=32 time<1ms TTL=255 +Reply from 192.168.1.1: bytes=32 time<1ms TTL=255 +Reply from 192.168.1.1: bytes=32 time<1ms TTL=255 + +Ping statistics for 192.168.1.1: + Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), +Approximate round trip times in milli-seconds: + Minimum = 0ms, Maximum = 0ms, Average = 0ms + +C:\>ping 10.254.10.1 + +Pinging 10.254.10.1 with 32 bytes of data: + +Reply from 10.254.10.1: bytes=32 time=1ms TTL=254 +Reply from 10.254.10.1: bytes=32 time<1ms TTL=254 +Reply from 10.254.10.1: bytes=32 time<1ms TTL=254 +Reply from 10.254.10.1: bytes=32 time<1ms TTL=254 + +Ping statistics for 10.254.10.1: + Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), +Approximate round trip times in milli-seconds: + Minimum = 0ms, Maximum = 1ms, Average = 0ms + +C:\>ping 192.168.2.2 + +Pinging 192.168.2.2 with 32 bytes of data: + +Request timed out. +Reply from 192.168.2.2: bytes=32 time=1ms TTL=125 +Reply from 192.168.2.2: bytes=32 time=1ms TTL=125 +Reply from 192.168.2.2: bytes=32 time=2ms TTL=125 + +Ping statistics for 192.168.2.2: + Packets: Sent = 4, Received = 3, Lost = 1 (25% loss), +Approximate round trip times in milli-seconds: + Minimum = 1ms, Maximum = 2ms, Average = 1ms + +C:\> +``` + +``` + +Packet Tracer PC Command Line 1.0 +C:\>ping 10.254.10.1 + +Pinging 10.254.10.1 with 32 bytes of data: + +Reply from 10.254.10.1: bytes=32 time=1ms TTL=254 +Reply from 10.254.10.1: bytes=32 time=1ms TTL=254 +Reply from 10.254.10.1: bytes=32 time=1ms TTL=254 +Reply from 10.254.10.1: bytes=32 time=1ms TTL=254 + +Ping statistics for 10.254.10.1: + Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), +Approximate round trip times in milli-seconds: + Minimum = 1ms, Maximum = 1ms, Average = 1ms + +C:\>ping 192.168.3.1 + +Pinging 192.168.3.1 with 32 bytes of data: + +Reply from 192.168.3.1: bytes=32 time=5ms TTL=253 +Reply from 192.168.3.1: bytes=32 time=1ms TTL=253 +Reply from 192.168.3.1: bytes=32 time=3ms TTL=253 +Reply from 192.168.3.1: bytes=32 time=3ms TTL=253 + +Ping statistics for 192.168.3.1: + Packets: Sent = 4, Received = 4, Lost = 0 (0% loss), +Approximate round trip times in milli-seconds: + Minimum = 1ms, Maximum = 5ms, Average = 3ms + +C:\>ping 192.168.1.3 + +Pinging 192.168.1.3 with 32 bytes of data: + +Request timed out. +Reply from 192.168.1.3: bytes=32 time=4ms TTL=125 +Reply from 192.168.1.3: bytes=32 time=11ms TTL=125 +Reply from 192.168.1.3: bytes=32 time=1ms TTL=125 + +Ping statistics for 192.168.1.3: + Packets: Sent = 4, Received = 3, Lost = 1 (25% loss), +Approximate round trip times in milli-seconds: + Minimum = 1ms, Maximum = 11ms, Average = 5ms + +C:\> +``` + +![image-20260512170147537](C:\Users\Administrator\AppData\Roaming\Typora\typora-user-images\image-20260512170147537.png) + + 笔记 + +- 动态路由选择:路由器使用路由选择协议(算法)根据实测或估计的距离、时延和网络拓扑等度量权值,自动计算最佳路径并建立路由表。相比静态路由选择,它配置手段更加便捷,适合应用于中大型且网络拓扑变化频繁的网络环境;但另一方面则会占用更多的路由器CPU资源和网络带宽。 + +- 路由选择协议可分为3大类,只有理解不同路由选择协议的工作方式,才能根据实际情况具体分析,从而最大程度上满足具体的应用需要: + + - 距离矢量:通过判断距离确定当前到达目的网络的最佳路径。如RIP、IGRP等 + + - 链路状态:通过发送本路由器与哪些路由器相邻,及其链路状态(距离、时延等)信息,如OSPF等 + + - 混合型:同时具有距离矢量和链路状态两种协议的特性,如EIGRP等 + +- 路由信息协议(Routing Information Protocls,即 RIP),是应用较早、使用较普遍的IGP内部路由协议,使用于小型同类网络的一种距离矢量协议,有以下两个版本: + + - RIPv1:属于有类路由协议,不支持VLSM,以广播形式进行路由更新; + + - RIPv2:属于无类路由协议,支持VLSM,以组播形式进行路由更新; + +- 路由配置模式            Router(config-router)# + +### \ No newline at end of file