I plan to have a portable IOS cisco router which will have two DHCP assigned ISP addresses from unknown ranges. A tunnel is then built through the preferred ISP to another outer.
I would like to set the default gateway based on a precedence, but more importantly based on reachability. Often you may get a DHCP address, but have no connectivity. The idea is a non-technical person can drop this in, plug it in (port on the local router already setup), and get connectivity based on a local ISP if possible, or a cellular one if not.
When you know the address of the next hop at config time, this is simple - the IP ROUTE ... TRACK will work nicely, combined with a suitable metric for precedence.
When you get a DHCP address, you can do an IP ROUTE ... DHCP but it will not accept a TRACK statement with it.
In the interface IP DHCP command you can set a default-router distance, so you can supply a precedence, but not test for reachability. So if everything is working you can get the best one, but not if one ISP is flakey (or becomes so).
Below are relevant portions of a configuration that is close. If either DHCP assigned interface fails to get an address, everything works, and it uses the other. It also actively tests to pick the right tunnel source, so if connectivity is down for one, it will shift to the other as the tunnel source. However, if both are up, then there is a failure of connectivity through gi0/7:
- The metric originally assigned gives gi0/7's next hop the best metric (no connectivity), and that metric will not go away until the interface rebinds (and maybe not then if it gets a new address but still lacks connectivity).
- the track in the ikev2 client setup will fail to pick 7, but also fail to get 6 (no working gateway as the gi0/7 metric still has it as best)
If I could force a very short lease the interface would rebind (if the dhcp server was also unreachable), but the servers usually override that request and put in 1 day or something to long to be useful. And the dhcp server might be semi-local and unaffected by the outage.
In theory it could work to put a route with destination of the interface (instead of next hop) with a TRACK, but that depends on the ISP providing proxy arp (I think that's the term), which is far from sure. And if proxy-arp is available only on the GSM router it might force it to be always up.
The question is this: Is there a way in current router IOS CLI (I'm on 15.6 to test with) to get, and update, a correct default route based on reachability when there are two DHCP ISP interfaces?
I've also tried various ways to get policy based routing to force the interface for the SLA (still using the DHCP provided next hop) without any success, but so far without success.
Thanks for any ideas.
track 6 ip sla 6 reachability
track 7 ip sla 7 reachability
!
crypto ikev2 client flexvpn FLEXVPN_IKEV2_CLIENT
peer 1 9.9.9.2
source 1 GigabitEthernet0/7 track 7
source 2 GigabitEthernet0/6 track 6
client connect Tunnel31
!
interface Tunnel31
ip unnumbered Loopback192
ip nat inside
tunnel source dynamic
tunnel mode ipsec ipv4
tunnel destination dynamic
tunnel protection ipsec profile IKEV2_IPSEC_PROFILE
!
interface GigabitEthernet0/6
description Connection to GSM modem (secondary internet if primary down)
ip dhcp client default-router distance 200
ip dhcp client lease 0 0 5
ip address dhcp
ip nat outside
!
interface GigabitEthernet0/7
description Connection to local intenet (if any)
ip dhcp client default-router distance 100
ip dhcp client lease 0 0 5
ip address dhcp
ip nat outside
ip sla 6
icmp-echo 75.75.75.75 source-interface GigabitEthernet0/6
tag Cellular connection up test
frequency 10
ip sla schedule 6 life forever start-time now
ip sla 7
icmp-echo 75.75.75.75 source-interface GigabitEthernet0/7
tag Local ISP connection up test
frequency 10
PS. I left out most of the tunnel stuff as this is really about the routing, not the tunnel; the tunnel is working properly when it has the right default gateway.
ip route
command, which works with tracking. Cisco has a huge library of documents, and several that are directly on point. Search forcisco ios ip route track command
.ip dhcp client route track <number>
interface command. There are several documents that specifically discuss how to do what you want.