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
|
|
|
|
{% 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'] }}
|
2017-03-16 13:22:40 -05:00
|
|
|
########## management network policy routing rules
|
|
|
|
# management port up rules
|
2017-01-29 13:33:33 -06:00
|
|
|
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
|
2017-03-22 22:13:55 -05:00
|
|
|
{% for prefix in forced_mgmt_routes %}
|
2017-05-27 03:14:58 -05:00
|
|
|
up ip rule add to {{ prefix }} table default
|
2017-03-22 22:13:55 -05:00
|
|
|
{% endfor %}
|
2017-03-16 13:22:40 -05:00
|
|
|
# management port down rules
|
2017-01-29 13:33:33 -06:00
|
|
|
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
|
2017-03-22 22:13:55 -05:00
|
|
|
{% for prefix in forced_mgmt_routes %}
|
2017-05-27 03:14:58 -05:00
|
|
|
down ip rule delete to {{ prefix }} 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-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
|
|
|
|
{% for interface in minigraph_interfaces %}
|
2017-03-30 17:25:31 -05:00
|
|
|
allow-hotplug {{ interface['attachto'] }}
|
|
|
|
iface {{ interface['attachto'] }} {{ 'inet' if interface['addr'] | ipv4 else 'inet6' }} static
|
2017-05-28 02:36:34 -05:00
|
|
|
mtu 9216
|
2017-01-29 13:33:33 -06:00
|
|
|
address {{ interface['addr'] }}
|
|
|
|
netmask {{ interface['mask'] }}
|
|
|
|
#
|
|
|
|
{% endfor %}
|
2017-04-04 03:41:42 -05:00
|
|
|
{% if minigraph_vlans.keys() | length %}
|
|
|
|
# "|| true" is added to suppress the error when interface is already a member of VLAN
|
|
|
|
{% endif %}
|
2017-03-30 17:25:31 -05:00
|
|
|
{% for vlan in minigraph_vlans.keys()|sort %}
|
|
|
|
{% for member in minigraph_vlans[vlan]['members'] %}
|
|
|
|
allow-hotplug {{ member }}
|
|
|
|
iface {{ member }} inet manual
|
2017-05-28 02:36:34 -05:00
|
|
|
pre-up ifconfig {{ member }} up mtu 9216
|
2017-04-04 03:41:42 -05:00
|
|
|
post-up brctl addif {{ vlan }} {{ member }} || true
|
2017-03-30 17:25:31 -05:00
|
|
|
post-down ifconfig {{ member }} down
|
2017-03-16 13:22:40 -05:00
|
|
|
#
|
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
2017-04-04 03:41:42 -05:00
|
|
|
{% if minigraph_portchannels.keys() | length %}
|
|
|
|
# "|| 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-04-04 03:41:42 -05:00
|
|
|
{% endif %}
|
2017-03-30 17:25:31 -05:00
|
|
|
{% for pc in minigraph_portchannels.keys()|sort %}
|
|
|
|
{% for member in minigraph_portchannels[pc]['members'] %}
|
|
|
|
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 %}
|
|
|
|
{% endblock front_panel_interfaces %}
|
2017-04-04 03:41:42 -05:00
|
|
|
{% if minigraph_vlans.keys() | length %}
|
2017-03-16 13:22:40 -05:00
|
|
|
{% block vlan_interfaces %}
|
2017-03-30 17:25:31 -05:00
|
|
|
# Vlan interfaces
|
2017-03-16 13:22:40 -05:00
|
|
|
{% for vlan_interface in minigraph_vlan_interfaces %}
|
2017-03-30 17:25:31 -05:00
|
|
|
auto {{ vlan_interface['attachto'] }}
|
|
|
|
iface {{ vlan_interface['attachto'] }} {{ 'inet' if vlan_interface['addr'] | ipv4 else 'inet6' }} static
|
2017-03-20 23:39:09 -05:00
|
|
|
bridge_ports none
|
2017-03-16 13:22:40 -05:00
|
|
|
address {{ vlan_interface['addr'] }}
|
|
|
|
netmask {{ vlan_interface['mask'] }}
|
|
|
|
{% endfor %}
|
2017-03-30 17:25:31 -05:00
|
|
|
#
|
2017-03-16 13:22:40 -05:00
|
|
|
{% endblock vlan_interfaces %}
|
2017-04-04 03:41:42 -05:00
|
|
|
{% endif %}
|
|
|
|
{% if minigraph_portchannels.keys() | length %}
|
2017-03-16 13:22:40 -05:00
|
|
|
{% block pc_interfaces %}
|
2017-03-30 17:25:31 -05:00
|
|
|
# Portchannel interfaces
|
2017-03-16 13:22:40 -05:00
|
|
|
{% for pc_interface in minigraph_portchannel_interfaces %}
|
2017-03-30 17:25:31 -05:00
|
|
|
allow-hotplug {{ pc_interface['attachto'] }}
|
|
|
|
iface {{ pc_interface['attachto'] }} {{ 'inet' if pc_interface['addr'] | ipv4 else 'inet6' }} static
|
2017-05-28 02:36:34 -05:00
|
|
|
mtu 9216
|
2017-03-16 13:22:40 -05:00
|
|
|
address {{ pc_interface['addr'] }}
|
|
|
|
netmask {{ pc_interface['mask'] }}
|
|
|
|
#
|
|
|
|
{% endfor %}
|
|
|
|
{% endblock pc_interfaces %}
|
2017-04-04 03:41:42 -05:00
|
|
|
{% endif %}
|