113 lines
4.1 KiB
Django/Jinja
113 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 (name, prefix) in LOOPBACK_INTERFACE %}
|
|
iface lo {{ 'inet' if prefix | ipv4 else 'inet6' }} static
|
|
address {{ prefix | ip }}
|
|
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
|
|
#
|
|
{% endfor %}
|
|
{% endblock loopback %}
|
|
{% block mgmt_interface %}
|
|
# The management network interface
|
|
auto eth0
|
|
{% if MGMT_INTERFACE %}
|
|
{% for (name, prefix) in MGMT_INTERFACE %}
|
|
iface eth0 {{ 'inet' if prefix | ipv4 else 'inet6' }} static
|
|
address {{ prefix | ip }}
|
|
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
|
|
########## 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 eth0 table default
|
|
up ip {{ '-4' if prefix | ipv4 else '-6' }} rule add from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table default
|
|
{% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %}
|
|
up ip rule add to {{ route }} table default
|
|
{% endfor %}
|
|
# management port down rules
|
|
down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete default via {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} dev eth0 table default
|
|
down ip {{ '-4' if prefix | ipv4 else '-6' }} rule delete from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table default
|
|
{% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %}
|
|
down ip rule delete to {{ route }} table default
|
|
{% endfor %}
|
|
{# TODO: COPP policy type rules #}
|
|
{% endfor %}
|
|
{% else %}
|
|
iface eth0 inet dhcp
|
|
{% endif %}
|
|
#
|
|
{% endblock mgmt_interface %}
|
|
{% block front_panel_interfaces %}
|
|
# The switch front panel interfaces
|
|
{% for (name, prefix) in INTERFACE %}
|
|
allow-hotplug {{ name }}
|
|
iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
|
|
mtu 9100
|
|
address {{ prefix | ip }}
|
|
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
|
|
#
|
|
{% endfor %}
|
|
{% if VLAN %}
|
|
# "|| true" is added to suppress the error when interface is already a member of VLAN
|
|
{% for vlan in VLAN.keys()|sort %}
|
|
{% for member in VLAN[vlan]['members'] %}
|
|
allow-hotplug {{ member }}
|
|
iface {{ member }} inet manual
|
|
pre-up ifconfig {{ member }} up mtu 9100
|
|
post-up brctl addif {{ vlan }} {{ member }} || true
|
|
post-down ifconfig {{ member }} down
|
|
#
|
|
{% endfor %}
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% if PORTCHANNEL %}
|
|
# "|| 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
|
|
{% for pc in PORTCHANNEL.keys()|sort %}
|
|
{% for member in PORTCHANNEL[pc]['members'] %}
|
|
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 %}
|
|
{% endif %}
|
|
{% endblock front_panel_interfaces %}
|
|
{% block vlan_interfaces %}
|
|
{% if VLAN_INTERFACE %}
|
|
# Vlan interfaces
|
|
{% for (name, prefix) in VLAN_INTERFACE.keys() | sort %}
|
|
auto {{ name }}
|
|
iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
|
|
bridge_ports none
|
|
hwaddress ether {{ hwaddr }}
|
|
address {{ prefix | ip }}
|
|
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
|
|
{% endfor %}
|
|
#
|
|
{% endif %}
|
|
{% endblock vlan_interfaces %}
|
|
{% block pc_interfaces %}
|
|
{% if PORTCHANNEL_INTERFACE %}
|
|
# Portchannel interfaces
|
|
{% for (name, prefix) in PORTCHANNEL_INTERFACE.keys() | sort %}
|
|
allow-hotplug {{ name }}
|
|
iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
|
|
mtu 9100
|
|
address {{ prefix | ip }}
|
|
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
|
|
#
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endblock pc_interfaces %}
|