diff --git "a/22 \346\235\216\346\200\235/20250422 \350\267\257\347\224\261\345\231\250\351\207\215\345\210\206\345\217\221.md" "b/22 \346\235\216\346\200\235/20250422 \350\267\257\347\224\261\345\231\250\351\207\215\345\210\206\345\217\221.md" new file mode 100644 index 0000000000000000000000000000000000000000..76904dbb82c0d24935886aa56501da8121c45859 --- /dev/null +++ "b/22 \346\235\216\346\200\235/20250422 \350\267\257\347\224\261\345\231\250\351\207\215\345\210\206\345\217\221.md" @@ -0,0 +1,293 @@ +中间负责重分发的路由器核心代码: + +```bash +# 进入OSPF 将RIP和静态重分发为OSPF +router ospf 1 + log-adjacency-changes + redistribute rip subnets + redistribute static subnets + network 9.9.9.0 0.0.0.255 area 0 +! +# 进入RIP 将OSPF和静态重分发为RIP +router rip + version 2 + redistribute ospf 1 metric 5 + redistribute static + network 11.0.0.0 +! +# 静态路由,直接设置,不用重发分,但与当前路由连接的静态路由器,要将当前路由器调为默认出口 +ip classless +ip route 0.0.0.0 0.0.0.0 12.12.12.1 +ip route 192.168.200.0 255.255.255.0 12.12.12.1 +ip route 192.168.220.0 255.255.255.0 12.12.12.1 +! +``` + + + +``` +ospf路由器0 +Router> +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#inter g0/0 +Router(config-if)#ip address 192.168.10.254 255.255.255.0 +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up + +Router(config-if)#ex +Router(config)#inter g0/1 +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up + +Router(config-if)#ip address 10.10.10.1 255.255.255.0 +Router(config-if)# +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up + +Router(config-if)#ex +Router(config)#router ospf 1 +Router(config-router)#network 10.10.10.0 0.0.0.255 area 0 +Router(config-router)#network 192.168.100 0.0.0.255 area 0 +00:25:54: %OSPF-5-ADJCHG: Process 1, Nbr 10.10.20.1 on GigabitEthernet0/1network 10.10.10.0 0.0.0.255 area 0 +Router(config-router)#network 192.168.10.0 0.0.0.255 area 0 +``` + +``` +路由器2 +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#inter g0/1 +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up + +Router(config-if)#i address 10.10.20.2 255.255.255.0 +% Ambiguous command: "i address 10.10.20.2 255.255.255.0" +Router(config-if)#ip address 10.10.20.2 255.255.255.0 +Router(config-if)#ex +Router(config)#inter g0/0 +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up + +Router(config-if)#ip address 192.168.20.254 255.255.255.0 +Router(config-if)#ex +Router(config)#inter g0/2 +Router(config-if)#ip address 9.9.9.1 255.255.255.0 +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up + +Router(config-if)#ex +Router(config)#^Z +Router# +%SYS-5-CONFIG_I: Configured from console by console + +Router#show ip route +Codes: L - local, C - connected, S - static, 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, 2 subnets, 2 masks +C 10.10.20.0/24 is directly connected, GigabitEthernet0/1 +L 10.10.20.2/32 is directly connected, GigabitEthernet0/1 + 192.168.20.0/24 is variably subnetted, 2 subnets, 2 masks +C 192.168.20.0/24 is directly connected, GigabitEthernet0/0 +L 192.168.20.254/32 is directly connected, GigabitEthernet0/0 + +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#router ospf 1 +Router(config-router)#network 192.168.20.0 0.0.0.255 area 0 +Router(config-router)#network 10.10.20.0 0.0.0.255 area 0 +Router(config-router)#network 9.9.9.0 0.0.0.255 area 0 +``` + +``` +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#inter g0/0 +Router(config-if)#ip address 192.168.100.254 255.255.255.0 +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up + +Router(config-if)#ex +Router(config)#inter g0/1 +Router(config-if)#ip address 10.20.10.1 255.255.255.0 +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up + +Router(config-if)# +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up + +Router(config-if)#ex +Router(config)#route rip +Router(config-router)#ver 2 +Router(config-router)#network 10.20.10.0 +Router(config-router)#network 192.168.100.0 +Router(config-router)#ex +Router(config)#inter g0/2 +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up + +Router(config-if)#ip address 11.11.11.2 255.255.255.0 +Router(config-if)#ex +Router(config)#route rip +Router(config-router)#ver 2 + +Router(config-router)#network 11.11.11.0 +``` + +``` +RIP路由器 +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#inter g0/0 +Router(config-if)#ip address 10.30.10.2 255.255.255.0 +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up + +Router(config-if)#ex +Router(config)#inter g0/1 +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up + +Router(config-if)#ip address 10.30.20.1 255.255.255.0 +Router(config-if)#ex +Router(config)#inter g0/2 +Router(config-if)#nos hut + ^ +% Invalid input detected at '^' marker. + +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/2, changed state to up + +Router(config-if)#ip address 12.12.12.1 255.255.255.0 + +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#ip route 192.168.200.0 255.255.255.0 10.30.10.1 +Router(config)#ip route 192.168.220.0 255.255.255.0 10.30.20.2 +``` + +``` +路由器3 +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#inter g0/0 +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up + +Router(config-if)#ip address 9.9.9.2 255.255.255.0 +Router(config-if)#ex +Router(config)#inter g0/1 +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up + +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up + +Router(config-if)#ip address 11.11.11.1 255.255.255.0 +Router(config-if)#ex +Router(config)#inter g0/2 +Router(config-if)#no shut + +Router(config-if)# +%LINK-5-CHANGED: Interface GigabitEthernet0/2, changed state to up + +Router(config-if)#ip address 12.12.12.2 255.255.255.0 +Router(config-if)# +%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/2, changed state to up + +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#route rip +Router(config-router)#ver 2 + +Router>en +Router#conf t +Enter configuration commands, one per line. End with CNTL/Z. +Router(config)#router rip +Router(config-router)#ver 2 +Router(config-router)#net 9.9.9.0 +Router(config-router)#ex +Router(config)#router ospf 1 +Router(config-router)#net 11.11.11.0 0.0.0.255 area 0 +Router(config-router)#ex +Router(config)#router ospf 1 +Router(config-router)#log-ad +Router(config-router)#log-adjacency-changes +Router(config-router)#redis +Router(config-router)#redistribute rip sub +Router(config-router)#redistribute rip subnets +Router(config-router)#red +Router(config-router)#redistribute sta +Router(config-router)#redistribute static sub +Router(config-router)#redistribute static subnets +Router(config-router)#net 9.9.9.0 0.0.0.255 area 0 +Router(config-router)#ex +Router(config)#router r +01:33:52: %OSPF-5-ADJCHG: Process 1, Nbr 192.168.20.254 on GigabitEthernet0/0 from LOADING to FULL, Loadi +Router(config)# +Router(config)#router rip +Router(config-router)#ver 2 +Router(config-router)#red +Router(config-router)#redistribute ospf 1 metric 5 +Router(config-router)#re +Router(config-router)#redistribute sta +Router(config-router)#redistribute static +Router(config-router)#network 11.0.0.0 +``` + +![Snipaste_2025-04-22_11-38-33](https://gitee.com/nevers-brother/picture-warehouse/raw/master/img/upgit_20250423_1745401332.png) \ No newline at end of file