Suppose if you have two internet links if one gets down, how you will set up redundancy?

To check the connectivity we can use the IP SLA feature in Cisco IOS which will be constantly pinging the internet address as soon as the icmp check will fail it will change the priority of the route so the traffic will get out through the other link.

First we create our IP SLA cinfig. In this example we want to ping the default gateway so we can check if the internet connectivity is working

ip sla monitor 50
type echo protocol ipIcmpEcho
timeout 1000
frequency 3
threshold 2

ip sla monitor schedule 1 life forever start-time now 

Next we create a tracked object. This one points to the reachability of the IP SLA. Note that the number 50 relates to the ip sla monitor number.

track 50 rtr 1 reachability

Next we create an ACL. This permits ICMP to our default gateway. This is used in our route map to determine the reachability.

ip access-list 101 permit icmp any host

Next we create our route map. We match on the ACL we just created, then set the next hop as the preferred provider IP You must set the interface to null0.

route-map DEFAULT-ROUTE-POLICY permit 10
match ip address 101
set ip next-hop
set interface null 0 

Next we create a local routing policy to use our newly created route map.

ip local policy route-map DEFAULT-ROUTE-POLICY

Finally we put in our default routes. The first default route points to our preferred provide and we append the tracking to it. We then add the second default route with a higher weight (floating static route). What this does for us is the router will track the preffered default route. If for some reason we lose connectivity (from the IPS SLA) the route will be removed and any secondary default route will be added. In this example the new default route will point to

ip route track 10
ip route