Fortinet black logo

Administration Guide

Equal cost multi-path (ECMP) routing

Copy Link
Copy Doc ID 962fb21b-9bd3-11eb-b70b-00505692583a:626296
Download PDF

Equal cost multi-path (ECMP) routing

ECMP is a forwarding mechanism that enables load-sharing of traffic to multiple paths of equal cost. An ECMP set is formed when the routing table contains multiple next-hop address for the same destination with equal cost. Routes of equal cost have the same preference and metric value. If there is an ECMP set for an active route, the switch uses a hash algorithm to choose one of the next-hop addresses. As input to the hash, the switch uses one or more of the following fields in the packet to be routed:

  • Source IP
  • Destination IP
  • Input port

Configuring ECMP

The switch automatically uses ECMP to choose between equal-cost routes.

This configuration value is system-wide. The source IP address is the default value.

NOTE:

  • There is a maximum of eight alternative paths (that is, ECMP paths).
  • When you configure a static route with a gateway, the gateway must be in the same IP subnet as the device. Also, the destination subnet cannot match any of device IP subnets in the switch.
  • When you configure a static route without a gateway, the destination subnet must be in the same IP subnet as the device.
Using the CLI:

config system settings

set ip-ecmp-mode [ source-ip-based ] [ dst-ip-based ] [ port-based ]

end

Example ECMP configuration

The following is an example CLI configuration for ECMP forwarding.

In this configuration, ports 2 and 6 are routed ports. Interfaces I-RED and I-GREEN are routed VLAN interfaces. The remaining ports in the switch are normal layer-2 ports.

  1. Configure native VLANs for ports 2, 6, and 9. Also configure the “internal” interface to allow native VLANs for ports 2, 6, and 9:

    config switch interface

    edit port2

    set native-vlan 10

    edit port6

    set native-vlan 20

    edit port9

    set native-vlan 30

    edit internal

    set allowed-vlans 10,20,30

    end

  2. Configure the system interfaces:

    config system interface

    edit "internal"

    set type physical

    next

    edit "i-blue"

    set ip 1.1.1.1 255.255.255.0

    set allowaccess ping https http ssh snmp telnet

    set vlanid 10

    set interface internal

    next

    edit "i-red"

    set ip 172.16.11.1 255.255.255.0

    set allowaccess ping ssh telnet

    set vlanid 20

    set interface internal

    next

    edit "i-green"

    set ip 172.168.13.1 255.255.255.0

    set allowaccess ping https http ssh snmp telnet

    set vlanid 30

    set interface internal

    next

    end

  3. Configure static routes. This code configures multiple next-hop gateways for the same network:

    config router static

    edit 1

    set device "mgmt"

    set gateway 10.105.0.1

    set status enable

    next

    edit 2

    set device “i-red"

    set dst 8.8.8.0/24

    set gateway 172.16.11.2

    set status enable

    next

    edit 3

    set device "i-green"

    set dst 8.8.8.0/24

    set gateway 172.168.13.2

    set status enable

    next

Viewing ECMP configuration

Display the status of the ECMP configuration using following command:

show system interface [ <system interface name> ]

Equal cost multi-path (ECMP) routing

ECMP is a forwarding mechanism that enables load-sharing of traffic to multiple paths of equal cost. An ECMP set is formed when the routing table contains multiple next-hop address for the same destination with equal cost. Routes of equal cost have the same preference and metric value. If there is an ECMP set for an active route, the switch uses a hash algorithm to choose one of the next-hop addresses. As input to the hash, the switch uses one or more of the following fields in the packet to be routed:

  • Source IP
  • Destination IP
  • Input port

Configuring ECMP

The switch automatically uses ECMP to choose between equal-cost routes.

This configuration value is system-wide. The source IP address is the default value.

NOTE:

  • There is a maximum of eight alternative paths (that is, ECMP paths).
  • When you configure a static route with a gateway, the gateway must be in the same IP subnet as the device. Also, the destination subnet cannot match any of device IP subnets in the switch.
  • When you configure a static route without a gateway, the destination subnet must be in the same IP subnet as the device.
Using the CLI:

config system settings

set ip-ecmp-mode [ source-ip-based ] [ dst-ip-based ] [ port-based ]

end

Example ECMP configuration

The following is an example CLI configuration for ECMP forwarding.

In this configuration, ports 2 and 6 are routed ports. Interfaces I-RED and I-GREEN are routed VLAN interfaces. The remaining ports in the switch are normal layer-2 ports.

  1. Configure native VLANs for ports 2, 6, and 9. Also configure the “internal” interface to allow native VLANs for ports 2, 6, and 9:

    config switch interface

    edit port2

    set native-vlan 10

    edit port6

    set native-vlan 20

    edit port9

    set native-vlan 30

    edit internal

    set allowed-vlans 10,20,30

    end

  2. Configure the system interfaces:

    config system interface

    edit "internal"

    set type physical

    next

    edit "i-blue"

    set ip 1.1.1.1 255.255.255.0

    set allowaccess ping https http ssh snmp telnet

    set vlanid 10

    set interface internal

    next

    edit "i-red"

    set ip 172.16.11.1 255.255.255.0

    set allowaccess ping ssh telnet

    set vlanid 20

    set interface internal

    next

    edit "i-green"

    set ip 172.168.13.1 255.255.255.0

    set allowaccess ping https http ssh snmp telnet

    set vlanid 30

    set interface internal

    next

    end

  3. Configure static routes. This code configures multiple next-hop gateways for the same network:

    config router static

    edit 1

    set device "mgmt"

    set gateway 10.105.0.1

    set status enable

    next

    edit 2

    set device “i-red"

    set dst 8.8.8.0/24

    set gateway 172.16.11.2

    set status enable

    next

    edit 3

    set device "i-green"

    set dst 8.8.8.0/24

    set gateway 172.168.13.2

    set status enable

    next

Viewing ECMP configuration

Display the status of the ECMP configuration using following command:

show system interface [ <system interface name> ]