Skip to content

Commit

Permalink
Fix network config
Browse files Browse the repository at this point in the history
  • Loading branch information
mraerino committed Sep 2, 2024
1 parent 61bcc37 commit ae2e1ad
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 19 deletions.
2 changes: 1 addition & 1 deletion group_vars/all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,4 @@ service_ipv4_address: >-
loopback_interface: "{{ interfaces | selectattr('name', 'equalto', 'lo') | first }}"
service_ipv6_address: "{{ gateway_ipv6_address }}"

domain_ipv6_subnet: "{{ gateway_ipv6_address | ipaddr('net') }}"
domain_ipv6_subnet: "{{ gateway_ipv6_address | ansible.utils.ipaddr('network/prefix') }}"
10 changes: 4 additions & 6 deletions roles/gateway/templates/client-bridge.network.j2
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@ Name=br0
[Link]
RequiredForOnline=no

[Address]
{%- for addr in client_bridge_interface.ip_addresses %}
Address={{ addr }}
{%- endfor %}

[Network]
{% for addr in client_bridge_interface.ip_addresses %}
Address={{ addr.address }}
{% endfor %}
DHCPServer=yes

[DHCPServer]
PoolOffset=10
PoolSize=64000
EmitDNS=yes
ServerAddress=10.12.255.254/16
DNS={{ service_ipv4_address | ipaddr('address') }}
DNS={{ service_ipv4_address | ansible.utils.ipaddr('address') }}
12 changes: 6 additions & 6 deletions roles/gateway/templates/dnsmasq.conf.j2
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
interface=br0
except-interface=lo
listen-address={{ gateway_ipv4_address | ipaddr('address') }}
listen-address={{ gateway_ipv6_address | ipaddr('address') }}
listen-address={{ gateway_ipv4_address | ansible.utils.ipaddr('address') }}
listen-address={{ gateway_ipv6_address | ansible.utils.ipaddr('address') }}
bind-interfaces

cache-size=10000

no-resolv
server=193.110.81.0@{{ service_ipv4_address | ipaddr('address') }}
server=185.253.5.0@{{ service_ipv4_address | ipaddr('address') }}
server=2a0f:fc80::@{{ service_ipv6_address | ipaddr('address') }}
server=2a0f:fc81::@{{ service_ipv6_address | ipaddr('address') }}
server=193.110.81.0@{{ service_ipv4_address | ansible.utils.ipaddr('address') }}
server=185.253.5.0@{{ service_ipv4_address | ansible.utils.ipaddr('address') }}
server=2a0f:fc80::@{{ service_ipv6_address | ansible.utils.ipaddr('address') }}
server=2a0f:fc81::@{{ service_ipv6_address | ansible.utils.ipaddr('address') }}
all-servers
neg-ttl=5

Expand Down
2 changes: 1 addition & 1 deletion roles/gateway/templates/firewall.nft.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ table inet nat {
chain postrouting {
type nat hook postrouting priority 0;

ip saddr $client_subnet oif eth0 snat to {{ service_ipv4_address | ipaddr('address') }}
ip saddr $client_subnet oif eth0 snat to {{ service_ipv4_address | ansible.utils.ipaddr('address') }}
}
}
22 changes: 19 additions & 3 deletions roles/service-ip/templates/bird.conf.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
router id {{ service_ipv4_address }};
router id {{ service_ipv4_address | ansible.utils.ipaddr('address') }};

log syslog all;

Expand Down Expand Up @@ -36,10 +36,26 @@ filter service {
reject;
}

define local_ipv4 = {{
wan_interface.ip_addresses |
map(attribute='address') |
ansible.utils.ipv4 |
first |
ansible.utils.ipaddr('address')
}};

define local_ipv6 = {{
wan_interface.ip_addresses |
map(attribute='address') |
ansible.utils.ipv6 |
first |
ansible.utils.ipaddr('address')
}};

{% for router in routers %}
protocol bgp service_v4_{{ router.name | lower }} from ffddorf {
description "Service Address Announcement IPv4 to {{ router.name }}";
local {{ service_ipv4_address }};
local local_ipv4;
neighbor {{ router.bgp_peer_ipv4_address }} as ffddorf_asn;

ipv4 {
Expand All @@ -49,7 +65,7 @@ protocol bgp service_v4_{{ router.name | lower }} from ffddorf {

protocol bgp service_v6_{{ router.name | lower }} from ffddorf {
description "Service Address Announcement IPv6 to {{ router.name }}";
local {{ ansible_default_ipv6.address }};
local local_ipv6;
neighbor {{ router.bgp_peer_ipv6_address }} as ffddorf_asn;

ipv6 {
Expand Down
4 changes: 2 additions & 2 deletions roles/service-ip/templates/service.network.j2
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
Name=lo

[Network]
{%- for addr in loopback_interface.ip_addresses %}
{% for addr in loopback_interface.ip_addresses %}
Address={{ addr }}
{%- endfor %}
{% endfor %}

0 comments on commit ae2e1ad

Please sign in to comment.