几个概念
1.ospf是分区域的,其中area0 即区域0是主干区域,其他区域都必须与它相连
2.ospf的基本格式:
router ospf 进程号
network ip地址段 子网掩码的反码 area 进程号
例如network 1.1.1.0 0.0.0.255 area 1
3.划分区域是按照端口来划分
上面的图例,如果用ospf联通的话,需要写如下的命令
R1上
- !
- interface Ethernet0/0
- no ip address
- shutdown
- half-duplex
- !
- interface Ethernet0/1
- ip address 192.168.12.1 255.255.255.0
- half-duplex
- !
- interface Ethernet0/2
- no ip address
- shutdown
- half-duplex
- !
- interface Ethernet0/3
- no ip address
- shutdown
- half-duplex
- !
- router ospf 100
- log-adjacency-changes
- network 192.168.12.0 0.0.0.255 area 1
- !
R2
- !
- interface Loopback1
- ip address 2.2.2.2 255.255.255.0
- !
- interface Ethernet0/0
- ip address 192.168.12.2 255.255.255.0
- half-duplex
- !
- interface Ethernet0/1
- ip address 192.168.23.2 255.255.255.0
- half-duplex
- !
- interface Ethernet0/2
- no ip address
- shutdown
- half-duplex
- !
- interface Ethernet0/3
- no ip address
- shutdown
- half-duplex
- !
- router ospf 100
- log-adjacency-changes
- network 2.2.2.0 0.0.0.255 area 0
- network 192.168.12.0 0.0.0.255 area 1
- network 192.168.23.0 0.0.0.255 area 0
- !
R3
- !
- interface Loopback1
- ip address 3.3.3.3 255.255.255.0
- !
- interface Ethernet0/0
- ip address 192.168.23.3 255.255.255.0
- half-duplex
- !
- interface Ethernet0/1
- ip address 192.168.34.3 255.255.255.0
- half-duplex
- !
- interface Ethernet0/2
- no ip address
- shutdown
- half-duplex
- !
- interface Ethernet0/3
- no ip address
- shutdown
- half-duplex
- !
- router ospf 100
- log-adjacency-changes
- network 3.3.3.0 0.0.0.255 area 0
- network 192.168.23.0 0.0.0.255 area 0
- network 192.168.34.0 0.0.0.255 area 2
- !
R4
- !
- interface Ethernet0/0
- ip address 192.168.34.4 255.255.255.0
- half-duplex
- !
- interface Ethernet0/1
- no ip address
- shutdown
- half-duplex
- !
- interface Ethernet0/2
- no ip address
- shutdown
- half-duplex
- !
- interface Ethernet0/3
- no ip address
- shutdown
- half-duplex
- !
- router ospf 100
- log-adjacency-changes
- network 192.168.34.0 0.0.0.255 area 2
- !