Junos Automation (Scripting)
Highlighted
Junos Automation (Scripting)

configlet or script for static route change

‎10-08-2015 06:22 AM
I'm looking for an easy way during a dr scenario to change a static route. Currently all I have to go on is the commands to switch the static route: delete routing-options static route x.x.x.x/32 next-hop 1.2.3.4 delete routing-options static route a.b.c.d/32 next-hop 1.2.3.4 set routing-options static route d.c.b.a/32 next-hop 2.3.4.5 set routing-options static route z.y.x.w/32 next-hop 2.3.4.5 Could I issue the command through a configlet or does it have to be a script?
5 REPLIES 5
Highlighted
Junos Automation (Scripting)

Re: configlet or script for static route change

‎10-08-2015 06:39 AM

Yes a configlet will work.

something like 

 

routing-options {

    static {

        delete: route $oldRoute1;

        delete: route $oldRoute2;

        route $newRoute1 next-hop $newNextHop;

        route $newRoute2 next-hop $newNextHop;

    }

}

 

 

Assuming you filled in prefix/len values for $newRoute1, $newRoute2 and $newNextHop somewhere.

 

HTH

/doug

 

 

--
"There he goes. One of God's own prototypes. A high-powered mutant of some kind never even considered for mass production. Too weird to live, and too rare to die." --HST
Highlighted
Junos Automation (Scripting)

Re: configlet or script for static route change

‎10-08-2015 07:48 AM
Thanks Doug! I will play around with this.
Highlighted
Junos Automation (Scripting)

Re: configlet or script for static route change

‎10-20-2015 11:24 AM

Doug this configlet has been working beautifully.  I have another scenario involving a static route change in a routing instance that i'm trying to puzzle out.  Would it look something like this?

routing-instance DATA-VR {
    routing-options {
        delete:static route $oldRoute1;
        delete: static route $oldRoute2;
        route $newRoute1 next-hop $newNextHop;
        route $newRoute2 next-hop $newNextHop;
    }
}

 

Here is a snippet of the set commands;

set routing-instances DATA-VR routing-options static route 0.0.0.0/0 next-hop st0.0
set routing-instances DATA-VR routing-options static route 0.0.0.0/0 qualified-next-hop st0.1 preference 10
set routing-instances DATA-VR routing-options static route 0.0.0.0/0 preference 5

 

Highlighted
Junos Automation (Scripting)

Re: configlet or script for static route change

‎10-22-2015 09:26 AM

disregard, got this one figure out.  Here it is if anyone is interested:

routing-instances DATA-VR {
  routing-options {
    delete: static route $oldRoute;
     static route $oldRoute preference 5;
    static route $oldRoute next-hop $newNextHop0 qualified-next-hop $newNextHop1 preference 10;
  }
}

 

Just reverse hop variables to change route preference.

Highlighted
Junos Automation (Scripting)

Re: configlet or script for static route change

‎10-28-2015 03:33 AM

Hi,

 

Just another comment/tip to add about configlets.

 

Their default behaviour is a "load merge".

 

To delete an existing part of the stanza, as you are aware you can use the delete: statement, and then recreate the entry afterwards

 

system {
    login {
        delete: user space;
        user space {
            ...
        }
    }
}

This approach can be optimized further by instead using the replace: statement.

system {
    login {
        replace: user space {
            ...
        }
    }
}

HTH,

Regards,

Andy

 

Feedback