Technical Configuration Example Feature Automation Script— enable-primary-nexthop.slax, enable-alternate-nexthop.slax Automatically switch between the primary and alternate next hop based on the ping result returned from a remote host. Juniper Networks, Inc. 1194 North Mathilda Avenue Sunnyvale, CA 94089 USA 408-745-2000 www.juniper.net This product includes the Envoy SNMP Engine, developed by Epilogue Technology, an Integrated Systems Company. Copyright © 1986–1997, Epilogue Technology Corporation. All rights reserved. This program and its documentation were developed at private expense, and no part of them is in the public domain. This product includes memory allocation software developed by Mark Moraes, copyright © 1988, 1989, 1993, University of Toronto. This product includes FreeBSD software developed by the University of California, Berkeley, and its contributors. All of the documentation and software included in the 4.4BSD and 4.4BSD-Lite Releases is copyrighted by The Regents of the University of California. Copyright © 1979, 1980, 1983, 1986, 1988, 1989, 1991, 1992, 1993, 1994. The Regents of the University of California. All rights reserved. GateD software copyright © 1995, The Regents of the University. All rights reserved. Gate Daemon was originated and developed through release 3.0 by Cornell University and its collaborators. Gated is based on Kirton’s EGP, UC Berkeley’s routing daemon (routed), and DCN’s HELLO routing protocol. Development of Gated has been supported in part by the National Science Foundation. Portions of the GateD software copyright © 1988, Regents of the University of California. All rights reserved. Portions of the GateD software copyright © 1991, D. L. S. Associates. Juniper Networks, the Juniper Networks logo, NetScreen, and ScreenOS are registered trademarks of Juniper Networks, Inc. in the United States and other countries. JUNOS and JUNOSe are trademarks of Juniper Networks, Inc. All other trademarks, service marks, registered trademarks, or registered service marks are the property of their respective owners. Juniper Networks assumes no responsibility for any inaccuracies in this document. Juniper Networks reserves the right to change, modify, transfer, or otherwise revise this publication without notice. Products made or sold by Juniper Networks or components thereof might be covered by one or more of the following patents that are owned by or licensed to Juniper Networks: U.S. Patent Nos. 5,473,599, 5,905,725, 5,909,440, 6,192,051, 6,333,650, 6,359,479, 6,406,312, 6,429,706, 6,459,579, 6,493,347, 6,538,518, 6,538,899, 6,552,918, 6,567,902, 6,578,186, and 6,590,785. Copyright © 2009, Juniper Networks, Inc. All rights reserved. Printed in USA. ii : Table of Contents enable-primary-nexthop.slax, enable-alternate-nexthop.slax 1 Description................................................................................................................... 1 System Requirements .................................................................................................. 1 What it Does ................................................................................................................ 1 Set Up .......................................................................................................................... 1 How to Run .................................................................................................................. 3 iii enable-primary-nexthop.slax, enable-alternate-nexthop.slax Description Use real-time performance monitoring (RPM) to automatically use an alternate next-hop path to reach a remote host when it becomes unreachable, and re-establish the original path when the remote host becomes reachable again. System Requirements All platforms; JUNOS Software 9.3 and above. What it Does When a device has been pingable for the last few tries and then the ping test fails, a script is triggered that enables an alternate next hop for the device, temporarily disabling the interfaced associated with the primary next hop to the not-pingable device. When the ping test is again successful, the temporary next hop is disabled and the original route is re-established. Set Up 1. Copy the scripts enable-primary-nexthop.slax and enable-alternate-nexthop.slax to /var/db/scripts/event directory on the router. 2. Use a text editor to create two configuration sections: one for the real-time monitoring of the target address, and one for the event-related configuration to enable the next hop. Description 1 : enable-primary-nexthop.slax, enable-alternate-nexthop.slax a. For the RPM-related configuration, create and save the configuration shown below. In the area marked EDIT HERE, enter the valid IP address that can be pinged as the target address. This is the address for which you will have the system enable the primary or alternate next-hop routes as needed. services { rpm { probe icmp-ping-probe { test ping-probe-test { probe-type icmp-ping; target address 10.63.0.50; /* EDIT HERE */ test-interval 60; } } } } b. For the event-related configuration, create and save the configuration shown below. In the areas marked EDIT HERE, enter the name of the primary next-hop interface that will be enabled or disabled based on the ping test event. event-options { policy enable-primary-nexthop { events ping_test_completed; within 60 { trigger on 1; } within 120 events ping_test_failed; then { event-script enable-primary-nexthop.slax { arguments { next-hop-interface <interface-name>; /* EDIT HERE */ } output-filename foo; destination foo; } } } policy enable-alternate-nexthop{ events ping_test_failed; within 60 { trigger on 1; } within 120 events ping_test_completed; then { event-script enable-alternate-nexthop.slax { arguments { next-hop-interface <interface-name>; /* EDIT HERE */ } output-filename zoo; destination foo; } } } destinations { foo { archive-sites { /var/tmp; } } } } Set Up 2 : enable-primary-nexthop.slax, enable-alternate-nexthop.slax 3. Enable the scripts by adding the file statement and script filenames to the [edit event-options event-script] hierarchy level as shown below. Only superusers can enable event scripts in the configuration. [edit event-options event-script] user@host# set file enable-primary-nexthop.slax [edit event-options event-script] user@host# set file enable-alternate-nexthop.slax 4. Load the configuration information: a. Use the text editor to open the configuration file that was created previously, and copy its contents to the clipboard. Make sure you have copied both configuration sections, the RPM-related and the event-related. b. On the device, enter configuration mode: user@host% cli user@host> configure Entering configuration mode [edit] user@host# c. Use the load merge terminal command to load the configuration information and merge it with the current configuration: [edit] user@host# load merge terminal [Type ^D at a new line to end input] > Paste the contents of the clipboard here < d. At the prompt, past the contents of the clipboard. e. Press Enter. f. Press Ctrl+D. g. Commit the configuration: [edit] user@host# commit and-quit How to Run Once the scripts and configurations have been loaded, the script enable-alternate-nexthop.slax is launched upon event ping_test_failed—when the remote destination was pingable in the last few tries and is not pingable in the latest try. The next hop for the default route is added as dl2.0 and the interface passed to this script as an argument is disabled. How to Run 3 : enable-primary-nexthop.slax, enable-alternate-nexthop.slax The script enable-primary-nexthop.slax is launched upon event ping_test_completed—when the remote destination was not pingable in the last few tries and now is pingable in the latest try. The next hop for the default route is added, the interface is passed as an argument to it, and that interface gets enabled. How to Run 4
© Copyright 2024