ospf:基于链路状态,用dijkstra选择最短路由路径
拓扑图:
配置代码:
R1:
En
Conf t
Host r1
No ip domain-lookup
Int f0/0
Ip address 192.168.1.254 255.255.255.0
No shut
int f1/0
ip address 10.0.0.1 255.0.0.0
No shut
int s2/0
ip address 30.0.0.2 255.0.0.0
no shut
exit
router ospf 100
!进程号1-65535任意
network 30.0.0.0 0.255.255.255 area 0
!掩码用反码
network 10.0.0.0 0.255.255.255 area 0
network 192.168.1.0 0.0.0.255 area 0
End
Show ip route
R2:
En
Conf t
Host r2
No ip domain-lookup
Int f0/0
ip address 20.0.0.2 255.0.0.0
No shut
int f1/0
ip address 10.0.0.2 255.0.0.0
no shut
exit
router ospf 100
!进程号1-65535任意
network 20.0.0.0 0.255.255.255 area 0
network 10.0.0.0 0.255.255.255 area 0
End
Show ip route
R3:
En
Conf t
Host r3
No ip domain-lookup
Int f0/0
Ip address 192.168.0.254 255.255.255.0
No shut
int f1/0
ip address 20.0.0.1 255.0.0.0
No shut
int s2/0
ip address 30.0.0.1 255.0.0.0
no shut
exit
router ospf 100
!进程号1-65535任意
network 30.0.0.0 0.255.255.255 area 0
network 20.0.0.0 0.255.255.255 area 0
network 192.168.0.0 0.0.0.255 area 0
End
Show ip route