大家好! 我是C07,在这里跟大家讲一下静态路由&动态路由的相关配置~
文章目录
- 路由器工作原理
- 路由是什么?
- 静态路由
- 什么是静态路由
- 静态路由的配置
- 默认路由
- 什么是静态路由
- 静态路由的配置
一、路由器的工作原理
一台路由器当收到数据包时,会由下往上进行解封装。当解封装到数据链路层时,只有在目的MAC为自己时才会接收(不是则丢弃),再进行解封装,当解封装到网络层时,发现目的IP地址不是给自己的,路由器则会查询路由表进行转发,如果路由表中不存在则丢弃。
华为路由器设备查询路由表的命令:
display ip routing-table
二、路由是什么?
简单来说,路由就像我们的导航一样,将一个个目的地写在一张地图中,路由是网络中的导航,指导数据包从起源到目的地的访问
就像我们的某某导航,会将我们想去的地方一个个的罗列出来,下一站该怎么走(是高铁还是大巴还是步行)
会在最上面列出一个最优的方案(而我们的路由表也是如此,但有些不一致的是路由器只会将同一目的地最优的路由列出来)
二、静态路由
我们的实验会从简单到难,循序渐进
实验一:
实验设备清单:
AR1220*3
拓扑图:
#AR1路由器配置
#从用户视图切换成系统视图
[Huawei]system-view
#将我们的路由器命名为AR1
[Huawei]sysname AR1
#配置AR1接口g0/0/0 将接口IP地址配置成12.1.1.1/24
[AR1]interface g0/0/0
[AR1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
#从接口视图切换成用户视图
[AR1-GigabitEthernet0/0/0]return
#保存我们的配置
<AR1>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
It will take several minutes to save configuration file, please wait.......
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
<AR1>
#AR2路由器配置
#从用户视图切换成系统视图
[Huawei]system-view
#将我们的路由器命名为AR2
[Huawei]sysname AR2
#配置AR2接口g0/0/0 将接口IP地址配置成12.1.1.2/24
[AR2]interface g0/0/0
[AR2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
#配置AR2接口g0/0/1 将接口IP地址配置成24.1.1.2/24
[AR2]interface g0/0/1
[AR2-GigabitEthernet0/0/0]ip add 24.1.1.2 24
#从接口视图切换成用户视图
[AR2-GigabitEthernet0/0/0]return
#保存我们的配置
<AR2>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
It will take several minutes to save configuration file, please wait.......
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
<AR2>
#我们也可以通过display ip interface brief来查看我们所配置的接口IP地址以及状态是否UP
<AR2>display ip interface brief
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 0
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 0
Interface IP Address/Mask