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

@ -39,7 +39,11 @@ iface {{ item['name'] }} inet static
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 %}
{% if item['routes'] is defined %}
{% for route in item['routes'] %}
up ip route add {{ route['network'] } via {{ route['gateway'] } || true
{% endfor %}
{% endif %} {% endif %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
@ -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 %}