bird: add IPv6 support
This commit is contained in:
parent
618cad720a
commit
99ba67f074
1 changed files with 89 additions and 58 deletions
|
@ -1,4 +1,4 @@
|
|||
{{ ansible_managed | comment }}
|
||||
P{{ ansible_managed | comment }}
|
||||
|
||||
log syslog all;
|
||||
|
||||
|
@ -113,26 +113,42 @@ protocol ospf v3 ospf6 {
|
|||
}
|
||||
|
||||
{% for session in bird__bgp_sessions %}
|
||||
protocol bgp {{ session.name }} {
|
||||
{% for local_address in session.local.address %}
|
||||
{%
|
||||
set version =
|
||||
local_address
|
||||
| ansible.utils.ipaddr(query="version")
|
||||
%}
|
||||
{%
|
||||
set remote_address =
|
||||
session.remote.address
|
||||
| ansible.utils.ipaddr(version=version)
|
||||
| first
|
||||
%}
|
||||
protocol bgp bgp_{{ session.name }}{{ version }} {
|
||||
|
||||
local as {{ session.local.as }};
|
||||
source address {{ session.local.address }};
|
||||
neighbor {{ session.remote.address }} as {{ session.remote.as }};
|
||||
local {{ local_address }} as {{ session.local.as }};
|
||||
neighbor {{ remote_address }} as {{ session.remote.as }};
|
||||
|
||||
{{ "ipv4" if version == 4 else "ipv6" }} {
|
||||
|
||||
ipv4 {
|
||||
import filter {
|
||||
{% for pref in session.import.local_pref | default([]) %}
|
||||
{%
|
||||
set networks =
|
||||
pref.prefix
|
||||
| product("+" if pref.sub else "")
|
||||
| map("join")
|
||||
| join(", ")
|
||||
| default([])
|
||||
| ansible.utils.ipaddr(version=version)
|
||||
| map("suffix", pref.sub
|
||||
| default(False)
|
||||
| ternary("+", ""))
|
||||
%}
|
||||
{% set operator = '!~' if pref.negate | default(False) else '~' %}
|
||||
if (net {{ operator }} [ {{ networks }} ]) then {
|
||||
{% set operator = pref.negate | default(False) | ternary("!~", "~") %}
|
||||
{% if networks %}
|
||||
if net {{ operator }} [ {{ networks | join(", ") }} ] then {
|
||||
bgp_local_pref = {{ pref.pref | int }};
|
||||
}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if session.import.accept == "all" %}
|
||||
accept;
|
||||
|
@ -141,31 +157,40 @@ protocol bgp {{ session.name }} {
|
|||
{%
|
||||
set networks =
|
||||
accept.prefix
|
||||
| product("+" if accept.sub else "")
|
||||
| map("join")
|
||||
| join(", ")
|
||||
| default([])
|
||||
| ansible.utils.ipaddr(version=version)
|
||||
| map("suffix", accept.sub
|
||||
| default(False)
|
||||
| ternary("+", ""))
|
||||
%}
|
||||
{% set operator = '!~' if accept.negate | default(False) else '~' %}
|
||||
if (net {{ operator }} [ {{ networks }} ]) then accept;
|
||||
{% set operator = accept.negate | default(False) | ternary("!~", "~") %}
|
||||
{% if networks %}
|
||||
if net {{ operator }} [ {{ networks | join(",") }} ] then accept;
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
reject;
|
||||
{% endif %}
|
||||
};
|
||||
|
||||
export filter {
|
||||
{% for prepend in session.export.as_prepend | default([]) %}
|
||||
{%
|
||||
set networks =
|
||||
prepend.prefix
|
||||
| product("+" if prepend.sub else "")
|
||||
| map("join")
|
||||
| join(", ")
|
||||
| default([])
|
||||
| ansible.utils.ipaddr(version=version)
|
||||
| map("suffix", prepend.sub
|
||||
| default(False)
|
||||
| ternary("+", ""))
|
||||
%}
|
||||
{% set operator = '!~' if prepend.negate | default(False) else '~' %}
|
||||
if (net {{ operator }} [ {{ networks }} ]) then {
|
||||
{% set operator = prepend.negate | default(False) | ternary("!~", "~") %}
|
||||
{% if networks %}
|
||||
if net {{ operator }} [ {{ networks | join(", ") }} ] then {
|
||||
{% for _ in range(prepend.size) %}
|
||||
bgp_path.prepend({{ session.local.as }});
|
||||
{% endfor %}
|
||||
}
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
{% if session.export.accept == "all" %}
|
||||
accept;
|
||||
|
@ -174,20 +199,26 @@ protocol bgp {{ session.name }} {
|
|||
{%
|
||||
set networks =
|
||||
accept.prefix
|
||||
| product("+" if accept.sub else "")
|
||||
| map("join")
|
||||
| join(", ")
|
||||
| default([])
|
||||
| ansible.utils.ipaddr(version=version)
|
||||
| map("suffix", accept.sub
|
||||
| default(False)
|
||||
| ternary("+", ""))
|
||||
%}
|
||||
{% set operator = '!~' if accept.negate | default(False) else '~' %}
|
||||
if (net {{ operator }} [ {{ networks }} ]) then accept;
|
||||
{% set operator = accept.negate | default(False) | ternary("!~", "~") %}
|
||||
{% if networks %}
|
||||
if net {{ operator }} [ {{ networks | join(", ") }} ] then accept;
|
||||
{% endif %}
|
||||
{% endfor %}
|
||||
reject;
|
||||
{% endif %}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
{% endfor %}
|
||||
{% endfor %}
|
||||
|
||||
{% if bird__radv_interfaces %}
|
||||
|
|
Loading…
Reference in a new issue