summaryrefslogtreecommitdiff
path: root/roles/configure_static_routes
diff options
context:
space:
mode:
authorNiklas Yann Wettengel <niyawe@niyawe.de>2021-07-28 01:12:10 +0200
committerNiklas Yann Wettengel <niyawe@niyawe.de>2021-07-28 01:12:10 +0200
commit9ec1670a262597356c24bff27d473eccceb45b61 (patch)
tree8d94c1ab62fef270ea45a103be179609272b3f82 /roles/configure_static_routes
parentf394fd81667a44e267e83d3c453101598a21c58c (diff)
wg
Diffstat (limited to 'roles/configure_static_routes')
-rw-r--r--roles/configure_static_routes/tasks/main.yml3
-rw-r--r--roles/configure_static_routes/tasks/wg_tasks.yml14
-rw-r--r--roles/configure_static_routes/templates/ffmyk-iproute-down.j210
-rw-r--r--roles/configure_static_routes/templates/ffmyk-iproute-up.j210
4 files changed, 20 insertions, 17 deletions
diff --git a/roles/configure_static_routes/tasks/main.yml b/roles/configure_static_routes/tasks/main.yml
index b1d90b7..c98825f 100644
--- a/roles/configure_static_routes/tasks/main.yml
+++ b/roles/configure_static_routes/tasks/main.yml
@@ -13,9 +13,6 @@
- include_tasks: fastd_tasks.yml
when: "'fastd' in group_names"
-- include_tasks: wg_tasks.yml
- when: "'wg' in group_names"
-
- name: copy ffmyk iproute systemd service
copy:
src: ffmyk-iproute.service
diff --git a/roles/configure_static_routes/tasks/wg_tasks.yml b/roles/configure_static_routes/tasks/wg_tasks.yml
deleted file mode 100644
index 4cd1583..0000000
--- a/roles/configure_static_routes/tasks/wg_tasks.yml
+++ /dev/null
@@ -1,14 +0,0 @@
----
-- name: copy site specific iproute up config script
- template:
- src: ffmyk-iproute-up.j2
- dest: /usr/local/bin/ffmyk-iproute{{ item.name }}-up.sh
- mode: 0744
- with_items: "{{ sites }}"
-
-- name: copy site specific iproute down config script
- template:
- src: ffmyk-iproute-down.j2
- dest: /usr/local/bin/ffmyk-iproute{{ item.name }}-down.sh
- mode: 0744
- with_items: "{{ sites }}"
diff --git a/roles/configure_static_routes/templates/ffmyk-iproute-down.j2 b/roles/configure_static_routes/templates/ffmyk-iproute-down.j2
index d551203..fe4334d 100644
--- a/roles/configure_static_routes/templates/ffmyk-iproute-down.j2
+++ b/roles/configure_static_routes/templates/ffmyk-iproute-down.j2
@@ -1,10 +1,20 @@
#!/bin/bash
+{% if item.net4 is defined %}
ip -4 route del {{item.net4 }} dev bat{{ item.name }} proto static table ffmyk
+{% endif %}
+{% if item.net6 is defined %}
ip -6 route del {{item.net6 }} dev bat{{ item.name }} proto static table ffmyk
+{% endif %}
+{% if item.site_net6 is defined %}
ip -6 route del {{item.site_net6 }} dev bat{{ item.name }} proto static table ffmyk
+{% endif %}
ip -4 rule del iif bat{{ item.name }} table ffmyk
ip -6 rule del iif bat{{ item.name }} table ffmyk
+{% if item.net4 is defined %}
ip -4 rule del from {{ item.net4 }} table ffmyk
+{% endif %}
+{% if item.net6 is defined %}
ip -6 rule del from {{ item.net6 }} table ffmyk
+{% endif %}
diff --git a/roles/configure_static_routes/templates/ffmyk-iproute-up.j2 b/roles/configure_static_routes/templates/ffmyk-iproute-up.j2
index 29afdb9..87e63a5 100644
--- a/roles/configure_static_routes/templates/ffmyk-iproute-up.j2
+++ b/roles/configure_static_routes/templates/ffmyk-iproute-up.j2
@@ -2,12 +2,22 @@
ip -4 rule add iif bat{{ item.name }} table ffmyk priority 10
ip -6 rule add iif bat{{ item.name }} table ffmyk priority 10
+{% if item.net4 is defined %}
ip -4 rule add from {{ item.net4 }} table ffmyk priority 10
+{% endif %}
+{% if item.net6 is defined %}
ip -6 rule add from {{ item.net6 }} table ffmyk priority 10
+{% endif %}
ip -4 rule add from all iif bat{{ item.name }} type unreachable priority 200
ip -6 rule add from all iif bat{{ item.name }} type unreachable priority 200
+{% if item.net4 is defined %}
ip -4 route replace {{item.net4 }} dev bat{{ item.name }} proto static table ffmyk
+{% endif %}
+{% if item.net6 is defined %}
ip -6 route replace {{item.net6 }} dev bat{{ item.name }} proto static table ffmyk
+{% endif %}
+{% if item.site_net6 is defined %}
ip -6 route replace {{item.site_net6 }} dev bat{{ item.name }} proto static table ffmyk
+{% endif %}