2017-01-19 22:56:26 -06:00
|
|
|
!
|
|
|
|
{% block banner %}
|
|
|
|
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
|
2017-09-12 16:13:27 -05:00
|
|
|
! generated by templates/quagga/bgpd.conf.j2 with config DB data
|
2017-01-19 22:56:26 -06:00
|
|
|
! file: bgpd.conf
|
|
|
|
!
|
|
|
|
{% endblock banner %}
|
|
|
|
!
|
|
|
|
{% block system_init %}
|
2017-09-12 16:13:27 -05:00
|
|
|
hostname {{ DEVICE_METADATA['localhost']['hostname'] }}
|
2017-01-19 22:56:26 -06:00
|
|
|
password zebra
|
|
|
|
log syslog informational
|
|
|
|
log facility local4
|
|
|
|
! enable password {# {{ en_passwd }} TODO: param needed #}
|
|
|
|
{% endblock system_init %}
|
|
|
|
!
|
2017-08-08 18:23:58 -05:00
|
|
|
{% if DEVICE_METADATA['localhost'].has_key('bgp_asn') %}
|
2017-01-19 22:56:26 -06:00
|
|
|
{% block bgp_init %}
|
|
|
|
!
|
|
|
|
! bgp multiple-instance
|
|
|
|
!
|
2017-06-21 20:52:50 -05:00
|
|
|
route-map FROM_BGP_SPEAKER_V4 permit 10
|
|
|
|
!
|
|
|
|
route-map TO_BGP_SPEAKER_V4 deny 10
|
|
|
|
!
|
2019-10-15 20:43:52 -05:00
|
|
|
{% if BGP_MONITORS is defined and BGP_MONITORS|length > 0 %}
|
2019-12-01 00:28:46 -06:00
|
|
|
route-map FROM_BGPMON deny 10
|
2019-10-15 20:43:52 -05:00
|
|
|
!
|
2019-12-01 00:28:46 -06:00
|
|
|
route-map TO_BGPMON permit 10
|
2019-10-15 20:43:52 -05:00
|
|
|
!
|
|
|
|
{% endif %}
|
2017-08-08 18:23:58 -05:00
|
|
|
router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
|
2017-01-19 22:56:26 -06:00
|
|
|
bgp log-neighbor-changes
|
|
|
|
bgp bestpath as-path multipath-relax
|
2017-08-30 15:06:02 -05:00
|
|
|
no bgp default ipv4-unicast
|
2019-04-10 21:13:03 -05:00
|
|
|
bgp graceful-restart restart-time 240
|
2017-03-31 15:25:39 -05:00
|
|
|
bgp graceful-restart
|
2017-09-12 16:13:27 -05:00
|
|
|
{% for (name, prefix) in LOOPBACK_INTERFACE %}
|
2017-10-20 09:15:11 -05:00
|
|
|
{% if prefix | ipv4 and name == 'Loopback0' %}
|
2017-09-12 16:13:27 -05:00
|
|
|
bgp router-id {{ prefix | ip }}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
2017-01-19 22:56:26 -06:00
|
|
|
{# advertise loopback #}
|
2017-09-12 16:13:27 -05:00
|
|
|
{% for (name, prefix) in LOOPBACK_INTERFACE %}
|
2017-10-20 09:15:11 -05:00
|
|
|
{% if prefix | ipv4 and name == 'Loopback0' %}
|
2017-09-12 16:13:27 -05:00
|
|
|
network {{ prefix | ip }}/32
|
2017-10-20 09:15:11 -05:00
|
|
|
{% elif prefix | ipv6 and name == 'Loopback0' %}
|
2017-01-19 22:56:26 -06:00
|
|
|
address-family ipv6
|
2017-10-17 20:28:27 -05:00
|
|
|
network {{ prefix | ip }}/64
|
2017-01-19 22:56:26 -06:00
|
|
|
exit-address-family
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
|
|
|
{% endblock bgp_init %}
|
2017-03-27 16:22:04 -05:00
|
|
|
{% endif %}
|
2017-01-19 22:56:26 -06:00
|
|
|
{% block vlan_advertisement %}
|
2017-09-12 16:13:27 -05:00
|
|
|
{% for (name, prefix) in VLAN_INTERFACE %}
|
|
|
|
{% if prefix | ipv4 %}
|
|
|
|
network {{ prefix }}
|
|
|
|
{% elif prefix | ipv6 %}
|
2017-08-16 23:12:32 -05:00
|
|
|
address-family ipv6
|
2017-09-12 16:13:27 -05:00
|
|
|
network {{ prefix }}
|
2017-08-16 23:12:32 -05:00
|
|
|
exit-address-family
|
|
|
|
{% endif %}
|
2017-01-19 22:56:26 -06:00
|
|
|
{% endfor %}
|
|
|
|
{% endblock vlan_advertisement %}
|
2017-06-21 20:52:50 -05:00
|
|
|
{% block bgp_peers_with_range %}
|
2017-09-12 16:13:27 -05:00
|
|
|
{% if BGP_PEER_RANGE %}
|
2017-08-08 18:23:58 -05:00
|
|
|
{% for bgp_peer in BGP_PEER_RANGE.values() %}
|
2017-06-21 20:52:50 -05:00
|
|
|
neighbor {{ bgp_peer['name'] }} peer-group
|
|
|
|
neighbor {{ bgp_peer['name'] }} passive
|
2019-04-10 23:50:36 -05:00
|
|
|
{% if bgp_peer['peer_asn'] is defined %}
|
|
|
|
neighbor {{ bgp_peer['name'] }} remote-as {{ bgp_peer['peer_asn'] }}
|
|
|
|
{% else %}
|
2017-09-18 15:04:29 -05:00
|
|
|
neighbor {{ bgp_peer['name'] }} remote-as {{ deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
|
2019-04-10 23:50:36 -05:00
|
|
|
{% endif %}
|
2017-06-21 20:52:50 -05:00
|
|
|
neighbor {{ bgp_peer['name'] }} ebgp-multihop 255
|
|
|
|
neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound
|
2019-04-10 23:50:36 -05:00
|
|
|
{% if bgp_peer['src_address'] is defined %}
|
|
|
|
neighbor {{ bgp_peer['name'] }} update-source {{ bgp_peer['src_address'] | ip }}
|
|
|
|
{% else %}
|
2017-10-20 09:15:11 -05:00
|
|
|
{% for (name, prefix) in LOOPBACK_INTERFACE %}
|
|
|
|
{% if name == 'Loopback1' %}
|
|
|
|
neighbor {{ bgp_peer['name'] }} update-source {{ prefix | ip }}
|
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
2019-04-10 23:50:36 -05:00
|
|
|
{% endif %}
|
2017-06-21 20:52:50 -05:00
|
|
|
neighbor {{ bgp_peer['name'] }} route-map FROM_BGP_SPEAKER_V4 in
|
|
|
|
neighbor {{ bgp_peer['name'] }} route-map TO_BGP_SPEAKER_V4 out
|
2017-07-13 17:03:10 -05:00
|
|
|
{% for ip_range in bgp_peer['ip_range'] %}
|
|
|
|
bgp listen range {{ip_range}} peer-group {{ bgp_peer['name'] }}
|
|
|
|
{% endfor %}
|
2017-08-30 15:06:02 -05:00
|
|
|
address-family ipv4
|
|
|
|
neighbor {{ bgp_peer['name'] }} activate
|
|
|
|
maximum-paths 64
|
|
|
|
exit-address-family
|
|
|
|
address-family ipv6
|
|
|
|
neighbor {{ bgp_peer['name'] }} activate
|
|
|
|
maximum-paths 64
|
|
|
|
exit-address-family
|
2017-06-21 20:52:50 -05:00
|
|
|
{% endfor %}
|
2017-09-12 16:13:27 -05:00
|
|
|
{% endif %}
|
2017-06-21 20:52:50 -05:00
|
|
|
{% endblock bgp_peers_with_range %}
|
2019-10-15 20:43:52 -05:00
|
|
|
{% block bgp_monitors %}
|
|
|
|
{% if BGP_MONITORS is defined and BGP_MONITORS|length > 0 %}
|
2019-12-01 00:28:46 -06:00
|
|
|
neighbor BGPMON peer-group
|
|
|
|
neighbor BGPMON activate
|
2019-10-15 20:43:52 -05:00
|
|
|
{% for (name, prefix) in LOOPBACK_INTERFACE %}
|
|
|
|
{% if prefix | ipv4 and name == 'Loopback0' %}
|
2019-12-01 00:28:46 -06:00
|
|
|
neighbor BGPMON update-source {{ prefix | ip }}
|
2019-10-15 20:43:52 -05:00
|
|
|
{% endif %}
|
|
|
|
{% endfor %}
|
2019-12-01 00:28:46 -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-15 20:43:52 -05:00
|
|
|
{% for neighbor_addr, bgp_session in BGP_MONITORS.items() %}
|
|
|
|
neighbor {{ neighbor_addr }} remote-as {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
|
2019-12-01 00:28:46 -06:00
|
|
|
neighbor {{ neighbor_addr }} peer-group BGPMON
|
2019-10-15 20:43:52 -05:00
|
|
|
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
|
|
|
|
neighbor {{ neighbor_addr }} activate
|
2019-12-01 00:28:46 -06:00
|
|
|
address-family ipv6
|
|
|
|
neighbor {{ neighbor_addr }} activate
|
|
|
|
exit-address-family
|
2019-10-15 20:43:52 -05:00
|
|
|
{% endfor %}
|
|
|
|
{% endif %}
|
|
|
|
{% endblock bgp_monitors %}
|
2017-01-19 22:56:26 -06:00
|
|
|
!
|
2017-08-08 18:23:58 -05:00
|
|
|
{% if DEVICE_METADATA['localhost'].has_key('bgp_asn') %}
|
2017-01-19 22:56:26 -06:00
|
|
|
maximum-paths 64
|
|
|
|
!
|
|
|
|
route-map ISOLATE permit 10
|
2017-08-08 18:23:58 -05:00
|
|
|
set as-path prepend {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
|
2017-03-27 16:22:04 -05:00
|
|
|
{% endif %}
|
2017-01-19 22:56:26 -06:00
|
|
|
!
|