better support p2p connections
This commit is contained in:
parent
d5858fe595
commit
3f3ed2fe15
2 changed files with 22 additions and 11 deletions
|
|
@ -4,6 +4,8 @@ wireguard:
|
||||||
privkey: ''
|
privkey: ''
|
||||||
ip: []
|
ip: []
|
||||||
ip6: []
|
ip6: []
|
||||||
|
route: []
|
||||||
|
route6: []
|
||||||
peers: {}
|
peers: {}
|
||||||
connections: {}
|
connections: {}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,29 @@
|
||||||
auto wg_{{ item.name }}
|
auto wg_{{ item.name }}
|
||||||
iface wg_{{ item.name }} inet static
|
iface wg_{{ item.name }} inet manual
|
||||||
{% for i in item.ip %}
|
post-down ip link del $IFACE
|
||||||
address {{ i }}
|
|
||||||
{% endfor %}
|
|
||||||
pre-up ip link add $IFACE type wireguard || true
|
pre-up ip link add $IFACE type wireguard || true
|
||||||
pre-up wg setconf $IFACE /etc/wireguard/$IFACE.conf
|
pre-up wg setconf $IFACE /etc/wireguard/$IFACE.conf
|
||||||
{% for i in item.route %}
|
{% if item.route|length == 1 and item.ip|length == 1%}
|
||||||
up ip route add {{ i }} dev $IFACE
|
pre-up ip a add {{ item.ip[0] }} peer {{ item.route[0] }} dev $IFACE
|
||||||
|
up ip route replace {{ item.route[0] }} src {{ item.ip[0].split('/')[0] }} dev $IFACE
|
||||||
|
{% else %}
|
||||||
|
{% for i in item.ip %}
|
||||||
|
pre-up ip a add {{ i }} dev $IFACE
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
post-down ip link del $IFACE
|
{% for i in item.route %}
|
||||||
|
up ip route replace {{ i }} dev $IFACE
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
iface wg_{{ item.name }} inet6 static
|
iface wg_{{ item.name }} inet6 manual
|
||||||
# static IP address
|
{% if item.route6|length == 1 and item.ip6|length == 1%}
|
||||||
|
pre-up ip -6 a add {{ item.ip6[0] }} peer {{ item.route6[0] }} dev $IFACE
|
||||||
|
up ip -6 route replace {{ item.route6[0] }} src {{ item.ip6[0].split('/')[0] }} dev $IFACE
|
||||||
|
{% else %}
|
||||||
{% for i in item.ip6 %}
|
{% for i in item.ip6 %}
|
||||||
address {{ i }}
|
pre-up ip -6 a add {{ i }} dev $IFACE
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% for i in item.route6 %}
|
{% for i in item.route6 %}
|
||||||
up ip -6 route add {{ i }} dev $IFACE
|
up ip -6 route replace {{ i }} dev $IFACE
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue