sonic-buildimage/files/image_config/interfaces/interfaces.j2

101 lines
3.7 KiB
Plaintext
Raw Normal View History

#
{% 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 route add {{ prefix }} via {{ minigraph_mgmt_interface['gwaddr'] }} dev eth0
{% 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 route delete {{ prefix }} via {{ minigraph_mgmt_interface['gwaddr'] }} dev eth0
{% 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['alias'] }}
allow-hotplug {{ interface['alias'] }}
iface {{ interface['alias'] }} {{ 'inet' if interface['addr'] | ipv4 else 'inet6' }} static
address {{ interface['addr'] }}
netmask {{ interface['mask'] }}
#
{% endfor %}
{% for vlan_interface in minigraph_vlan_interfaces|unique_name %}
{% for interface in vlan_interface['members'] %}
auto {{ interface }}
allow-hotplug {{ interface }}
iface {{ interface }} inet manual
pre-up ifconfig {{ interface }} up
post-up brctl addif {{ vlan_interface['name'] }} {{ interface }}
post-down ifconfig {{ interface }} down
#
{% endfor %}
{% endfor %}
# Add || true to suppress the error when docker-teamd starts after docker-swss
{% for pc_interface in minigraph_portchannel_interfaces|unique_name %}
{% for interface in pc_interface['members'] %}
{% if pc_interface['name'] not in pc_set %}
auto {{ interface }}
allow-hotplug {{ interface }}
iface {{ interface }} inet manual
pre-up teamdctl {{ pc_interface['name'] }} port add {{ interface }} || true
post-down ifconfig {{ interface }} down
#
{% endif %}
{% endfor %}
{% endfor %}
{% endblock front_panel_interfaces %}
{% block vlan_interfaces %}
{% for vlan_interface in minigraph_vlan_interfaces %}
auto {{ vlan_interface['name'] }}
iface {{ vlan_interface['name'] }} {{ 'inet' if vlan_interface['addr'] | ipv4 else 'inet6' }} static
bridge_ports none
address {{ vlan_interface['addr'] }}
netmask {{ vlan_interface['mask'] }}
#
{% endfor %}
{% endblock vlan_interfaces %}
{% block pc_interfaces %}
{% for pc_interface in minigraph_portchannel_interfaces %}
auto {{ pc_interface['name'] }}
allow-hotplug {{ pc_interface['name'] }}
iface {{ pc_interface['name'] }} {{ 'inet' if pc_interface['addr'] | ipv4 else 'inet6' }} static
address {{ pc_interface['addr'] }}
netmask {{ pc_interface['mask'] }}
#
{% endfor %}
{% endblock pc_interfaces %}