Add static routes

This commit is contained in:
Cory 2021-03-25 17:52:26 +10:30
parent ee51a45afe
commit 9c11fc7a83
1 changed files with 30 additions and 9 deletions

View File

@ -15,7 +15,7 @@ iface {{OOBNET_NIC}} inet static
{% endif %} {% endif %}
{% if autobgp_interfaces is defined %} {% if autobgp_interfaces is defined %}
{% for item in autobgp_interfaces %} {% for item in autobgp_interfaces %}
auto {{ item['name'] }} auto {{ item['name'] }}
allow-hotplug {{ item['name'] }} allow-hotplug {{ item['name'] }}
@ -24,24 +24,28 @@ iface {{ item['name'] }} inet static
{% if item['mtu'] is defined %} {% if item['mtu'] is defined %}
mtu {{ item['mtu'] }} mtu {{ item['mtu'] }}
{% endif %} {% 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 #Force speed to 10G
post-up sudo ethtool -s {{ item['name'] }} autoneg off post-up sudo ethtool -s {{ item['name'] }} autoneg off
post-up sudo ethtool -s {{ item['name'] }} speed 10000 post-up sudo ethtool -s {{ item['name'] }} speed 10000
{% endif %} {% endif %}
{% if item['force40G'] is defined and item['force40G']|lower == "true" %} {% if item['force40G'] is defined and item['force40G']|lower == "true" %}
#Force speed to 40G #Force speed to 40G
pre-up sudo ethtool -s {{ item['name'] }} autoneg off pre-up sudo ethtool -s {{ item['name'] }} autoneg off
pre-up sudo ethtool -s {{ item['name'] }} speed 40000 pre-up sudo ethtool -s {{ item['name'] }} speed 40000
{% endif %} {% endif %}
{% if item['auto40G'] is defined and item['auto40G']|lower == "true" %} {% if item['auto40G'] is defined and item['auto40G']|lower == "true" %}
#Auto speed #Auto speed
pre-up sudo /bin/ip link set down {{ item['name'] }} && sleep 1 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 pre-up sudo ethtool -s {{ item['name'] }} speed 40000 duplex full autoneg on
post-up sudo /bin/ip link set up {{ item['name'] }} post-up sudo /bin/ip link set up {{ item['name'] }}
{% endif %}
{% endif %} {% if item['routes'] is defined %}
{% endfor %} {% for route in item['routes'] %}
up ip route add {{ route['network'] } via {{ route['gateway'] } || true
{% endfor %}
{% endif %}
{% endfor %}
{% endif %} {% endif %}
{% if addressed_interfaces is defined and addressed_interfaces != [] %} {% 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'] }} autoneg off
post-up sudo ethtool -s {{ item['name'] }} speed 10000 post-up sudo ethtool -s {{ item['name'] }} speed 10000
{% endif %} {% endif %}
{% if item['routes'] is defined %}
{% for route in item['routes'] %}
up ip route add {{ route['network'] } via {{ route['gateway'] } || true
{% endfor %}
{% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
@ -89,6 +98,12 @@ auto {{ item['name'] }}
bond-mode active-backup bond-mode active-backup
bond-miimon 100 bond-miimon 100
bond-slaves none 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 %} {% endfor %}
{% endif %} {% endif %}
@ -110,6 +125,12 @@ iface {{ item['name'] }} inet static
mtu {{ item['mtu'] }} mtu {{ item['mtu'] }}
{% endif %} {% endif %}
vlan-raw-device {{ item['vlan-raw-device'] }} 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 %} {% endfor %}
{% endif %} {% endif %}