2019-10-24 09:35:14 -05:00
|
|
|
!
|
2019-07-08 19:32:20 -05:00
|
|
|
{% if DEVICE_METADATA['localhost'].has_key('bgp_asn') %}
|
|
|
|
{% block bgp_init %}
|
|
|
|
!
|
|
|
|
! bgp multiple-instance
|
|
|
|
!
|
|
|
|
route-map FROM_BGP_SPEAKER_V4 permit 10
|
|
|
|
!
|
|
|
|
route-map TO_BGP_SPEAKER_V4 deny 10
|
|
|
|
!
|
2019-07-26 16:31:56 -05:00
|
|
|
{# generate loopback prefix-lists #}
|
|
|
|
{% for (name, prefix) in LOOPBACK_INTERFACE|pfx_filter %}
|
|
|
|
{% if prefix | ipv4 and name == 'Loopback0' %}
|
|
|
|
ip prefix-list PL_LoopbackV4 permit {{ prefix | ip }}/32
|
|
|
|
{% elif prefix | ipv6 and name == 'Loopback0' %}
|
2019-10-24 09:35:14 -05:00
|
|
|
ipv6 prefix-list PL_LoopbackV6 permit {{ prefix | replace('/128', '/64') | ip_network }}/64
|
2019-07-26 16:31:56 -05:00
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
!
|
|
|
|
{# generate default peer route-maps #}
|
|
|
|
!
|
|
|
|
route-map TO_BGP_PEER_V4 permit 100
|
|
|
|
!
|
|
|
|
route-map TO_BGP_PEER_V6 permit 100
|
|
|
|
!
|
2020-03-31 12:06:19 -05:00
|
|
|
{% if DEVICE_METADATA['localhost']['type'] == 'InternalFrontend' %}
|
|
|
|
route-map HIDE_INTERNAL permit 10
|
|
|
|
set community local-AS
|
|
|
|
!
|
|
|
|
{% endif %}
|
|
|
|
{% if DEVICE_METADATA['localhost']['type'] == 'InternalBackend' %}
|
|
|
|
route-map OVERRIDE_ORIGINATOR_ID permit 10
|
|
|
|
{% for (name, prefix) in LOOPBACK_INTERFACE|pfx_filter %}
|
|
|
|
{% if prefix | ipv4 and name == 'Loopback0' %}
|
|
|
|
set originator-id {{ prefix | ip }}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
!
|
|
|
|
{% endif %}
|
2019-10-07 18:05:07 -05:00
|
|
|
{% if BGP_MONITORS is defined and BGP_MONITORS|length > 0 %}
|
2019-11-22 22:43:44 -06:00
|
|
|
route-map FROM_BGPMON deny 10
|
2019-10-07 18:05:07 -05:00
|
|
|
!
|
2019-11-22 22:43:44 -06:00
|
|
|
route-map TO_BGPMON permit 10
|
2019-10-07 18:05:07 -05:00
|
|
|
!
|
|
|
|
{% endif %}
|
2019-10-24 09:35:14 -05:00
|
|
|
!
|
|
|
|
route-map ISOLATE permit 10
|
|
|
|
set as-path prepend {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
|
|
|
|
!
|
|
|
|
route-map set-next-hop-global-v6 permit 10
|
|
|
|
set ipv6 next-hop prefer-global
|
|
|
|
!
|
2019-07-08 19:32:20 -05:00
|
|
|
router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
|
2020-03-31 12:06:19 -05:00
|
|
|
{% if DEVICE_METADATA['localhost']['type'] == 'InternalFrontend' %}
|
|
|
|
redistribute connected route-map HIDE_INTERNAL
|
|
|
|
{% endif %}
|
2019-07-08 19:32:20 -05:00
|
|
|
bgp log-neighbor-changes
|
|
|
|
bgp bestpath as-path multipath-relax
|
|
|
|
no bgp default ipv4-unicast
|
|
|
|
bgp graceful-restart restart-time 240
|
|
|
|
bgp graceful-restart
|
|
|
|
{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
|
|
|
|
bgp graceful-restart preserve-fw-state
|
|
|
|
{% endif %}
|
|
|
|
{% for (name, prefix) in LOOPBACK_INTERFACE|pfx_filter %}
|
|
|
|
{% if prefix | ipv4 and name == 'Loopback0' %}
|
|
|
|
bgp router-id {{ prefix | ip }}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{# advertise loopback #}
|
|
|
|
{% for (name, prefix) in LOOPBACK_INTERFACE|pfx_filter %}
|
|
|
|
{% if prefix | ipv4 and name == 'Loopback0' %}
|
|
|
|
network {{ prefix | ip }}/32
|
|
|
|
{% elif prefix | ipv6 and name == 'Loopback0' %}
|
|
|
|
address-family ipv6
|
|
|
|
network {{ prefix | ip }}/64
|
|
|
|
exit-address-family
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endblock bgp_init %}
|
|
|
|
{% endif %}
|
|
|
|
{% block vlan_advertisement %}
|
|
|
|
{% for (name, prefix) in VLAN_INTERFACE|pfx_filter %}
|
|
|
|
{% if prefix | ipv4 %}
|
|
|
|
network {{ prefix }}
|
|
|
|
{% elif prefix | ipv6 %}
|
|
|
|
address-family ipv6
|
|
|
|
network {{ prefix }}
|
|
|
|
exit-address-family
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endblock vlan_advertisement %}
|
2019-10-24 09:35:14 -05:00
|
|
|
{% block maximum_paths %}
|
2019-07-08 19:32:20 -05:00
|
|
|
address-family ipv4
|
|
|
|
maximum-paths 64
|
|
|
|
exit-address-family
|
|
|
|
address-family ipv6
|
|
|
|
maximum-paths 64
|
|
|
|
exit-address-family
|
2019-10-24 09:35:14 -05:00
|
|
|
{% endblock maximum_paths %}
|
|
|
|
{% block peers_peer_group %}
|
|
|
|
neighbor PEER_V4 peer-group
|
|
|
|
neighbor PEER_V6 peer-group
|
|
|
|
address-family ipv4
|
|
|
|
{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
|
|
|
|
neighbor PEER_V4 allowas-in 1
|
2019-07-08 19:32:20 -05:00
|
|
|
{% endif %}
|
2019-10-24 09:35:14 -05:00
|
|
|
neighbor PEER_V4 soft-reconfiguration inbound
|
|
|
|
neighbor PEER_V4 route-map TO_BGP_PEER_V4 out
|
|
|
|
exit-address-family
|
|
|
|
address-family ipv6
|
|
|
|
{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
|
|
|
|
neighbor PEER_V6 allowas-in 1
|
2019-07-08 19:32:20 -05:00
|
|
|
{% endif %}
|
2019-10-24 09:35:14 -05:00
|
|
|
neighbor PEER_V6 soft-reconfiguration inbound
|
|
|
|
neighbor PEER_V6 route-map TO_BGP_PEER_V6 out
|
|
|
|
exit-address-family
|
|
|
|
{% endblock peers_peer_group %}
|
2019-07-08 19:32:20 -05:00
|
|
|
{% block bgp_peers_with_range %}
|
|
|
|
{% if BGP_PEER_RANGE %}
|
|
|
|
{% for bgp_peer in BGP_PEER_RANGE.values() %}
|
|
|
|
neighbor {{ bgp_peer['name'] }} peer-group
|
|
|
|
neighbor {{ bgp_peer['name'] }} passive
|
|
|
|
{% if bgp_peer['peer_asn'] is defined %}
|
|
|
|
neighbor {{ bgp_peer['name'] }} remote-as {{ bgp_peer['peer_asn'] }}
|
|
|
|
{% else %}
|
2019-11-06 18:07:28 -06:00
|
|
|
neighbor {{ bgp_peer['name'] }} remote-as {{ constants.deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
|
2019-07-08 19:32:20 -05:00
|
|
|
{% endif %}
|
|
|
|
neighbor {{ bgp_peer['name'] }} ebgp-multihop 255
|
|
|
|
neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound
|
|
|
|
{% if bgp_peer['src_address'] is defined %}
|
|
|
|
neighbor {{ bgp_peer['name'] }} update-source {{ bgp_peer['src_address'] | ip }}
|
|
|
|
{% else %}
|
|
|
|
{% for (name, prefix) in LOOPBACK_INTERFACE|pfx_filter %}
|
|
|
|
{% if name == 'Loopback1' %}
|
|
|
|
neighbor {{ bgp_peer['name'] }} update-source {{ prefix | ip }}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
neighbor {{ bgp_peer['name'] }} route-map FROM_BGP_SPEAKER_V4 in
|
|
|
|
neighbor {{ bgp_peer['name'] }} route-map TO_BGP_SPEAKER_V4 out
|
|
|
|
{% for ip_range in bgp_peer['ip_range'] %}
|
|
|
|
bgp listen range {{ip_range}} peer-group {{ bgp_peer['name'] }}
|
|
|
|
{% endfor %}
|
|
|
|
address-family ipv4
|
|
|
|
neighbor {{ bgp_peer['name'] }} activate
|
|
|
|
exit-address-family
|
|
|
|
address-family ipv6
|
|
|
|
neighbor {{ bgp_peer['name'] }} activate
|
|
|
|
exit-address-family
|
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% endblock bgp_peers_with_range %}
|
2019-10-07 18:05:07 -05:00
|
|
|
{% block bgp_monitors %}
|
|
|
|
{% if BGP_MONITORS is defined and BGP_MONITORS|length > 0 %}
|
2019-11-22 22:43:44 -06:00
|
|
|
neighbor BGPMON peer-group
|
2019-10-07 18:05:07 -05:00
|
|
|
{% for (name, prefix) in LOOPBACK_INTERFACE|pfx_filter %}
|
|
|
|
{% if prefix | ipv4 and name == 'Loopback0' %}
|
2019-11-22 22:43:44 -06:00
|
|
|
neighbor BGPMON update-source {{ prefix | ip }}
|
2019-10-07 18:05:07 -05:00
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
2019-11-22 22:43:44 -06:00
|
|
|
neighbor BGPMON route-map FROM_BGPMON in
|
|
|
|
neighbor BGPMON route-map TO_BGPMON out
|
|
|
|
neighbor BGPMON send-community
|
|
|
|
neighbor BGPMON maximum-prefix 1
|
2019-10-07 18:05:07 -05:00
|
|
|
{% for neighbor_addr, bgp_session in BGP_MONITORS.items() %}
|
|
|
|
neighbor {{ neighbor_addr }} remote-as {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
|
2019-11-22 22:43:44 -06:00
|
|
|
neighbor {{ neighbor_addr }} peer-group BGPMON
|
2019-10-07 18:05:07 -05:00
|
|
|
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
|
|
|
|
neighbor {{ neighbor_addr }} activate
|
2020-03-31 12:06:19 -05:00
|
|
|
{% if DEVICE_METADATA['localhost']['type'] == 'InternalBackend' %}
|
|
|
|
neighbor {{ neighbor_addr }} route-map OVERRIDE_ORIGINATOR_ID in
|
|
|
|
{% endif %}
|
2019-11-22 22:43:44 -06:00
|
|
|
address-family ipv6
|
|
|
|
neighbor {{ neighbor_addr }} activate
|
|
|
|
exit-address-family
|
2019-10-07 18:05:07 -05:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% endblock bgp_monitors %}
|
2019-07-08 19:32:20 -05:00
|
|
|
!
|