🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
# 拓扑图 ![](https://box.kancloud.cn/803345e4b36994e02562c1a09963d1f8_889x417.png) # 基础配置 ## R1: ~~~ Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname R1 R1(config)#interface gigabitEthernet 0/0 R1(config-if)#ip address 192.168.1.254 255.255.255.0 R1(config-if)#no shutdown R1(config)#interface gigabitEthernet 0/2 R1(config-if)#ip address 12.1.1.1 255.255.255.0 R1(config-if)#no shutdown R1(config)#ip route 172.16.1.0 255.255.255.0 12.1.1.2 R1(config)#ip route 23.1.1.0 255.255.255.0 12.1.1.2 ~~~ ## R2: ~~~ Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname R2 R2(config)#interface gigabitEthernet 0/1 R2(config-if)#ip address 12.1.1.2 255.255.255.0 R2(config-if)#no shutdown R2(config)#interface gigabitEthernet 0/2 R2(config-if)#ip address 23.1.1.2 255.255.255.0 R2(config-if)#no shutdown R2(config)#ip route 192.168.1.0 255.255.255.0 12.1.1.1 R2(config)#ip route 172.16.1.0 255.255.255.0 23.1.1.3 ~~~ ## R3: ~~~ Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname R3 R3(config)#interface gigabitEthernet 0/2 R3(config-if)#ip address 23.1.1.3 255.255.255.0 R3(config-if)#no shutdown R3(config)#interface gigabitEthernet 0/0 R3(config-if)#ip address 172.16.1.254 255.255.255.0 R3(config-if)#no shutdown R3(config)#ip route 192.168.1.0 255.255.255.0 23.1.1.2 R3(config)#ip route 12.1.1.0 255.255.255.0 23.1.1.2 ~~~ # 查看路由表 ## R1: ~~~ R1#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 12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 12.1.1.0/24 is directly connected, GigabitEthernet0/1 L 12.1.1.1/32 is directly connected, GigabitEthernet0/1 23.0.0.0/24 is subnetted, 1 subnets S 23.1.1.0/24 [1/0] via 12.1.1.2 172.16.0.0/24 is subnetted, 1 subnets S 172.16.1.0/24 [1/0] via 12.1.1.2 192.168.1.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.1.0/24 is directly connected, GigabitEthernet0/0 L 192.168.1.254/32 is directly connected, GigabitEthernet0/0 ~~~ ## R2: ~~~ R2#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 12.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 12.1.1.0/24 is directly connected, GigabitEthernet0/1 L 12.1.1.2/32 is directly connected, GigabitEthernet0/1 23.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 23.1.1.0/24 is directly connected, GigabitEthernet0/2 L 23.1.1.2/32 is directly connected, GigabitEthernet0/2 172.16.0.0/24 is subnetted, 1 subnets S 172.16.1.0/24 [1/0] via 23.1.1.3 S 192.168.1.0/24 [1/0] via 12.1.1.1 ~~~ ## R3: ~~~ R3#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 12.0.0.0/24 is subnetted, 1 subnets S 12.1.1.0/24 [1/0] via 23.1.1.2 23.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 23.1.1.0/24 is directly connected, GigabitEthernet0/2 L 23.1.1.3/32 is directly connected, GigabitEthernet0/2 172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks C 172.16.1.0/24 is directly connected, GigabitEthernet0/0 L 172.16.1.254/32 is directly connected, GigabitEthernet0/0 S 192.168.1.0/24 [1/0] via 23.1.1.2 ~~~ # 实验测试 通过 ping 测试连通性 * PC 0 与 PC 1 之间能够互相通信 * PC 与路由器之间能够互相通信 * 路由器之间能够互相通信 ## 拓展 在路由器上配置 telnet 相关设置,与交换机不同的是路由器的 ip 配置在了接口上