ibgp.conf 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #
  2. # FFHO iBGP configuration (Salt managed)
  3. #
  4. template bgp ibgp {
  5. import filter ibgp_in;
  6. export filter ibgp_out;
  7. local as AS_OWN;
  8. source address LO_IP;
  9. enable route refresh yes;
  10. graceful restart yes;
  11. }
  12. {#- Gather information for iBGP sessions #}
  13. {%- set roles = salt['pillar.get']('nodes:' ~ grains['id'] ~ ':roles', []) %}
  14. {%- set peers = [] %}
  15. {%- for node in salt['pillar.get']('nodes', [])|sort if node != grains['id'] %}
  16. {%- set peer_node_config = salt['pillar.get']('nodes:' ~ node) %}
  17. {%- set peer_roles = peer_node_config.get ('roles', []) %}
  18. {#- save peers node name, mangle . and - to _ to make bird happy #}
  19. {%- set peer_config = { 'node' : salt['ffho.re_replace']('[.-]', '_', node) } %}
  20. {%- if 'router' in peer_roles %}
  21. {#- Skip peer if neither we nor him are a RR #}
  22. {%- if 'routereflector' not in roles and 'routereflector' not in peer_roles %}
  23. {%- continue %}
  24. {%- endif %}
  25. {#- Is our peer a route reflector? #}
  26. {%- if 'routereflector' in peer_roles %}
  27. {%- do peer_config.update ({'rr' : True }) %}
  28. {%- endif %}
  29. {#- get peers Lo IP #}
  30. {%- do peer_config.update ({ 'ip' : salt['ffho_net.get_loopback_ip'] (peer_node_config, node, proto)}) %}
  31. {%- do peers.append (peer_config) %}
  32. {%- endif %}
  33. {%- endfor %}
  34. {#- configure iBGP sessions #}
  35. {% for peer_config in peers %}
  36. protocol bgp {{ peer_config.get ('node') }} from ibgp {
  37. neighbor {{ peer_config.get ('ip') }} as AS_OWN;
  38. {%- if 'routereflector' in roles and not 'rr' in peer_config %}
  39. rr client;
  40. {%- endif %}
  41. }
  42. {% endfor %}