sonic-buildimage/dockers/docker-fpm-quagga/bgpd.conf.j2
pavel-shirshov 6d1530f753
[docker-fpm-quagga]: Enable sending ipv6 prefixes over ipv4 BGPMON session. (#3828)
* Enable ipv6 prefixes over ipv4 BGPMON session

* Fix testcases

* Update bgpd_quagga.conf
2019-11-30 22:28:46 -08:00

135 lines
4.1 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 %}
!
{% 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
!
{% if BGP_MONITORS is defined and BGP_MONITORS|length > 0 %}
route-map FROM_BGPMON deny 10
!
route-map TO_BGPMON permit 10
!
{% endif %}
router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
bgp log-neighbor-changes
bgp bestpath as-path multipath-relax
no bgp default ipv4-unicast
bgp graceful-restart restart-time 240
bgp graceful-restart
{% 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 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 %}
{% if prefix | ipv4 %}
network {{ prefix }}
{% elif prefix | ipv6 %}
address-family ipv6
network {{ prefix }}
exit-address-family
{% endif %}
{% endfor %}
{% endblock vlan_advertisement %}
{% 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 %}
neighbor {{ bgp_peer['name'] }} remote-as {{ deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }}
{% 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 %}
{% 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
maximum-paths 64
exit-address-family
address-family ipv6
neighbor {{ bgp_peer['name'] }} activate
maximum-paths 64
exit-address-family
{% endfor %}
{% endif %}
{% endblock bgp_peers_with_range %}
{% block bgp_monitors %}
{% if BGP_MONITORS is defined and BGP_MONITORS|length > 0 %}
neighbor BGPMON peer-group
neighbor BGPMON activate
{% for (name, prefix) in LOOPBACK_INTERFACE %}
{% if prefix | ipv4 and name == 'Loopback0' %}
neighbor BGPMON update-source {{ prefix | ip }}
{% endif %}
{% endfor %}
neighbor BGPMON route-map FROM_BGPMON in
neighbor BGPMON route-map TO_BGPMON out
neighbor BGPMON send-community
neighbor BGPMON maximum-prefix 1
{% for neighbor_addr, bgp_session in BGP_MONITORS.items() %}
neighbor {{ neighbor_addr }} remote-as {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
neighbor {{ neighbor_addr }} peer-group BGPMON
neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }}
neighbor {{ neighbor_addr }} activate
address-family ipv6
neighbor {{ neighbor_addr }} activate
exit-address-family
{% endfor %}
{% endif %}
{% endblock bgp_monitors %}
!
{% if DEVICE_METADATA['localhost'].has_key('bgp_asn') %}
maximum-paths 64
!
route-map ISOLATE permit 10
set as-path prepend {{ DEVICE_METADATA['localhost']['bgp_asn'] }}
{% endif %}
!