diff options
author | Niklas Yann Wettengel <niyawe@niyawe.de> | 2021-07-28 01:12:10 +0200 |
---|---|---|
committer | Niklas Yann Wettengel <niyawe@niyawe.de> | 2021-07-28 01:12:10 +0200 |
commit | 9ec1670a262597356c24bff27d473eccceb45b61 (patch) | |
tree | 8d94c1ab62fef270ea45a103be179609272b3f82 /roles/install_wireguard_mesh | |
parent | f394fd81667a44e267e83d3c453101598a21c58c (diff) |
wg
Diffstat (limited to 'roles/install_wireguard_mesh')
-rw-r--r-- | roles/install_wireguard_mesh/templates/down.sh.j2 | 10 | ||||
-rw-r--r-- | roles/install_wireguard_mesh/templates/up.sh.j2 | 19 | ||||
-rw-r--r-- | roles/install_wireguard_mesh/templates/wg.conf.j2 | 2 |
3 files changed, 18 insertions, 13 deletions
diff --git a/roles/install_wireguard_mesh/templates/down.sh.j2 b/roles/install_wireguard_mesh/templates/down.sh.j2 index 85489b5..67d95bd 100644 --- a/roles/install_wireguard_mesh/templates/down.sh.j2 +++ b/roles/install_wireguard_mesh/templates/down.sh.j2 @@ -1,8 +1,4 @@ #!/bin/bash -{% for host in groups['fastd'] %} -{% for site in hostvars[host]['sites'] if site.name == item.name and site.wireguard_mesh_number != item.wireguard_mesh_number %} -batctl meshif bat{{ item.name }} if del mesh{{ item.name }}{{ site.wireguard_mesh_number }} -ip link set down dev mesh{{ item.name }}{{ site.wireguard_mesh_number }} -ip link del mesh{{ item.name }}{{ site.wireguard_mesh_number }} type ip6gretap -{% endfor %} -{% endfor %} +batctl meshif bat{{ item.name }} if del vx{{ item.name }} +ip link set down dev vx{{ item.name }} +ip link del vx{{ item.name }} type vxlan diff --git a/roles/install_wireguard_mesh/templates/up.sh.j2 b/roles/install_wireguard_mesh/templates/up.sh.j2 index 1f0c111..8164f2a 100644 --- a/roles/install_wireguard_mesh/templates/up.sh.j2 +++ b/roles/install_wireguard_mesh/templates/up.sh.j2 @@ -1,13 +1,15 @@ #!/bin/bash +ip -6 link add vx{{ item.name }} type vxlan id {{ item.vxlan_id }} dstport 8472 local {{ item.wireguard_mesh_address }} dev wg{{ item.name }} +ip link set mtu 1280 dev vx{{ item.name }} +ip link set address {{ item.wireguard_mesh_mac }} dev vx{{ item.name }} +ip link set up dev vx{{ item.name }} +batctl meshif bat{{ item.name }} if add vx{{ item.name }} {% for host in groups['fastd'] %} {% for site in hostvars[host]['sites'] if site.name == item.name and site.wireguard_mesh_number != item.wireguard_mesh_number %} -ip link add mesh{{ item.name }}{{ site.wireguard_mesh_number }} type ip6gretap remote {{ site.wireguard_mesh_address }} local {{ item.wireguard_mesh_address }} ttl 255 dev wg{{ item.name }} -ip link set mtu 1280 dev mesh{{ item.name }}{{ site.wireguard_mesh_number }} -ip link set address {{ item.wireguard_mesh_mac_prefix }}{{ site.wireguard_mesh_number }} dev mesh{{ item.name }}{{ site.wireguard_mesh_number }} -ip link set up dev mesh{{ item.name }}{{ site.wireguard_mesh_number }} -batctl meshif bat{{ item.name }} if add mesh{{ item.name }}{{ site.wireguard_mesh_number }} +bridge fdb append 00:00:00:00:00:00 dev vx{{ item.name }} dst {{ site.wireguard_mesh_address }} {% endfor %} {% endfor %} +{% if item.net4 is defined %} batctl meshif bat{{ item.name }} gw server 1000000/1000000 batctl meshif bat{{ item.name }} it 10000 batctl meshif bat{{ item.name }} mm 1 @@ -15,3 +17,10 @@ batctl meshif bat{{ item.name }} hop_penalty 64 netctl start bat{{ item.name }} systemctl restart dhcpd4.service systemctl restart named.service +{% else %} +batctl meshif bat{{ item.name }} gw client +batctl meshif bat{{ item.name }} it 10000 +batctl meshif bat{{ item.name }} mm 1 +batctl meshif bat{{ item.name }} hop_penalty 64 +netctl start bat{{ item.name }} +{% endif %} diff --git a/roles/install_wireguard_mesh/templates/wg.conf.j2 b/roles/install_wireguard_mesh/templates/wg.conf.j2 index 410d591..61bc469 100644 --- a/roles/install_wireguard_mesh/templates/wg.conf.j2 +++ b/roles/install_wireguard_mesh/templates/wg.conf.j2 @@ -1,7 +1,7 @@ [Interface] ListenPort = {{ item.wireguard_mesh_port }} PrivateKey = {{ item.wireguard_mesh_priv_key }} -Address = {{ item.wireguard_mesh_address }}/48 +Address = {{ item.wireguard_mesh_address }}/128 MTU = 1400 PostUp = /etc/wireguard/up{{ item.name }}.sh PreDown = /etc/wireguard/down{{ item.name }}.sh |