OSPF基本配置-qq5ca7fbcdb091c的博客

OSPF基本配置

1.(如上图)搭建好内部环境后
2.开始配置
路由器(AR1)
interface GigabitEthernet0/0/0
ip address 192.168.20.1 255.255.255.0
interface g0/0/1
ip address 192.168.22.1 255.255.255.0
quit
ospf 1 router-id 1.1.1.1
area 0.0.0.0
network 192.168.20.0 0.0.0.255
area 0.0.0.1
network 192.168.22.0 0.0.0.255
return

路由器(AR2)
interface GigabitEthernet0/0/0
ip address 192.168.23.1 255.255.255.0
interface g0/0/1
ip address 192.168.21.1 255.255.255.0
quit
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 192.168.23.0 0.0.0.255
area 0.0.0.1
network 192.168.21.0 0.0.0.255
return

三层交换机(SW2)
vlan batch 10 12 15 20 21
port-group 1
group-member g/0/0/1 g0/02 g0/03
port link-type trunk
port trunk allow-pass vlan all
quit
interface GigabitEthernet 0/0/2
port link-type access
port default vlan 20
interface g0/0/5
port link-type access
port default vlan 21
quit
interface Vlanif10
ip address 192.168.10.1 255.255.255.0
interface Vlanif12
ip address 192.168.12.1 255.255.255.0
interface Vlanif15
ip address 192.168.15.1 255.255.255.0
interface Vlanif20
ip address 192.168.20.2 255.255.255.0
interface Vlanif21
ip address 192.168.21.2 255.255.255.0
quit
ospf 1 router-id 12.12.12.12
area 0.0.0.0
network 192.168.20.0 0.0.0.255
network 192.168.15.0 0.0.0.255
network 192.168.10.0 0.0.0.255
area 0.0.0.1
network 192.168.21.0 0.0.0.255
network 192.168.12.0 0.0.0.255
return

三层交换机(SW4)
vlan batch 11 13 15 22 23
port-group 1
group-member g0/0/1 g0/0/3 g0/0/4
port link-type trunk
port trunk allow-pass vlan all
quit
interface GigabitEthernet 0/0/2
port link-type access
port default vlan 22
interface g0/0/5
port link-type access
port default vlan 23
quit
interface Vlanif11
ip address 192.168.11.1 255.255.255.0
interface Vlanif13
ip address 192.168.13.1 255.255.255.0
interface vlanif 15
ip address 192.168.15.2 255.255.255.0
interface vlanif 22
ip address 192.168.22.2 255.255.255.0
interface vlanif 23
ip address 192.168.23.2 255.255.255.0
quit
ospf 1 router-id 14.14.14.14
area 0.0.0.0
network 192.168.23.0 0.0.0.255
network 192.168.15.0 0.0.0.255
network 192.168.13.0 0.0.0.255
area 0.0.0.1
network 192.168.22.0 0.0.0.255
network 192.168.11.0 0.0.0.255
return

三层交换机(SW1)
vlan batch 5 10 11
port-group 1
group-member g0/0/1 g0/0/2 g0/0/3
port link-type trunk
port trunk allow-pass vlan all
quit
interface Vlanif5
ip address 192.168.5.1 255.255.255.0
interface Vlanif10
ip address 192.168.10.2 255.255.255.0
interface Vlanif11
ip address 192.168.11.2 255.255.255.0
quit
ospf 1 router-id 11.11.11.11
area 0.0.0.0
network 192.168.10.0 0.0.0.255
network 192.168.5.0 0.0.0.255
area 0.0.0.1
network 192.168.11.0 0.0.0.255
return

    三层交换机(SW3)
    vlan batch 5 12 13
    port-group 1
     group-member    g0/0/1  g0/0/2  g0/0/3
             port   link-type  trunk
             port   trunk  allow-pass  vlan  all
             quit
  interface Vlanif5
     ip address 192.168.5.2 255.255.255.0
interface Vlanif12
     ip address 192.168.12.2 255.255.255.0
interface Vlanif13
     ip address 192.168.13.2 255.255.255.0
    quit
    ospf 1 router-id 13.13.13.13
     area 0.0.0.0
        network 192.168.5.0 0.0.0.255
        network 192.168.13.0 0.0.0.255
     area 0.0.0.1
        network 192.168.12.0 0.0.0.255
return

    3.测试
      1)用三层交换机(SW1或SW3)ping路由器(Ar1或Ar2)
        2) 当用三层交换机SW3去ping其他主机时,会出现可以ping通路由器Ar2、SW4、SW1,却ping不通SW2与Ar1,这是因为与数据链路有关,只需将路由器Ar1的g/0/01接口的IP地址删掉在重新宣告,之后再进行ping测试,则三层交换机SW3可以ping所有设备主机了