项目目标:通过ospf让路由器学习到pc网段和每台路由的换回接口,实现互通
1.构建直连
R1的基础配置
interface GigabitEthernet0/0/0
ip address 172.16.10.1 24
interface GigabitEthernet0/0/1
ip address 10.10.14.1 24
interface GigabitEthernet0/0/2
ip address 10.10.12.1 24
lookback 0
ip address 10.10.0.1 3
R2的基础配置
interface GigabitEthernet0/0/1
ip address 10.10.12.2 24
interface GigabitEthernet0/0/2
ip address 10.10.23.2 24
lookback 0
ip address 10.10.0.2 32
R3的基础配置
interface GigabitEthernet0/0/0
ip address 172.16.30.3 24
interface GigabitEthernet0/0/1
ip address 10.10.34.3 24
interface GigabitEthernet0/0/2
ip address 10.10.23.3 24
lookback 0
ip address 10.10.0.3 32
R4的基础配置
interface GigabitEthernet0/0/1
ip address 10.10.14.4 24
interface GigabitEthernet0/0/2
ip address 10.10.34.4 24
lookback 0
ip address 10.10.0.4 32
pc1基础配置
pc2基础配置
2.进行ospf配置
ps:进行配置时使用掩码为反掩码
R1的ospf配置
ospf 1 router-id 10.10.0.1
area 0.0.0.0
network 172.16.10.0 0.0.0.255
network 10.10.12.0 0.0.0.255
network 10.10.14.0 0.0.0.255
network 10.10.0.1 0.0.0.0
进入接口后使用命令将接口加入ospf区域
命令为ospf enable (ospf进程号)area (ospf区域)
R2的ospf配置
interface GigabitEthernet0/0/1
ospf enable 2 area 0.0.0.0
interface GigabitEthernet0/0/2
ospf enable 2 area 0.0.0.0
interface LoopBack0
ospf enable 2 area 0.0.0.0
R3的ospf配置
ospf 3 router-id 10.10.0.3
area 0.0.0.0
network 0.0.0.0 255.255.255.255(匹配所有ip子网)
3.查看ospf邻居详情
在R3查看邻居关系
验证pc之间的通信(1)
在R2上查看ospf路由
验证pc之间的通信(2)
pc1向pc2发起ping测试
将R4加入ospf域
R4的ospf配置
ospf 4 router-id 10.10.0.4
area 0.0.0.0
network 10.10.14.0 0.0.0.255
network 10.10.34.0 0.0.0.255
network 10.10.0.4 0.0.0.0
查看ospf路由
在R3查看ospf路由