Skip to content

Commit

Permalink
Merge pull request #67 from evrardjp/add_routes_options
Browse files Browse the repository at this point in the history
Add route management
  • Loading branch information
evrardjp authored Apr 10, 2021
2 parents e353b6a + 64d85e8 commit bd907a3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
6 changes: 6 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,9 @@ tinc_vpn_interface: tun0
tinc_vpn_cidr: "/24"
tinc_netname: tinc-vpn
tinc_control_plane_bind_ip: "{{ ansible_default_ipv4.address }}"

# tinc_vpn_routes can add routes to flow through the VPN (and remove them on tinc down)
tinc_vpn_routes: []
#tinc_vpn_routes:
# - dest:
# gateway:
6 changes: 5 additions & 1 deletion templates/tinc-down.j2
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
#!/bin/sh
ip link set dev {{ tinc_vpn_interface }} down
{% for route in tinc_vpn_routes %}
ip route del {{ route.dest }} via {{ route.gateway }}
{% endfor %}

ip link set dev {{ tinc_vpn_interface }} down
4 changes: 4 additions & 0 deletions templates/tinc-up.j2
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@ ip addr add {{ tinc_vpn_ip }}{{ tinc_vpn_cidr }} dev {{ tinc_vpn_interface }}
{% if tinc_up_scripts is defined %}
{{ tinc_up_scripts }}
{% endif %}

{% for route in tinc_vpn_routes %}
ip route add {{ route.dest }} via {{ route.gateway }}
{% endfor %}

0 comments on commit bd907a3

Please sign in to comment.