Building an OSPF Network from Scratch with Ansible

Building an OSPF Network from Scratch with Ansible
Table of Contents

This post is part of an ongoing series - see all the posts below.

Ansible Course

So far in this series, we've been working with pretty much the same set of devices, core1, core2, access1, access2, and access3. We've used them to configure VLANs, NTP, syslog, and interface descriptions, and to learn the core Ansible concepts along the way.

For this part, we're going to start with a new topology and put everything we've learned into practice with a real-world example. The lab has six Cisco routers, split across three OSPF areas. I created it using Containerlab, and I've included the topology file below, so you should be able to build the same lab and follow along.

name: ospf_lab

mgmt:
  network: mgmt
  ipv4-subnet: 192.168.202.0/24

topology:
  kinds:
    cisco_iol:
      image: cisco-iol-17.12.01

  nodes:
    r1:
      kind: cisco_iol
      mgmt-ipv4: 192.168.202.101
    r2:
      kind: cisco_iol
      mgmt-ipv4: 192.168.202.102
    r3:
      kind: cisco_iol
      mgmt-ipv4: 192.168.202.103
    r4:
      kind: cisco_iol
      mgmt-ipv4: 192.168.202.104
    r5:
      kind: cisco_iol
      mgmt-ipv4: 192.168.202.105
    r6:
      kind: cisco_iol
      mgmt-ipv4: 192.168.202.106

  links:
    # Area 0
    - endpoints: ["r1:Ethernet0/1", "r2:Ethernet0/1"]   # 10.100.12.x
    - endpoints: ["r1:Ethernet0/2", "r4:Ethernet0/2"]   # 10.100.14.x
    - endpoints: ["r1:Ethernet0/3", "r3:Ethernet0/3"]   # 10.100.13.x
    - endpoints: ["r2:Ethernet0/2", "r3:Ethernet0/2"]   # 10.100.23.x
    - endpoints: ["r2:Ethernet0/3", "r4:Ethernet0/3"]   # 10.100.24.x
    - endpoints: ["r3:Ethernet0/1", "r4:Ethernet0/1"]   # 10.100.34.x
    # Area 1
    - endpoints: ["r1:Ethernet1/0", "r5:Ethernet1/0"]   # 10.100.15.x
    - endpoints: ["r3:Ethernet1/1", "r5:Ethernet1/1"]   # 10.100.35.x
    # Area 2
    - endpoints: ["r2:Ethernet1/0", "r6:Ethernet1/0"]   # 10.100.26.x
    - endpoints: ["r4:Ethernet1/1", "r6:Ethernet1/1"]   # 10.100.46.x

If you're new to Containerlab, I've written quite a few posts about it, covering everything from installing it to building your first lab. Feel free to check them out here.

ospf diagram
ospf diagram

As you can see in the diagram above, the lab has six routers split across three OSPF areas. r1, r2, r3, and r4 form the backbone in area 0. r5 connects to r1 and r3 in area 1, and r6 connects to r2 and r4 in area 2. So r1 and r3 act as the Area Border Routers (ABRs) for area 1, while r2 and r4 are the ABRs for area 2. The numbers next to each link are the interface numbers on each router, which are all Ethernet interfaces.

Great! You’ve successfully signed up.
Welcome back! You've successfully signed in.
You've successfully subscribed to Packetswitch.
Your link has expired.
Success! Check your email for magic link to sign-in.
Success! Your billing info has been updated.
Your billing was not updated.