Junos Automation (Scripting)
Reply
Contributor
alagarn
Posts: 20
Registered: ‎11-11-2009
0

Wan failover within two isp

Hi,

 

I have primary isp connected to ge-0/0/0.0 interface and secondary isp connected to fe-0/0/2.0.

 

I have careated the routes as follows:

 

routing-options {
    static {
        route 0.0.0.0/0 {
            next-hop 192.168.1.254;
            qualified-next-hop 192.168.2.254 {
                preference 30;

            }
        }
    }
}

 

Whenver the primary isp is down, i need to physically pull out the cable from ge/0/0/0.0 to make the failover to secondary isp.

 

Is there any way i can do it automatic if i can use to ping 4.2.2.2 as track ip similar to ssg devices ?

 

Thanks and regards,

AN

Recognized Expert
Mattia
Posts: 198
Registered: ‎03-17-2010
0

Re: Wan failover within two isp

[ Edited ]

Hi,

 

you can configure both the routes with qualified  next-hop, and use rpm probes to track the next-hop on the primary link. Then you can use an event script to increase the metric of the primary qualified next-hop when the rpm probe fails.

 

As a quick example, you may use the following configuration:

 

 

routing-options {
    static {
        route 0.0.0.0/0 {
            qualified-next-hop 192.168.1.254 {
                 metric 100;
               }
            }
            qualified-next-hop 192.168.2.254 {
                metric 150;
            }
        }
    }
}    
services {
    rpm {
        probe  {
            test primary-nh {
                target address 192.168.1.254;
                probe-count 10;
                probe-interval 1;
                test-interval 1;
            }
        }
    }
}

 

Then you will have to configure an event-policy to trigger an event-script which  will change the metric of the primary next-hop if the probe 'primary-nh' fails:

 

 

 

event-options {
    event-script {
        file change-nh-metric.slax;
    }
}             
    policy  {
        change-nh-metric {
            events ping_test_failed
            attributes-match {
                ping_test_failed.test-owner matches "^primary-nh$"
             }
            then {
                 event-script change-nh-metric.slax
             }
        }
    }

 

As for the event-script code, you can have a look at this topic ; the script should increase the qualified next-hop metric instead of deleting the route (I suggest you to read also the Day-One Junos automation books).

 

Please note that (obviously) you should also follow the same logic in order to restore the original configuration, i.e. to reduce the metric of the primary next-hop when it comes up again (so you will need another event policy and another event-script... but of course there are many different ways to obtain the same results).

 

Another approach that will fit your purpose is followed by this script, part of the Junos automation library.

 

So, I just tried to give you a quick hint. You may want to change something, e.g. using different event-policies, making the match statement more accurate...and so on..

 

I hope it helps,

 

Mattia

 

 

.................................................................................
JNCIP-ENT, JNCIP-SEC, JNCIS-SP
(If this post helped you, please mark it as an "Accepted Solution"; kudos are also appreciated!)


Copyright© 1999-2013 Juniper Networks, Inc. All rights reserved.