2017-01-29 13:33:33 -06:00
|
|
|
#
|
|
|
|
{% block banner %}
|
2017-03-16 13:22:40 -05:00
|
|
|
# =============== Managed by SONiC Config Engine DO NOT EDIT! ===============
|
|
|
|
# generated from /usr/share/sonic/templates/interfaces.j2 using sonic-cfggen
|
|
|
|
# file: /etc/network/interfaces
|
2017-01-29 13:33:33 -06:00
|
|
|
#
|
2017-03-16 13:22:40 -05:00
|
|
|
{% endblock banner %}
|
2017-01-29 13:33:33 -06:00
|
|
|
{% block loopback %}
|
|
|
|
# The loopback network interface
|
|
|
|
auto lo
|
|
|
|
iface lo inet loopback
|
|
|
|
# Use command 'ip addr list dev lo' to check all addresses
|
2017-09-12 16:13:27 -05:00
|
|
|
{% 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 }}
|
2017-01-29 13:33:33 -06:00
|
|
|
#
|
|
|
|
{% endfor %}
|
|
|
|
{% endblock loopback %}
|
|
|
|
{% block mgmt_interface %}
|
|
|
|
# The management network interface
|
|
|
|
auto eth0
|
2017-09-12 16:13:27 -05:00
|
|
|
{% 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 }}
|
2017-03-16 13:22:40 -05:00
|
|
|
########## management network policy routing rules
|
|
|
|
# management port up rules
|
2017-09-21 01:55:50 -05:00
|
|
|
up ip {{ '-4' if prefix | ipv4 else '-6' }} route add default via {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} dev eth0 table default
|
2017-11-14 10:19:24 -06:00
|
|
|
up ip {{ '-4' if prefix | ipv4 else '-6' }} route add {{ prefix | network }}/{{ prefix | prefixlen }} dev eth0 table default
|
2017-09-21 01:55:50 -05:00
|
|
|
up ip {{ '-4' if prefix | ipv4 else '-6' }} rule add from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table default
|
2017-09-12 16:13:27 -05:00
|
|
|
{% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %}
|
|
|
|
up ip rule add to {{ route }} table default
|
2017-03-22 22:13:55 -05:00
|
|
|
{% endfor %}
|
2017-03-16 13:22:40 -05:00
|
|
|
# management port down rules
|
2017-09-21 01:55:50 -05:00
|
|
|
down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete default via {{ MGMT_INTERFACE[(name, prefix)]['gwaddr'] }} dev eth0 table default
|
2017-11-14 10:19:24 -06:00
|
|
|
down ip {{ '-4' if prefix | ipv4 else '-6' }} route delete {{ prefix | network }}/{{ prefix | prefixlen }} dev eth0 table default
|
2017-09-21 01:55:50 -05:00
|
|
|
down ip {{ '-4' if prefix | ipv4 else '-6' }} rule delete from {{ prefix | ip }}/{{ '32' if prefix | ipv4 else '128' }} table default
|
2017-09-12 16:13:27 -05:00
|
|
|
{% for route in MGMT_INTERFACE[(name, prefix)]['forced_mgmt_routes'] %}
|
|
|
|
down ip rule delete to {{ route }} table default
|
2017-03-22 22:13:55 -05:00
|
|
|
{% endfor %}
|
2017-03-30 17:25:31 -05:00
|
|
|
{# TODO: COPP policy type rules #}
|
2017-09-12 16:13:27 -05:00
|
|
|
{% endfor %}
|
2017-01-29 13:33:33 -06:00
|
|
|
{% else %}
|
|
|
|
iface eth0 inet dhcp
|
|
|
|
{% endif %}
|
|
|
|
#
|
2017-03-16 13:22:40 -05:00
|
|
|
{% endblock mgmt_interface %}
|
|
|
|
{% block front_panel_interfaces %}
|
2017-01-29 13:33:33 -06:00
|
|
|
# The switch front panel interfaces
|
2017-09-12 16:13:27 -05:00
|
|
|
{% for (name, prefix) in INTERFACE %}
|
|
|
|
allow-hotplug {{ name }}
|
|
|
|
iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
|
2017-11-10 15:54:31 -06:00
|
|
|
mtu {{ PORT[name]['mtu'] if PORT[name]['mtu'] else 9100 }}
|
2017-09-12 16:13:27 -05:00
|
|
|
address {{ prefix | ip }}
|
|
|
|
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
|
2017-01-29 13:33:33 -06:00
|
|
|
#
|
|
|
|
{% endfor %}
|
2017-09-12 16:13:27 -05:00
|
|
|
{% if PORTCHANNEL %}
|
2017-04-04 03:41:42 -05:00
|
|
|
# "|| true" is added to suppress the error when interface is already a member of LAG
|
2017-04-14 01:54:44 -05:00
|
|
|
# "ip link show | grep -q master" is added to ensure interface is enslaved
|
2017-09-12 16:13:27 -05:00
|
|
|
{% for pc in PORTCHANNEL.keys()|sort %}
|
|
|
|
{% for member in PORTCHANNEL[pc]['members'] %}
|
2017-03-30 17:25:31 -05:00
|
|
|
allow-hotplug {{ member }}
|
|
|
|
iface {{ member }} inet manual
|
|
|
|
pre-up teamdctl {{ pc }} port add {{ member }} || true
|
2017-04-14 01:54:44 -05:00
|
|
|
post-up ip link show {{ member }} | grep -q master && ifconfig {{ member }} up
|
2017-03-30 17:25:31 -05:00
|
|
|
post-down ifconfig {{ member }} down
|
2017-03-16 13:22:40 -05:00
|
|
|
#
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
2017-09-12 16:13:27 -05:00
|
|
|
{% endif %}
|
2017-03-16 13:22:40 -05:00
|
|
|
{% endblock front_panel_interfaces %}
|
|
|
|
{% block pc_interfaces %}
|
2017-09-12 16:13:27 -05:00
|
|
|
{% if PORTCHANNEL_INTERFACE %}
|
2017-03-30 17:25:31 -05:00
|
|
|
# Portchannel interfaces
|
2017-09-12 16:13:27 -05:00
|
|
|
{% for (name, prefix) in PORTCHANNEL_INTERFACE.keys() | sort %}
|
|
|
|
allow-hotplug {{ name }}
|
|
|
|
iface {{ name }} {{ 'inet' if prefix | ipv4 else 'inet6' }} static
|
2017-11-10 15:54:31 -06:00
|
|
|
mtu {{ PORTCHANNEL[name]['mtu'] if PORTCHANNEL[name]['mtu'] else 9100 }}
|
2017-09-12 16:13:27 -05:00
|
|
|
address {{ prefix | ip }}
|
|
|
|
netmask {{ prefix | netmask if prefix | ipv4 else prefix | prefixlen }}
|
2017-03-16 13:22:40 -05:00
|
|
|
#
|
|
|
|
{% endfor %}
|
2017-04-04 03:41:42 -05:00
|
|
|
{% endif %}
|
2017-09-12 16:13:27 -05:00
|
|
|
{% endblock pc_interfaces %}
|