803c263331
* Added management subnet route to route table-default in kernel. * Added sample output to interface file
88 lines
3.6 KiB
Django/Jinja
88 lines
3.6 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' }} route add {{ prefix | network }}/{{ prefix | prefixlen }} 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' }} route delete {{ prefix | network }}/{{ prefix | prefixlen }} 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 {{ PORT[name]['mtu'] if PORT[name]['mtu'] else 9100 }}
|
|
address {{ prefix | ip }}
|
|
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
|
|
#
|
|
{% endfor %}
|
|
{% 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 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 {{ PORTCHANNEL[name]['mtu'] if PORTCHANNEL[name]['mtu'] else 9100 }}
|
|
address {{ prefix | ip }}
|
|
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
|
|
#
|
|
{% endfor %}
|
|
{% endif %}
|
|
{% endblock pc_interfaces %}
|