|
| 1 | +! |
| 2 | +{% block banner %} |
| 3 | +! =========== Managed by sonic-cfggen DO NOT edit manually! ==================== |
| 4 | +! generated by templates/quagga/bgpd.conf.j2 with config DB data |
| 5 | +! file: bgpd.conf |
| 6 | +! |
| 7 | +{% endblock banner %} |
| 8 | +! |
| 9 | +{% block system_init %} |
| 10 | +hostname {{ DEVICE_METADATA['localhost']['hostname'] }} |
| 11 | +password zebra |
| 12 | +log syslog informational |
| 13 | +log facility local4 |
| 14 | +! enable password {# {{ en_passwd }} TODO: param needed #} |
| 15 | +{% endblock system_init %} |
| 16 | +! |
| 17 | +{% if DEVICE_METADATA['localhost'].has_key('bgp_asn') %} |
| 18 | +{% block bgp_init %} |
| 19 | +! |
| 20 | +! bgp multiple-instance |
| 21 | +! |
| 22 | +route-map FROM_BGP_SPEAKER_V4 permit 10 |
| 23 | +! |
| 24 | +route-map TO_BGP_SPEAKER_V4 deny 10 |
| 25 | +! |
| 26 | +router bgp {{ DEVICE_METADATA['localhost']['bgp_asn'] }} |
| 27 | + bgp log-neighbor-changes |
| 28 | + bgp bestpath as-path multipath-relax |
| 29 | + no bgp default ipv4-unicast |
| 30 | + bgp graceful-restart restart-time 240 |
| 31 | + bgp graceful-restart |
| 32 | +{% for (name, prefix) in LOOPBACK_INTERFACE %} |
| 33 | +{% if prefix | ipv4 and name == 'Loopback0' %} |
| 34 | + bgp router-id {{ prefix | ip }} |
| 35 | +{% endif %} |
| 36 | +{% endfor %} |
| 37 | +{# advertise loopback #} |
| 38 | +{% for (name, prefix) in LOOPBACK_INTERFACE %} |
| 39 | +{% if prefix | ipv4 and name == 'Loopback0' %} |
| 40 | + network {{ prefix | ip }}/32 |
| 41 | +{% elif prefix | ipv6 and name == 'Loopback0' %} |
| 42 | + address-family ipv6 |
| 43 | + network {{ prefix | ip }}/64 |
| 44 | + exit-address-family |
| 45 | +{% endif %} |
| 46 | +{% endfor %} |
| 47 | +{% endblock bgp_init %} |
| 48 | +{% endif %} |
| 49 | +{% block vlan_advertisement %} |
| 50 | +{% for (name, prefix) in VLAN_INTERFACE %} |
| 51 | +{% if prefix | ipv4 %} |
| 52 | + network {{ prefix }} |
| 53 | +{% elif prefix | ipv6 %} |
| 54 | + address-family ipv6 |
| 55 | + network {{ prefix }} |
| 56 | + exit-address-family |
| 57 | +{% endif %} |
| 58 | +{% endfor %} |
| 59 | +{% endblock vlan_advertisement %} |
| 60 | +{% block bgp_sessions %} |
| 61 | +{% for neighbor_addr, bgp_session in BGP_NEIGHBOR.iteritems() %} |
| 62 | +{% if bgp_session['asn'] | int != 0 %} |
| 63 | + neighbor {{ neighbor_addr }} remote-as {{ bgp_session['asn'] }} |
| 64 | + neighbor {{ neighbor_addr }} description {{ bgp_session['name'] }} |
| 65 | +{# set the bgp neighbor timers if they have not default values #} |
| 66 | +{% if (bgp_session['keepalive'] is defined and bgp_session['keepalive'] | int != 60) |
| 67 | + or (bgp_session['holdtime'] is defined and bgp_session['holdtime'] | int != 180) %} |
| 68 | + neighbor {{ neighbor_addr }} timers {{ bgp_session['keepalive'] }} {{ bgp_session['holdtime'] }} |
| 69 | +{% endif %} |
| 70 | +{% 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' %} |
| 71 | + neighbor {{ neighbor_addr }} shutdown |
| 72 | +{% endif %} |
| 73 | +{% if neighbor_addr | ipv4 %} |
| 74 | + address-family ipv4 |
| 75 | +{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %} |
| 76 | + neighbor {{ neighbor_addr }} allowas-in 1 |
| 77 | +{% endif %} |
| 78 | + neighbor {{ neighbor_addr }} activate |
| 79 | + neighbor {{ neighbor_addr }} soft-reconfiguration inbound |
| 80 | + maximum-paths 64 |
| 81 | + exit-address-family |
| 82 | +{% endif %} |
| 83 | +{% if neighbor_addr | ipv6 %} |
| 84 | + address-family ipv6 |
| 85 | +{% if DEVICE_METADATA['localhost']['type'] == 'ToRRouter' %} |
| 86 | + neighbor {{ neighbor_addr }} allowas-in 1 |
| 87 | +{% endif %} |
| 88 | + neighbor {{ neighbor_addr }} activate |
| 89 | + neighbor {{ neighbor_addr }} soft-reconfiguration inbound |
| 90 | + maximum-paths 64 |
| 91 | + exit-address-family |
| 92 | +{% endif %} |
| 93 | +{% endif %} |
| 94 | +{% endfor %} |
| 95 | +{% endblock bgp_sessions %} |
| 96 | +{% block bgp_peers_with_range %} |
| 97 | +{% if BGP_PEER_RANGE %} |
| 98 | +{% for bgp_peer in BGP_PEER_RANGE.values() %} |
| 99 | + neighbor {{ bgp_peer['name'] }} peer-group |
| 100 | + neighbor {{ bgp_peer['name'] }} passive |
| 101 | +{% if bgp_peer['peer_asn'] is defined %} |
| 102 | + neighbor {{ bgp_peer['name'] }} remote-as {{ bgp_peer['peer_asn'] }} |
| 103 | +{% else %} |
| 104 | + neighbor {{ bgp_peer['name'] }} remote-as {{ deployment_id_asn_map[DEVICE_METADATA['localhost']['deployment_id']] }} |
| 105 | +{% endif %} |
| 106 | + neighbor {{ bgp_peer['name'] }} ebgp-multihop 255 |
| 107 | + neighbor {{ bgp_peer['name'] }} soft-reconfiguration inbound |
| 108 | +{% if bgp_peer['src_address'] is defined %} |
| 109 | + neighbor {{ bgp_peer['name'] }} update-source {{ bgp_peer['src_address'] | ip }} |
| 110 | +{% else %} |
| 111 | +{% for (name, prefix) in LOOPBACK_INTERFACE %} |
| 112 | +{% if name == 'Loopback1' %} |
| 113 | + neighbor {{ bgp_peer['name'] }} update-source {{ prefix | ip }} |
| 114 | +{% endif %} |
| 115 | +{% endfor %} |
| 116 | +{% endif %} |
| 117 | + neighbor {{ bgp_peer['name'] }} route-map FROM_BGP_SPEAKER_V4 in |
| 118 | + neighbor {{ bgp_peer['name'] }} route-map TO_BGP_SPEAKER_V4 out |
| 119 | +{% for ip_range in bgp_peer['ip_range'] %} |
| 120 | + bgp listen range {{ip_range}} peer-group {{ bgp_peer['name'] }} |
| 121 | +{% endfor %} |
| 122 | + address-family ipv4 |
| 123 | + neighbor {{ bgp_peer['name'] }} activate |
| 124 | + maximum-paths 64 |
| 125 | + exit-address-family |
| 126 | + address-family ipv6 |
| 127 | + neighbor {{ bgp_peer['name'] }} activate |
| 128 | + maximum-paths 64 |
| 129 | + exit-address-family |
| 130 | +{% endfor %} |
| 131 | +{% endif %} |
| 132 | +{% endblock bgp_peers_with_range %} |
| 133 | +! |
| 134 | +{% if DEVICE_METADATA['localhost'].has_key('bgp_asn') %} |
| 135 | +maximum-paths 64 |
| 136 | +! |
| 137 | +route-map ISOLATE permit 10 |
| 138 | +set as-path prepend {{ DEVICE_METADATA['localhost']['bgp_asn'] }} |
| 139 | +{% endif %} |
| 140 | +! |
0 commit comments