ansible-role-tinc/templates/tinc-up.j2

24 lines
1,011 B
Plaintext
Raw Normal View History

2019-11-03 15:27:52 +00:00
#!/bin/sh
{% if ansible_hostname == 'hetzner-01' %}
/sbin/ifconfig $INTERFACE {{ tinc_client_ip | ipaddr('address') }} netmask 255.255.255.0
/usr/sbin/ip rule add to {{ tinc_remote_nets[0].net_cidr }} table 5
/usr/sbin/ip route add {{ tinc_remote_nets[0].net_cidr }} via {{ tinc_remote_nets[0].gateway }} dev {{ tinc_vpn_id }} table 5
{% elif ansible_hostname == 'RaspiBeyerstedt' %}
/sbin/ifconfig $INTERFACE {{ tinc_client_ip | ipaddr('address') }} netmask 255.255.255.0
/bin/bash -c "echo 1 > /proc/sys/net/ipv4/ip_forward"
/bin/ip route add {{ tinc_remote_nets[0].net_cidr }} dev eth0
iptables -t nat -A POSTROUTING -o eth0 -s {{ tinc_vpn_net }} -j MASQUERADE
2020-07-18 21:06:38 +00:00
{% elif ansible_os_family == 'Darwin' %}
2019-11-03 15:27:52 +00:00
# only a single endpoint works, because tun interface is p2p
/sbin/ifconfig $INTERFACE inet {{ tinc_client_ip | ipaddr('address') }} {{ tinc_remote_nets[0].gateway }} up netmask 255.255.255.0
2019-11-03 15:27:52 +00:00
/sbin/route -n add -net {{ tinc_remote_nets[0].net_cidr }} {{ tinc_remote_nets[0].gateway }}
{% endif %}