Backup link on Cisco: IP SLA and track

Automatic switch to the second ISP when the internet goes down.
Ready IOS commands with NAT on both links, verification and rollback.

Backup link on Cisco: IP SLA and track

The router pings addresses on the internet through the primary ISP and, if they stop answering, moves the default route to the second ISP by itself. Ready IOS and IOS XE commands with NAT on both links, verification and rollback.

Primary ISP

As in show ip interface brief: GigabitEthernet0/0, Dialer1.
If the address comes from DHCP, show dhcp lease shows the gateway.
A public address that answers ping. It will be reachable only through the primary ISP.
Optional. With two addresses the switch happens only when both stop answering.

Backup ISP

Switching speed

How long the primary link must stay silent before the router moves to the backup.
How long the primary link must work without failures before traffic returns to it.
Comma-separated: GigabitEthernet0/1, Vlan10.
Comma-separated, e.g. 192.168.1.0/24.
Configuration

   
Verification

   
Rollback

   

The commands are built in your browser; addresses are not sent anywhere.

How the switchover works

When a router has two ISPs, a plain default route does not notice that the internet behind the primary link is gone: the cable is in, the gateway answers, and nothing lies beyond. IP SLA pings addresses on the internet through the primary ISP every few seconds, a track object follows the result, and the default route via the primary gateway stays only while the track is Up. When the checks stop answering, the route leaves the table and traffic takes the backup — a floating route with a higher distance.

How to use it

  1. Enter the primary ISP's interface and gateway and one or two public addresses to check — Yandex and Google DNS by default.
  2. Enter the backup ISP's interface and gateway, or choose DHCP.
  3. Choose how fast to switch and to return. A short return delay causes flapping if the primary link is unstable.
  4. Turn on NAT on both links if users reach the internet through this router.
  5. Paste the configuration in configure terminal mode, test the switchover and save: copy running-config startup-config.

What is in the configuration

Each address to check gets its own ip sla sourced from the primary ISP's interface and a route to that address only via the primary gateway (with a fallback route to Null0, so the check never succeeds through the backup link and brings the primary back by mistake). With two addresses the track is a list boolean or: the switch happens only when both are silent. NAT uses two route-maps with match interface, and an EEM applet clears translations when the link changes. For MikroTik the dual ISP generator does the same, and port forwarding on Cisco is in NAT and port forwarding.

Further reading

Frequently asked questions

Why not check the ISP's gateway?

The gateway usually sits in the ISP's rack next door and answers ping even when the ISP has lost its own connection to the world. Check an address far out on the internet — a public DNS server, for example — and preferably two from different companies.

What if the primary ISP assigns the address by DHCP?

The generator needs the gateway address: show dhcp lease shows it, and it usually does not change. If it does change, Cisco offers ip dhcp client route track on the interface — it must be entered before ip address dhcp, and the DHCP route will then depend on the track.

Why do some sites not open after a switchover?

Old NAT translations keep sending replies through the failed link until they expire. That is what the EEM applet in the configuration is for: it runs clear ip nat translation * on every state change. Manually, the same command in enable mode does it.

Does it work on ASA?

No. ASA uses sla monitor and route … track with a different syntax, and NAT is set up with object network. The generator is for IOS and IOS XE routers: ISR, the 800, 1900, 2900 and 4000 series, Catalyst 8000 and others.

More tools

Cisco

Cisco VLAN lists
Compress, compare, add/remove for trunks
DHCP server on Cisco
Pools, exclusions, fixed addresses
Cisco port configuration
access, voice, trunk, Port Security for many ports
EtherChannel on Cisco
LACP, PAgP, trunk and commands for the other end
Cisco L2 security
DHCP snooping, DAI, IP Source Guard
Cisco SNMPv3
authPriv instead of communities, ACL, traps
Cisco config diff
Section by section, with draft commands
Cisco backups
A copy on every write memory and on a schedule