114 lines
4.1 KiB
Django/Jinja
114 lines
4.1 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 loopback %}
|
|
# The loopback network interface
|
|
auto lo
|
|
iface lo inet loopback
|
|
# Use command 'ip addr list dev lo' to check all addresses
|
|
{% for minigraph_lo_interface in minigraph_lo_interfaces %}
|
|
iface lo {{ 'inet' if minigraph_lo_interface['addr'] | ipv4 else 'inet6' }} static
|
|
address {{ minigraph_lo_interface['addr'] }}
|
|
netmask {{ minigraph_lo_interface['mask'] }}
|
|
#
|
|
{% endfor %}
|
|
{% endblock loopback %}
|
|
{% block mgmt_interface %}
|
|
# The management network interface
|
|
auto eth0
|
|
{% if minigraph_mgmt_interface['addr'] %}
|
|
iface eth0 inet static
|
|
address {{ minigraph_mgmt_interface['addr'] }}
|
|
netmask {{ minigraph_mgmt_interface['mask'] }}
|
|
########## management network policy routing rules
|
|
# management port up rules
|
|
up ip route add default via {{ minigraph_mgmt_interface['gwaddr'] }} dev eth0 table default
|
|
up ip rule add from {{ minigraph_mgmt_interface['addr'] }}/32 table default
|
|
{% for prefix in forced_mgmt_routes %}
|
|
up ip rule add to {{ prefix }} table default
|
|
{% endfor %}
|
|
# management port down rules
|
|
down ip route delete default via {{ minigraph_mgmt_interface['gwaddr'] }} dev eth0 table default
|
|
down ip rule delete from {{ minigraph_mgmt_interface['addr'] }}/32 table default
|
|
{% for prefix in forced_mgmt_routes %}
|
|
down ip rule delete to {{ prefix }} table default
|
|
{% endfor %}
|
|
{# TODO: COPP policy type rules #}
|
|
{% else %}
|
|
iface eth0 inet dhcp
|
|
{% endif %}
|
|
#
|
|
{% endblock mgmt_interface %}
|
|
{% block front_panel_interfaces %}
|
|
# The switch front panel interfaces
|
|
{% for interface in minigraph_interfaces %}
|
|
auto {{ interface['attachto'] }}
|
|
allow-hotplug {{ interface['attachto'] }}
|
|
iface {{ interface['attachto'] }} {{ 'inet' if interface['addr'] | ipv4 else 'inet6' }} static
|
|
mtu 9216
|
|
address {{ interface['addr'] }}
|
|
netmask {{ interface['mask'] }}
|
|
#
|
|
{% endfor %}
|
|
{% if minigraph_vlans.keys() | length %}
|
|
# "|| true" is added to suppress the error when interface is already a member of VLAN
|
|
{% endif %}
|
|
{% for vlan in minigraph_vlans.keys()|sort %}
|
|
{% for member in minigraph_vlans[vlan]['members'] %}
|
|
auto {{ member }}
|
|
allow-hotplug {{ member }}
|
|
iface {{ member }} inet manual
|
|
pre-up ifconfig {{ member }} up mtu 9216
|
|
post-up brctl addif {{ vlan }} {{ member }} || true
|
|
post-down ifconfig {{ member }} down
|
|
#
|
|
{% endfor %}
|
|
{% endfor %}
|
|
{% if minigraph_portchannels.keys() | length %}
|
|
# "|| true" is added to suppress the error when interface is already a member of LAG
|
|
# "ip link show | grep -q master" is added to ensure interface is enslaved
|
|
{% endif %}
|
|
{% for pc in minigraph_portchannels.keys()|sort %}
|
|
{% for member in minigraph_portchannels[pc]['members'] %}
|
|
auto {{ member }}
|
|
allow-hotplug {{ member }}
|
|
iface {{ member }} inet manual
|
|
pre-up teamdctl {{ pc }} port add {{ member }} || true
|
|
post-up ip link show {{ member }} | grep -q master && ifconfig {{ member }} up
|
|
post-down ifconfig {{ member }} down
|
|
#
|
|
{% endfor %}
|
|
{% endfor %}
|
|
{% endblock front_panel_interfaces %}
|
|
{% if minigraph_vlans.keys() | length %}
|
|
{% block vlan_interfaces %}
|
|
# Vlan interfaces
|
|
{% for vlan_interface in minigraph_vlan_interfaces %}
|
|
auto {{ vlan_interface['attachto'] }}
|
|
iface {{ vlan_interface['attachto'] }} {{ 'inet' if vlan_interface['addr'] | ipv4 else 'inet6' }} static
|
|
bridge_ports none
|
|
address {{ vlan_interface['addr'] }}
|
|
netmask {{ vlan_interface['mask'] }}
|
|
{% endfor %}
|
|
#
|
|
{% endblock vlan_interfaces %}
|
|
{% endif %}
|
|
{% if minigraph_portchannels.keys() | length %}
|
|
{% block pc_interfaces %}
|
|
# Portchannel interfaces
|
|
{% for pc_interface in minigraph_portchannel_interfaces %}
|
|
auto {{ pc_interface['attachto'] }}
|
|
allow-hotplug {{ pc_interface['attachto'] }}
|
|
iface {{ pc_interface['attachto'] }} {{ 'inet' if pc_interface['addr'] | ipv4 else 'inet6' }} static
|
|
mtu 9216
|
|
address {{ pc_interface['addr'] }}
|
|
netmask {{ pc_interface['mask'] }}
|
|
#
|
|
{% endfor %}
|
|
{% endblock pc_interfaces %}
|
|
{% endif %}
|