From 10585bc4d2f854858084c808ce56cd6d87934b49 Mon Sep 17 00:00:00 2001 From: Niklas Yann Wettengel Date: Sat, 24 Mar 2018 12:09:53 +0100 Subject: babel add preferred uplink --- host_vars/fastd | 1 + roles/install_babeld/templates/babeld.conf.j2 | 33 +++++++++------------------ 2 files changed, 12 insertions(+), 22 deletions(-) diff --git a/host_vars/fastd b/host_vars/fastd index 1029b1c..7ede1cd 100644 --- a/host_vars/fastd +++ b/host_vars/fastd @@ -30,3 +30,4 @@ wireguard_bb_pub_key: '< pub key >' wireguard_bb_port: < port > wireguard_bb_ipv4: '< wg bb ipv4 >' wireguard_bb_ipv6: '< wg bb ipv6 (fe80::) >' +preferred_uplink: '< (optional) wg_bb_name of uplink >' diff --git a/roles/install_babeld/templates/babeld.conf.j2 b/roles/install_babeld/templates/babeld.conf.j2 index c3f59f0..bf39bd5 100644 --- a/roles/install_babeld/templates/babeld.conf.j2 +++ b/roles/install_babeld/templates/babeld.conf.j2 @@ -23,36 +23,17 @@ interface bb{{ peer.name }} #debug 1 local-port 33123 #diversity true -#random-id true +random-id true -# Per-interface configuration. Note that each interface referenced here -# will be used by babeld. -#interface eth1 rxcost 10 -#interface tun0 faraway true -#interface wlan0 hello-interval 1 +default type tunnel rtt-min 1 rtt-max 25 max-rtt-penalty 128 +smoothing-half-life 30 -# Since 1.4.2, you can also specify defaults for interface parameters, which -# will be used for all interfaces except specified otherwise (see above). -#default rxcost 42 -#default hello-interval 5 - -# Since 1.5.0, you can use the RTT-based metric, most useful for a network -# with tunnels (overlay network). -#default enable-timestamps true -#interface tun0 max-rtt-penalty 150 -#interface tun0 rtt-max 100 -default type tunnel rtt-min 1 rtt-max 20 max-rtt-penalty 128 export-table 42 import-table 42 # Filtering rules. -# Only accept routes included in a specific prefix. -#in ip 192.168.42.0/24 allow -#in ip 2001:db8:cafe:cafe::/64 allow -#in deny - {% if 'mullvad_uplink' in group_names %} redistribute if mullvad metric 256 {% endif %} @@ -69,3 +50,11 @@ redistribute ip 2001:470:cd45:ff00::/56 allow redistribute ip 2a03:2260:1016::/48 allow redistribute ip fd62:44e1:da::/48 allow redistribute local deny + +{% if 'fastd' in group_names and preferred_uplink is defined %} +{% for peer in groups['uplink'] %} +{% if not hostvars[peer]['wireguard_bb_name'] == preferred_uplink %} +in if bb{{ hostvars[peer]['wireguard_bb_name'] }} metric 64 +{% endif %} +{% endfor %} +{% endif %} -- cgit v1.2.3-54-g00ecf