From 9c11fc7a83f246430692c22627e092f9efeaec49 Mon Sep 17 00:00:00 2001 From: Cory Date: Thu, 25 Mar 2021 17:52:26 +1030 Subject: [PATCH] Add static routes --- templates/interfaces.j2 | 39 ++++++++++++++++++++++++++++++--------- 1 file changed, 30 insertions(+), 9 deletions(-) diff --git a/templates/interfaces.j2 b/templates/interfaces.j2 index c67fa00..2dd6432 100644 --- a/templates/interfaces.j2 +++ b/templates/interfaces.j2 @@ -15,7 +15,7 @@ iface {{OOBNET_NIC}} inet static {% endif %} {% if autobgp_interfaces is defined %} -{% for item in autobgp_interfaces %} +{% for item in autobgp_interfaces %} auto {{ item['name'] }} allow-hotplug {{ item['name'] }} @@ -24,24 +24,28 @@ iface {{ item['name'] }} inet static {% if item['mtu'] is defined %} mtu {{ item['mtu'] }} {% endif %} -{% if item['force10G'] is defined and item['force10G']|lower == "true" %} +{% if item['force10G'] is defined and item['force10G']|lower == "true" %} #Force speed to 10G post-up sudo ethtool -s {{ item['name'] }} autoneg off post-up sudo ethtool -s {{ item['name'] }} speed 10000 -{% endif %} -{% if item['force40G'] is defined and item['force40G']|lower == "true" %} +{% endif %} +{% if item['force40G'] is defined and item['force40G']|lower == "true" %} #Force speed to 40G pre-up sudo ethtool -s {{ item['name'] }} autoneg off pre-up sudo ethtool -s {{ item['name'] }} speed 40000 -{% endif %} -{% if item['auto40G'] is defined and item['auto40G']|lower == "true" %} +{% endif %} +{% if item['auto40G'] is defined and item['auto40G']|lower == "true" %} #Auto speed pre-up sudo /bin/ip link set down {{ item['name'] }} && sleep 1 pre-up sudo ethtool -s {{ item['name'] }} speed 40000 duplex full autoneg on post-up sudo /bin/ip link set up {{ item['name'] }} - -{% endif %} -{% endfor %} +{% endif %} +{% if item['routes'] is defined %} +{% for route in item['routes'] %} +up ip route add {{ route['network'] } via {{ route['gateway'] } || true +{% endfor %} +{% endif %} +{% endfor %} {% endif %} {% if addressed_interfaces is defined and addressed_interfaces != [] %} @@ -61,6 +65,11 @@ iface {{ item['name'] }} inet static post-up sudo ethtool -s {{ item['name'] }} autoneg off post-up sudo ethtool -s {{ item['name'] }} speed 10000 {% endif %} +{% if item['routes'] is defined %} +{% for route in item['routes'] %} +up ip route add {{ route['network'] } via {{ route['gateway'] } || true +{% endfor %} +{% endif %} {% endfor %} {% endif %} @@ -89,6 +98,12 @@ auto {{ item['name'] }} bond-mode active-backup bond-miimon 100 bond-slaves none +{% if item['routes'] is defined %} +{% for route in item['routes'] %} +up ip route add {{ route['network'] } via {{ route['gateway'] } || true +{% endfor %} +{% endif %} + {% endfor %} {% endif %} @@ -110,6 +125,12 @@ iface {{ item['name'] }} inet static mtu {{ item['mtu'] }} {% endif %} vlan-raw-device {{ item['vlan-raw-device'] }} +{% if item['routes'] is defined %} +{% for route in item['routes'] %} +up ip route add {{ route['network'] } via {{ route['gateway'] } || true +{% endfor %} +{% endif %} + {% endfor %} {% endif %}