静态路由:静态路由是一种路由的方式,路由项由手动配置,而非动态决定。与动态路由不同,静态路由是固定的,不会改变,即使网络状况已经改变或是重新被组态。一般来说,静态路由是由网络管理员逐项加入路由表。静态路由适用于小型网络。
动态路由:动态路由是指路由器能够自动地建立自己的路由表,并且能够根据实际情况的变化适时地进行调整。常见的动态路由协议包括RIP、OSPF、IS-IS、BGP等。这里主要讲的是OSPF。OSPF(Open Shortest Path First)开放式最短路径优先)是一个内部网关协议(Interior Gateway Protocol,简称IGP),用于在单一自治系统(autonomous system,AS)内决策路由。与RIP相对,OSPF是链路状态路由协议,而RIP是距离向量路由协议。
不同路由的优先级(数值越小,优先级越高)
直连 --- 0
ospf内部 --- 10
ISIS --- 15
static -- 60
rip ---- 100
BGP --- 255
要求:要使PC1 pingt PC2
静态路由配置:
PC1
PC2
AR1
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname AR1
[AR1]undo in
[AR1]undo info-center e
[AR1]undo info-center enable
Info: Information center is disabled.
[AR1]int g0/0/1
[AR1-GigabitEthernet0/0/1]ip address 192.168.1.2 24
[AR1-GigabitEthernet0/0/1]int g0/0/0
[AR1-GigabitEthernet0/0/0]ip address 10.1.1.1 24
[AR1]int LoopBack 0
[AR1-LoopBack0]ip address 1.1.1.1 32
[AR1]ip route-static 192.168.2.0 255.255.255.0 10.1.1.2
AR2
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]undo in
[Huawei]undo info-center e
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]sysname AR2
[AR2]int g0/0/0
[AR2-GigabitEthernet0/0/0]ip address 10.1.1.2 24
[AR2-GigabitEthernet0/0/0]int g0/0/1
[AR2-GigabitEthernet0/0/1]ip address 10.1.2.2 24
[AR2-GigabitEthernet0/0/1]q
[AR2]int LoopBack 0
[AR2-LoopBack0]ip ad
[AR2-LoopBack0]ip address 2.2.2.2 32
[AR2-LoopBack0]q
[AR2]ip route-static 192.168.1.0 255.255.255.0 10.1.1.1
[AR2]ip route-static 192.168.2.0 255.255.255.0 10.1.2.1
AR3
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip address 10.1.2.1 24
[Huawei-GigabitEthernet0/0/1]int g0/0/2
[Huawei-GigabitEthernet0/0/2]ip address 192.168.2.2 24
[Huawei-GigabitEthernet0/0/2]q
[Huawei]int LoopBack 0
[Huawei-LoopBack0]ip a
[Huawei-LoopBack0]ip address 3.3.3.3 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 192.168.1.0 255.255.255.0 10.1.2.2
[Huawei]SYSNAME AR3
[AR3]
PC1 ping PC2
OSPF配置
先删除AR1、AR2 、AR3 的静态路由
AR1
[AR1]undo ip route-static 192.168.2.0 255.255.255.0 10.1.1.2
AR2
[AR2]undo ip route-static 192.168.1.0 255.255.255.0 10.1.1.1
[AR2]undo ip route-static 192.168.2.0 255.255.255.0 10.1.2.1
AR3
[AR3]undo ip route-static 192.168.1.0 255.255.255.0 10.1.2.2
AR1
[AR1]router id 1.1.1.1
Info: Router ID has been modified, please reset the relative protocols manually
to update the Router ID.
[AR1]ospf
[AR1-ospf-1]area 0
[AR1-ospf-1-area-0.0.0.0]network 192.168.1.0 0.0.0.255
[AR1-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[AR1-ospf-1-area-0.0.0.0]network 1.1.1.1 0.0.0.0
[AR1-ospf-1-area-0.0.0.0]q
AR2
[AR2]router id 2.2.2.2
Info: Router ID has been modified, please reset the relative protocols manually
to update the Router ID.
[AR2]ospf
[AR2-ospf-1]area 0
[AR2-ospf-1-area-0.0.0.0]netw
[AR2-ospf-1-area-0.0.0.0]network 10.1.1.0 0.0.0.255
[AR2-ospf-1-area-0.0.0.0]network 10.1.2.0 0.0.0.255
[AR2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
AR3
[AR3]router id 3.3.3.3
Info: Router ID has been modified, please reset the relative protocols manually
to update the Router ID.
[AR3]ospf
[AR3-ospf-1]area 0
[AR3-ospf-1-area-0.0.0.0]network 192.168.2.0 0.0.0.255
[AR3-ospf-1-area-0.0.0.0]network 10.1.2.0 0.0.0.255
[AR3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
PC1 ping PC2
查看AR2的路由表
<AR2>dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 15 Routes : 15
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.1/32 OSPF 10 1 D 10.1.1.1 GigabitEthernet
0/0/0
2.2.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0
3.3.3.3/32 OSPF 10 1 D 10.1.2.1 GigabitEthernet
0/0/1
10.1.1.0/24 Direct 0 0 D 10.1.1.2 GigabitEthernet
0/0/0
10.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
10.1.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
10.1.2.0/24 Direct 0 0 D 10.1.2.2 GigabitEthernet
0/0/1
10.1.2.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
10.1.2.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.1.0/24 OSPF 10 2 D 10.1.1.1 GigabitEthernet
0/0/0
192.168.2.0/24 OSPF 10 2 D 10.1.2.1 GigabitEthernet