# Dual WAN Failover Script Ping Command

**URL:** <https://forum.mikrotik.com/t/dual-wan-failover-script-ping-command/150516>\
**Category:** Beginner Basics\
**Created:** [July 18, 2021, 8:43pm UTC](https://forum.mikrotik.com/t/dual-wan-failover-script-ping-command/150516 "2021-07-18T20:43:50Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![rextended](https://forum.mikrotik.com/user_avatar/forum.mikrotik.com/rextended/32/67729_2.png) [@rextended](https://forum.mikrotik.com/u/rextended)\
**Post date:** [July 19, 2021, 1:34pm UTC](https://forum.mikrotik.com/t/dual-wan-failover-script-ping-command/150516/8 "2021-07-19T13:34:58Z")

</div>

search tag # rextended dual dhcp wan failover

This works only on 6.46.8+ and not in v7+

REMEMBER TO REMOVE “ADD DEFAULT ROUTE” ON DHCP CLIENTs  
and add those scripts on “script” section of DHCP client

script for DHCP Client 1 = MAIN

```plaintext
/ip route
set [find where comment~"ISP1"] gateway=$"gateway-address"

```

script for DHCP Client 2 = FAILOVER

```plaintext
/ip route
set [find where comment~"ISP2"] gateway=$"gateway-address"

```

This must be pasted on new terminal, better if before do that remove all non dynamic routes from routes  
DO NOT CHANGE COMMENTS!!! (until keeped ISP1 and ISP2 inside…)  
First time change 2.3.4.5 and 6.7.8.9 with actuals or, after paste on new terminal, disable and re-enable dhcp clients

```plaintext
/ip dns
set servers=1.1.1.1,8.8.8.8

/ip route
add comment="A - 1.1.1.1 must be reachable only from ISP1" distance=1 dst-address=1.1.1.1/32 gateway=2.3.4.5 scope=10
add comment="B - Recursive Routing, check ping 1.1.1.1 instead of ISP IP" distance=10 gateway=1.1.1.1 check-gateway=ping
add comment="C - ISP2 is alternative Gateway" distance=20 gateway=6.7.8.9

```

---

_[View the full topic](https://forum.mikrotik.com/t/dual-wan-failover-script-ping-command/150516)._
