2017-01-19 22:56:26 -06:00
!
{% block banner %}
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
! generated by templates/quagga/bgpd.conf.j2 using minigraph_facts.py
! file: bgpd.conf
!
{% endblock banner %}
!
{% block system_init %}
hostname {{ inventory_hostname }}
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
!
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-03-31 15:25:39 -05:00
{# Advertise graceful restart capability for ToR #}
{% if minigraph_devices[inventory_hostname]['type'] == 'ToRRouter' %}
bgp graceful-restart
{% endif %}
2017-01-19 22:56:26 -06:00
{# TODO: use lo[0] for backward compatibility, will revisit the case with multiple lo interfaces #}
bgp router-id {{ minigraph_lo_interfaces[0]['addr'] }}
{# advertise loopback #}
{% for lo in minigraph_lo_interfaces %}
{% if lo['addr'] | ipv4 %}
network {{ lo['addr'] }}/32
{% elif lo['addr'] | ipv6 %}
address-family ipv6
network {{ lo['addr'] }}/128
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-02-13 16:17:22 -06:00
{% for vlan_interface in minigraph_vlan_interfaces %}
2017-08-16 23:12:32 -05:00
{% if vlan_interface['addr'] | ipv4 %}
2017-02-13 16:17:22 -06:00
network {{ vlan_interface['subnet'] }}
2017-08-16 23:12:32 -05:00
{% elif vlan_interface['addr'] | ipv6 %}
address-family ipv6
network {{ vlan_interface['subnet'] }}
exit-address-family
{% endif %}
2017-01-19 22:56:26 -06:00
{% endfor %}
{% endblock vlan_advertisement %}
{% block bgp_sessions %}
2017-08-08 18:23:58 -05:00
{% for neighbor_addr, bgp_session in BGP_NEIGHBOR.iteritems() %}
2017-01-19 22:56:26 -06:00
{% if bgp_session['asn'] != 0 %}
2017-08-08 18:23:58 -05:00
neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }}
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
{% if bgp_session.has_key('admin_status') and bgp_session['admin_status'] == 'down' or not bgp_session.has_key('admin_status') and DEVICE_METADATA['localhost'].has_key('default_bgp_status') and DEVICE_METADATA['localhost']['default_bgp_status'] == 'down' %}
neighbor {{ neighbor_addr }} shutdown
2017-06-12 13:05:22 -05:00
{% endif %}
2017-08-08 18:23:58 -05:00
{% if neighbor_addr | ipv4 %}
2017-02-07 02:28:30 -06:00
{% if minigraph_devices[inventory_hostname]['type'] == 'ToRRouter' %}
2017-08-08 18:23:58 -05:00
neighbor {{ neighbor_addr }} allowas-in 1
2017-02-07 02:28:30 -06:00
{% endif %}
2017-06-22 21:50:24 -05:00
{% endif %}
2017-08-08 18:23:58 -05:00
{% if neighbor_addr | ipv6 %}
2017-01-19 22:56:26 -06:00
address-family ipv6
2017-06-22 21:50:24 -05:00
{% if minigraph_devices[inventory_hostname]['type'] == 'ToRRouter' %}
2017-08-08 18:23:58 -05:00
neighbor {{ neighbor_addr }} allowas-in 1
2017-06-22 21:50:24 -05:00
{% endif %}
2017-08-08 18:23:58 -05:00
neighbor {{ neighbor_addr }} activate
2017-01-19 22:56:26 -06:00
maximum-paths 64
exit-address-family
{% endif %}
{% endif %}
{% endfor %}
{% endblock bgp_sessions %}
2017-06-21 20:52:50 -05:00
{% block bgp_peers_with_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
neighbor {{ bgp_peer['name'] }} remote-as {{deployment_id_asn_map[deployment_id] }}
neighbor {{ bgp_peer['name'] }} ebgp-multihop 255
neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound
neighbor {{ bgp_peer['name'] }} update-source Loopback0
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-06-21 20:52:50 -05:00
{% endfor %}
{% endblock bgp_peers_with_range %}
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
!