5.动态路由OSPF

拓扑图

1561033706526.png

实验步骤

配置三层交换机

en

conf t

hostname S3569

声明两个不同的 Vlan

vlan 10

exit

vlan 20

exit

将端口划分给Vlan

interface fa 0/10

switchport access vlan 10

exit

interface fa 0/20

switchport access vlan 20

exit

配置Vlan

interface vlan 10

ip address 192.168.1.1 255.255.255.0

no shutdown

exit

interface vlan 20

ip address 192.168.3.1 255.255.255.0

no shutdown

exit

开启交换机路由功能

ip routing

启动ospf协议,通告直连的网络

router ospf 1

network 192.168.1.0 0.0.0.255 area 0

network 192.168.3.0 0.0.0.255 area 0

end

show ip route

知识点:

  • OSPF宣告是要加反掩码的
  • area是自治系统区域的标识。eg:如果全局在一个area中,那么它们属于一个自治系统,也称为单区域自治系统

配置路由器Router0

en

conf t

hostname R0

配置端口

interface f0/0

no shutdown

ip address 192.168.3.2 255.255.255.0

exit

interface s0/0/0

no shutdown

ip address 192.168.4.1 255.255.255.0

clock rate 64000

end

查看当前路由表

show ip route

conf t

设置ospf协议

router ospf 1

network 192.168.3.0 0.0.0.255 area 0

network 192.168.4.0 0.0.0.255 area 0

end

再次查看路由表

show ip route

配置路由器Router1

en

conf t

hostname R2

配置端口

interface s0/0/0

no shutdown

ip address 192.168.4.2 255.255.255.0

exit

interface f0/0

no shutdown

ip address 192.168.2.1 255.255.255.0

end

查看当前路由表

show ip route

conf t

配置ospf

router ospf 1

network 192.168.2.0 0.0.0.255 area 0

network 192.168.4.0 0.0.0.255 area 0

end

再次查看路由表

show ip route

实验结果

查看Router0的路由表,可以看到已经获得了相邻网段的ip:

show ip route

1561035549271.png

你可能感兴趣的:(5.动态路由OSPF)