Bookmark this page

Implementing Dynamic Routing with EBGP

Objectives

After completing this section, you should be able to use Ansible to configure the External Border Gateway Protocol (EBGP) to perform dynamic routing between multiple autonomous systems.

Implementing EBGP

Other routing protocols, such as EBGP, for instance, can be implemented in a similar way.

The following is a minimal configuration for EBGP on a VyOS device:

set interfaces loopback lo address 10.0.0.1/32
set protocols bgp 100 parameters router-id '10.0.0.1'
set protocols bgp 100 network 10.10.1.0/24
set protocols bgp 100 network 10.10.10.0/24
set protocols bgp 100 neighbor 172.25.250.61 remote-as '200'

This configuration:

  • Binds IPv4 address 10.0.0.1/32 to the loopback interfaces.

  • Configures the BGP router-id as the loopback address.

  • Defines the networks known to this router.

  • Defines the BGP neighbor.

Describing a VyOS Template for EBGP

A Jinja2 template takes BGP data and uses it to produce VyOS EBGP configuration statements.

$ cat j2/vyos-bgp.j2
set protocols bgp {{ bgp_data[inventory_hostname]['as'] }} parameters router-id {{ bgp_data[inventory_hostname]
['router-id'] | ipaddr("address") }}
{% for nei in bgp_data[inventory_hostname]['neighbors'] -%}
set protocols bgp {{ bgp_data[inventory_hostname]['as'] }} neighbor {{ nei['ipv4'] | ipaddr('address') }} remote-as
{{ nei['as'] }}
{% endfor -%}
{% for net in bgp_data[inventory_hostname]['networks'] -%}
set protocols bgp {{ bgp_data[inventory_hostname]['as'] }} network {{ net }}
{% endfor -%}

The following playbook uses the template to implement EBGP on a VyOS device:

- name: Play that sets up eBGP on the spine devices
  hosts: spines
  gather_facts: no
  vars_files:
    - "{{ playbook_dir }}/vars/bgp-vars.yml

  tasks:
    - name: configure devices
      vyos_config:
        src: j2/vyos-bgp.j2
        save: yes
Revision: do457-2.5-4693601