sonic-buildimage/dockers/docker-fpm-frr/bgpd.conf.j2
2017-11-28 14:52:26 -08:00

102 lines
3.0 KiB
Django/Jinja

!
{% block banner %}
! =========== Managed by sonic-cfggen DO NOT edit manually! ====================
! generated by templates/quagga/bgpd.conf.j2 with config DB data
! file: bgpd.conf
!
{% endblock banner %}
!
{% block system_init %}
hostname {{ DEVICE_METADATA['localhost']['hostname'] }}
password zebra
log syslog informational
log facility local4
! enable password {# {{ en_passwd }} TODO: param needed #}
{% endblock system_init %}
!
{% block bgp_init %}
!
! bgp multiple-instance
!
router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
bgp log-neighbor-changes
bgp bestpath as-path multipath-relax
no bgp default ipv4-unicast
{# TODO: use lo[0] for backward compatibility, will revisit the case with multiple lo interfaces #}
{% for (name, prefix) in LOOPBACK_INTERFACE %}
{% if prefix | ipv4 and name == 'Loopback0' %}
bgp router-id {{ prefix | ip }}
{% endif %}
{% endfor %}
{# advertise loopback #}
{% for (name, prefix) in LOOPBACK_INTERFACE %}
{% if prefix | ipv4 %}
network {{ prefix | ip }}/32
{% elif prefix | ipv6 %}
address-family ipv6
network {{ prefix | ip }}/128
exit-address-family
{% endif %}
{% endfor %}
{% endblock bgp_init %}
{% block vlan_advertisement %}
{% for (name, prefix) in VLAN_INTERFACE %}
{% if prefix | ipv4 %}
network {{ prefix }}
{% elif prefix | ipv6 %}
address-family ipv6
network {{ prefix }}
exit-address-family
{% endif %}
{% endfor %}
{% endblock vlan_advertisement %}
{% block bgp_sessions %}
{% for neighbor_addr, bgp_session in BGP_NEIGHBOR.iteritems() %}
{% if bgp_session['asn'] | int != 0 %}
neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }}
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
neighbor {{ neighbor_addr }} timers {{ bgp_session['keepalive'] }} {{ bgp_session['holdtime'] }}
{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %}
neighbor {{ neighbor_addr }} allowas-in 1
{% endif %}
{% if neighbor_addr | ipv4 %}
address-family ipv4
neighbor {{ neighbor_addr }} activate
{% if bgp_session['rrclient'] | int != 0 %}
neighbor {{ neighbor_addr }} route-reflector-client
{% endif %}
{% if bgp_session['nhopself'] | int != 0 %}
neighbor {{ neighbor_addr }} next-hop-self
{% endif %}
maximum-paths 64
exit-address-family
{% endif %}
{% if neighbor_addr | ipv6 %}
address-family ipv6
neighbor {{ neighbor_addr }} activate
{% if bgp_session['rrclient'] | int != 0 %}
neighbor {{ neighbor_addr }} route-reflector-client
{% endif %}
{% if bgp_session['nhopself'] | int != 0 %}
neighbor {{ neighbor_addr }} next-hop-self
{% endif %}
{% if bgp_session['asn'] != DEVICE_METADATA['localhost']['bgp_asn'] %}
neighbor {{ neighbor_addr }} route-map set-next-hop-global-v6 in
{% endif %}
maximum-paths 64
exit-address-family
{% endif %}
{% endif %}
{% endfor %}
{% endblock bgp_sessions %}
!
maximum-paths 64
!
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
!