90a849ea85
* [Interfaces] Modify template to support multiple management interfaces * Modify minigraph to process interfaces in sorted order Signed-off-by: Ubuntu <gechen@gechen-sonic-dev.d0r25nej54guppclip4gpy5b5a.jx.internal.cloudapp.net> * Add UT minigraph Signed-off-by: Ubuntu <gechen@gechen-sonic-dev.d0r25nej54guppclip4gpy5b5a.jx.internal.cloudapp.net> * make case insensitve comparison Signed-off-by: George Chen <gechen@microsoft.com> * Use natural sort Signed-off-by: George Chen <gechen@microsoft.com> Co-authored-by: Ubuntu <gechen@gechen-sonic-dev.d0r25nej54guppclip4gpy5b5a.jx.internal.cloudapp.net>
118 lines
4.3 KiB
Django/Jinja
118 lines
4.3 KiB
Django/Jinja
#
|
|
{% block banner %}
|
|
# =============== Managed by SONiC Config Engine DO NOT EDIT! ===============
|
|
# generated from /usr/share/sonic/templates/interfaces.j2 using sonic-cfggen
|
|
# file: /etc/network/interfaces
|
|
#
|
|
{% endblock banner %}
|
|
{% block mgmt_vrf %}
|
|
{% if (MGMT_VRF_CONFIG) and (MGMT_VRF_CONFIG['vrf_global']['mgmtVrfEnabled'] == "true") %}
|
|
auto mgmt
|
|
iface mgmt
|
|
vrf-table 5000
|
|
# The loopback network interface for mgmt VRF that is required for applications like NTP
|
|
up ip link add lo-m type dummy
|
|
up ip link set dev lo-m master mgmt
|
|
up ip addr add 127.0.0.1/16 dev lo-m
|
|
up ip link set lo-m up
|
|
down ip link delete dev lo-m
|
|
{% endif %}
|
|
{% endblock mgmt_vrf %}
|
|
{% block loopback %}
|
|
# The loopback network interface
|
|
auto lo
|
|
iface lo inet loopback
|
|
address 127.0.0.1
|
|
netmask 255.255.0.0
|
|
scope host
|
|
post-up ip addr del 127.0.0.1/8 dev lo
|
|
{% endblock loopback %}
|
|
{% block mgmt_interface %}
|
|
|
|
# The management network interface
|
|
{% if MGMT_INTERFACE %}
|
|
{% for (name, prefix) in MGMT_INTERFACE|pfx_filter|unique(attribute=0) %}
|
|
auto {{ name }}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if (ZTP_DHCP_DISABLED is not defined) and (ZTP is defined) and (ZTP['mode'] is defined and ZTP['mode']['profile'] == 'active') %}
|
|
|
|
|
|
# ZTP out-of-band interface
|
|
{% if MGMT_INTERFACE %}
|
|
{% for (name, prefix) in MGMT_INTERFACE|pfx_filter|unique(attribute=0) %}
|
|
allow-hotplug {{ name }}
|
|
{% if ZTP['mode']['ipv4'] == 'true' %}
|
|
iface {{ name }} inet dhcp
|
|
{% endif %}
|
|
{% if ZTP['mode']['ipv6'] == 'true' %}
|
|
iface {{ name }} inet6 dhcp
|
|
up sysctl net.ipv6.conf.{{ name }}.accept_ra=1
|
|
down sysctl net.ipv6.conf.{{ name }}.accept_ra=0
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
{% if ZTP['mode']['inband'] == 'true' %}
|
|
{% for port in PORT %}
|
|
|
|
# ZTP in-band interface {{ port }}
|
|
auto {{ port }}
|
|
allow-hotplug {{ port }}
|
|
{% if PORT_DATA['PORT_TABLE:'+port] is defined and PORT_DATA['PORT_TABLE:'+port]['value']['oper_status'] == 'up' %}
|
|
{% if ZTP['mode']['ipv4'] == 'true' %}
|
|
iface {{ port }} inet dhcp
|
|
{% endif %}
|
|
{% if ZTP['mode']['ipv6'] == 'true' %}
|
|
iface {{ port }} inet6 dhcp
|
|
{% endif %}
|
|
{% endif %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
|
|
{% else %}
|
|
{% if MGMT_INTERFACE %}
|
|
{% for (name, prefix) in MGMT_INTERFACE|pfx_filter %}
|
|
iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
|
|
address {{ prefix | ip }}
|
|
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
|
|
network {{ prefix | network }}
|
|
broadcast {{ prefix | broadcast }}
|
|
{% set vrf_table = 'default' %}
|
|
{% if (MGMT_VRF_CONFIG) and (MGMT_VRF_CONFIG['vrf_global']['mgmtVrfEnabled'] == "true") %}
|
|
{% set vrf_table = '5000' %}
|
|
vrf mgmt
|
|
{% endif %}
|
|
########## management network policy routing rules
|
|
# management port up rules
|
|
up ip {{ '-4' if prefix | ipv4 else '-6' }} route add default via {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} dev {{ name }} table {{ vrf_table }} metric 201
|
|
up ip {{ '-4' if prefix | ipv4 else '-6' }} route add {{ prefix | network }}/{{ prefix | prefixlen }} dev {{ name }} table {{ vrf_table }}
|
|
up ip {{ '-4' if prefix | ipv4 else '-6' }} rule add pref 32765 from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table {{ vrf_table }}
|
|
{% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %}
|
|
up ip rule add pref 32764 to {{ route }} table {{ vrf_table }}
|
|
{% endfor %}
|
|
# management port down rules
|
|
pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete default via {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} dev {{ name }} table {{ vrf_table }}
|
|
pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete {{ prefix | network }}/{{ prefix | prefixlen }} dev {{ name }} table {{ vrf_table }}
|
|
pre-down ip {{ '-4' if prefix | ipv4 else '-6' }} rule delete pref 32765 from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table {{ vrf_table }}
|
|
{% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %}
|
|
pre-down ip rule delete pref 32764 to {{ route }} table {{ vrf_table }}
|
|
{% endfor %}
|
|
{# TODO: COPP policy type rules #}
|
|
{% endfor %}
|
|
{% else %}
|
|
iface eth0 inet dhcp
|
|
metric 202
|
|
{% if (MGMT_VRF_CONFIG) and (MGMT_VRF_CONFIG['vrf_global']['mgmtVrfEnabled'] == "true") %}
|
|
vrf mgmt
|
|
{% endif %}
|
|
iface eth0 inet6 dhcp
|
|
up sysctl net.ipv6.conf.eth0.accept_ra=1
|
|
down sysctl net.ipv6.conf.eth0.accept_ra=0
|
|
{% endif %}
|
|
{% endif %}
|
|
#
|
|
source /etc/network/interfaces.d/*
|
|
#
|
|
{% endblock mgmt_interface %}
|