路由:数据转发时候的路径
静态路由:手动配置
动态路由:依据一定的算法进行计算得到的
- 基本配置+优化命令+设备名修改
Router>en
Router#conf t
Router(config)#no ip domain loo
Router(config)#line c 0
Router(config-line)#no exec-t
Router(config-line)#logg s
Router(config-line)#exit
Router(config)#ho R1
- 配置IP地址,且ping通直连
R1(config)#int f0/0
R1(config-if)#ip add 192.168.1.254 255.255.255.0
R1(config-if)#no sh
R1(config-if)#int f0/1
R1(config-if)#ip add 12.1.1.1 255.255.255.0
R1(config-if)#no sh
R2(config)#int f0/0
R2(config-if)#ip add 12.1.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int f0/1
R2(config-if)#ip add 23.1.1.2 255.255.255.0
R2(config-if)#no sh
R3(config)#int f0/0
R3(config-if)#ip add 23.1.1.3 255.255.255.0
R3(config-if)#no sh
R3(config-if)#int f0/1
R3(config-if)#ip add 10.1.1.254 255.255.255.0
R3(config-if)#no sh
R1:
Ping 192.168.1.1
Ping 12.1.1.2
R3:
Ping 23.1.1.2
Ping 10.1.1.1
“.”代表的是丢包,“!”代表收到回包
(do) sh ip int b
数据包在设备中没有相对应目标网络的路由,路由器会将数据包丢弃
- 配置静态路由,让PC0和PC1之间相互通信
R1(config)#ip route 10.1.1.0 255.255.255.0 12.1.1.2
//写一条静态路由,目标网络为10.1.1.0,目标网络的子网掩码为255.255.255.0,下一跳地址为12.1.1.2
R2(config)#ip route 10.1.1.0 255.255.255.0 23.1.1.3
R3(config-if)#ip route 192.168.1.0 255.255.255.0 23.1.1.2
R2(config)#ip route 192.168.1.0 255.255.255.0 12.1.1.1
- 查看现象
-
测试
-
配置静态路由,让全网通(每台设备上都有去往所有网络的路由)
R1(config)#ip route 23.1.1.0 255.255.255.0 12.1.1.2
R3(config)#ip route 12.1.1.0 255.255.255.0 23.1.1.2
-
检查现象
每台设备上都是4条路由 -
测试
实验:使用静态路由,实现全网通
- 基本配置+优化命令+设备名称修改
en
conf t
no ip domain loo
line c 0
no exec-t
logg s
exit
ho R1
- 配置接口IP地址,且ping通直连
R1(config)#int f0/0
R1(config-if)#ip add 192.168.1.254 255.255.255.0
R1(config-if)#no sh
(中间可以省略exit)
R1(config-if)#int f0/1
R1(config-if)#ip add 12.1.1.1 255.255.255.0
R1(config-if)#no sh
R2(config)#int f0/0
R2(config-if)#ip add 12.1.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int f0/1
R2(config-if)#ip add 23.1.1.2 255.255.255.0
R2(config-if)#no sh
R2(config-if)#int e1/0
R2(config-if)#ip add 24.1.1.2 255.255.255.0
R2(config-if)#no sh
R3(config)#int f0/0
R3(config-if)#ip add 172.16.1.254 255.255.255.0
R3(config-if)#no sh
R3(config-if)#int f0/1
R3(config-if)#ip add 23.1.1.3 255.255.255.0
R3(config-if)#no sh
R4(config)#int f0/0
R4(config-if)#ip add 24.1.1.4 255.255.255.0
R4(config-if)#no sh
R4(config-if)#int f0/1
R4(config-if)#ip add 10.1.1.254 255.255.255.0
R4(config-if)#no sh
R1:
Ping 192.168.1.1
Ping 12.1.1.2
R3:
Ping 172.16.1.1
Ping 23.1.1.2
R4:
Ping 10.1.1.1
Ping 24.1.1.2
.!!!!
3. 配置静态路,实现全网通
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
R1(config)#ip route 24.1.1.0 255.255.255.0 12.1.1.2
R1(config)#ip route 10.1.1.0 255.255.255.0 12.1.1.2
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
R2(config)#ip route 10.1.1.0 255.255.255.0 24.1.1.4
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
R3(config)#ip route 24.1.1.0 255.255.255.0 23.1.1.2
R3(config)#ip route 10.1.1.0 255.255.255.0 23.1.1.2
R4(config)#ip route 192.168.1.0 255.255.255.0 24.1.1.2
R4(config)#ip route 172.16.1.0 255.255.255.0 24.1.1.2
R4(config)#ip route 12.1.1.0 255.255.255.0 24.1.1.2
R4(config)#ip route 23.1.1.0 255.255.255.0 24.1.1.2
- 测试
用任意设备都可以ping通网络上的任意一个IP地址