Subscribe to our blog
multi-vendor prefix-lists blog

To keep the networks healthy, cause connectivity matters

I love being a network engineer, even though I struggled to explain to non-networking people about the utmost relevance of network administration. However, during the last two years of the COVID-19 pandemic, the world could see the relevance of having connectivity. Networks are the highways of information. Data, applications, entertainment, and factories need the network connectivity roads to make the world run. It’s interesting that even network models to estimate traffic behavior use algorithms that are similar to the ones to estimate transportation.

To enable this communication, networks have to interconnect through routing protocols. There are many ways to configure routing; you can permit or restrict traffic to certain networks to leave some sectors isolated, and propagate routes to allow connectivity only to specific segments of your network.

When you configure routing settings to allow this interconnection, you not only want to reach the ultimate purpose of configuring connectivity, but you want to do this in an efficient manner. 

The use of prefix-lists is one mechanism to permit a better use of resources in your routers. In this blog we are going to briefly cover why prefix-lists configuration is relevant, and how you can simplify this configuration through automation with Red Hat Ansible Automation Platform.

Why are prefix-lists relevant?

Prefix lists are commonly used to configure route maps and route filtering operations, and usually replace access lists. They are used for every routing protocol: BGP, OSPF, ISIS, and RIP are very common configurations among network operations. 

Depending on the company and IT needs, routing configuration can be very dynamic: New routes will be added for route advertisements (prefixes), and removed networks will have their routes removed for prefix announcements. 

How do they work?

Each statement of a prefix list has a sequence number to permit deletion or insertion of individual commands into a particular sequence position. Each command has a permit or deny action to match packets; permit implies a route is matched, while deny implies that a route is denied. Prefix-lists work similarly to access-lists in that ordered entries are processed sequentially and the evaluation of a prefix against a prefix list will end the moment a match is found.

A prefix-list command has a structure like: 

ip prefix-list list-name [seq seq-value] {deny network/length | permit network/ length}[ge ge-value] [le le-value]

Now let’s see how we can automate this configuration in a simple and structured manner using network resource modules.

Using network resource modules to automate prefix-lists configuration

What's an Ansible network resource module?

An Ansible network resource module can read and configure a specific resource, such as a prefix-list, on a network device. They allow for configuration of subsections or resources within the network device configuration, in a consistent way across multi-vendor network devices (Arista EOS, Cisco NX-OS, Cisco IOS and IOS-XE, Juniper JunOS, VYOS, and Cisco IOS-XR)

You can use the network resource modules to specify the behavior of your configuration by assigning the following states: merged, replaced, overridden, gathered, rendered, parsed, or deleted.

In very simple words, resource modules are the bricks, the solid foundation that allow you to create automation content ready for production.

Automating with playbooks

In a multi-vendor environment, you might want to configure in a simple and consistent manner. This is achieved in the following example through the selection of specific resource modules depending on OS conditions. 

Note this demo environment has four routers: 

  • rtr1 with Cisco IOS XE
  • rtr2 with Arista EOS
  • rtr3 with Juniper JUNOS
  • rtr4 with Arista EOS

You can see below highlighted how this works for Cisco IOS (IOS-XE router) and Arista EOS. This means the Juniper router will not be configured this time:

- name: configure prefix-lists
 hosts: network
 gather_facts: false
 - name: Merge IOS XE provided Prefix lists configuration
       - afi: "ipv4"
           - name: "v401"
               - action: "deny"
                 prefix: ""
                 sequence: 25
       - afi: ipv6
           - name: test_ipv6
             description: this is ipv6 merge test
               - action: deny
                 prefix: 2001:DB8:0:4::/64
                 ge: 80
                 le: 100
                 sequence: 10
     state: merged           
   when: ('ios' in ansible_network_os)
 - name: Merge EOS provided Prefix lists configuration
       - afi: "ipv4"
           - name: "v401"
               - sequence: 25
                 action: "deny"
                 address: ""
               - sequence: 100
                 action: "permit"
                 address: ""
                   masklen: 32
                   operator: "ge"
           - name: "v402"
               - action: "deny"
                 address: ""
                 sequence: 10
                   masklen: 32
                   operator: "ge"
       - afi: "ipv6"
           - name: "v601"
               - sequence: 125
                 action: "deny"
                 address: "5000:1::/64"
     state: merged           
   when: ('eos' in ansible_network_os)

After you run this template, you will see rtr3 was not impacted as it did not match the condition rules. Condition statements can follow different criterias, and this is particularly interesting when you have standard rules that you can follow such as hostnames or IP addresses per location, or network purpose (i.e. aggregation, core).

After the execution using Red Hat Ansible Automation Platform, you can even check the full configuration in a structure JSON format which looks like this:

Key takeaways

As you can see, you can keep governance of your network configuration but still add automation and logic into the most common configuration scenarios, such as prefix-lists.

Network resource modules can simplify the automation content creation process by providing the building blocks. We covered a multi-vendor scenario, including Arista EOS and Cisco IOS XE routers following specific rules, and this configuration can be extended for other scenarios following different rules according to your specific needs. 

Continuing the network automation adventure:

Want to try Ansible Automation Platform in your own environment? 

We offer an Ansible Automation Platform trial.

Interested in developing human-readable automation with Ansible? 

DO007 is a free self-paced online video course to expand your automation skills. We also provide short self-paced, interactive labs with Ansible Automation Platform 2.

Want to learn more about network automation use cases?

Check out additional information about network automation use cases; you are also invited to try Ansible Automation Platform for a free trial. 

Additional documentation to start can be found here: 

Want to learn more about network resource modules?

You can check the available resource modules here: 

Want to recreate the demo?

You can recreate this demo scenario anytime using the GitHub Code to recreate the automation for these tasks. 

About the author

Dafné is a Principal Technical Marketing Manager for Ansible Automation Platform Business Unit at Red Hat. Prior to Red Hat, Dafné worked at Cisco Systems, supporting Service Providers customers across US, Canada and Latin America to design, implement and adopt automation, orchestration and network management solutions. She brings over 15 years of experience in the IT field with specializations in DevNet, ITIL, SCRUM, consulting, networking and automation.

Read full bio

Browse by channel

automation icon


The latest on IT automation that spans tech, teams, and environments

AI icon

Artificial intelligence

Explore the platforms and partners building a faster path for AI

open hybrid cloud icon

Open hybrid cloud

Explore how we build a more flexible future with hybrid cloud

security icon


Explore how we reduce risks across environments and technologies

edge icon

Edge computing

Updates on the solutions that simplify infrastructure at the edge

Infrastructure icon


Stay up to date on the world’s leading enterprise Linux platform

application development icon


The latest on our solutions to the toughest application challenges

Original series icon

Original shows

Entertaining stories from the makers and leaders in enterprise tech