SlideShare ist ein Scribd-Unternehmen logo
1 von 25
Downloaden Sie, um offline zu lesen
Scripting on Routersp g
Richard A Steenbergen <ras@nlayer.net> nLayer Communications, Inc.
By Richard Steenbergen, nLayer Communications, Inc. 1
Why Script on Routers?Why Script on Routers?
• What do we mean by “Scripting on Routers?”What do we mean by Scripting on Routers?
• Provide network operators with the ability to write custom
software which runs on routers to simplify configurationssoftware which runs on routers, to simplify configurations,
react to network events, and/or automate complex tasks.
• Why do we need scripting on routers?Why do we need scripting on routers?
• Router configurations are complex and often repetitive.
• Scripts can simplify existing repetitive configurations• Scripts can simplify existing repetitive configurations.
• Can also enable new features which might otherwise be impossible.
• Humans frequently make mistakes.Humans frequently make mistakes.
• Scripts can provide complex error checking to prevent accidents.
• Humans cost a lot of money to maintain and administer.y
• Scripts can reduce the manpower necessary to run a network.
By Richard Steenbergen, nLayer Communications, Inc. 2
What About Offline Automation?What About Offline Automation?
• We have existing router management tools today• We have existing router management tools today
• Expect/Perl/etc scripting over CLI Telnet/SSH
IETF t d di d N tC f (XML b d) P t l• IETF standardized NetConf (XML based) Protocol
• Some networks are entirely managed offline
With h l i i t t l i t• With no humans logging into routers, only scripts.
• But most networks are still run the old fashioned way
• Writing offline tools requires dedicated/experienced staff.
• It is difficult to pre-plan for every possible configuration.
• Most networks use a mix of tools + standard CLI configs.
• Scripting on the router provides the advantages of router
management software, while still allowing manual one-offs.
By Richard Steenbergen, nLayer Communications, Inc. 3
Some Router Scripting ExamplesSome Router Scripting Examples
E l t ti f 3 t ki t k• Example automation of 3 common networking tasks
• Automated BGP Policy Generation
• Per-ASN BGP communities and their associated policies.
• Other Per-ASN policies such as AS-PATH leak filters.
• All automated and built automatically for every BGP peer• All automated and built automatically for every BGP peer.
• Automated BGP Prefix-Limit Management
• Auto-tuning prefix-limits which adjust to follow changes in BGPAuto tuning prefix limits which adjust to follow changes in BGP.
• Without requiring human intervention to maintain.
• Support case data gathering scriptspp g g p
• Automatically compiles and uploads logs/info when opening cases.
By Richard Steenbergen, nLayer Communications, Inc. 4
Automated BGP Policy Generationy
By Richard Steenbergen, nLayer Communications, Inc. 5
Automated BGP Policy GenerationAutomated BGP Policy Generation
St t b d fi i “BGP l ti ”• Start by defining a “BGP location” macro:
• Essentially a piece of custom router configuration which
t i t i t b d b th i t l toperators can maintain, to be used by the script later on.
• Here we define the values for continent, region, and city
codes to be used for BGP Communities for the routercodes to be used for BGP Communities for the router.
• system {
location {location {
apply-macro bgp {
city 16;y ;
continent 1;
region 2;
…
By Richard Steenbergen, nLayer Communications, Inc. 6
Automated BGP Policy GenerationAutomated BGP Policy Generation
• Configure a BGP Peer like normal
protocols {
b {bgp {
group PNI {
import PRIVPEER-IN;
export PRIVPEER-OUT;
neighbor 1.2.3.4 {
description “Example BGP Peer”;p p ;
peer-as 1234;
}
}}
}
By Richard Steenbergen, nLayer Communications, Inc. 7
Automated BGP Policy GenerationAutomated BGP Policy Generation
• Commit the configuration, and the script runs.
• The script reads the “location” data from our config:
• var $location = system/location/apply-macro[bgp];
var $continent = $location/data[‘continent’]/value;
$ i $l ti /d t [‘ i ’]/ lvar $region = $location/data[‘region’]/value;
var $city = $location/data[‘city’]/value;
• Calls a function to build policy for every BGP neighbor• Calls a function to build policy for every BGP neighbor
• for-each (protocols/bgp/group/neighbor[peer-as]) {
call example($asn $name $continent $region $city);call example($asn, $name, $continent, $region, $city);
…
}
By Richard Steenbergen, nLayer Communications, Inc. 8
Automated BGP Policy GenerationAutomated BGP Policy Generation
Generate some new configurations defining BGP policies• Generate some new configurations defining BGP policies
<policy-statement> {
<name> "AUTO-COMMUNITY-" _ $name _ "-OUT";
<term> {
<name> "PREPEND_ONE";
<from> {
<community> "MATCH_" _ $name _ "_PREPEND_ONE";
}
<then> {{
<as-path-prepend> $local-as;
}
}}
…
By Richard Steenbergen, nLayer Communications, Inc. 9
Automated BGP Policy GenerationAutomated BGP Policy Generation
Generate some new configurations defining BGP communities• Generate some new configurations defining BGP communities
var $regexp = "((000)|" _ $reg_continent _ "|" _ $reg_continentregion _ "|" _ $reg_city _ ")$";
call jcs:emit-change($tag = 'transient-change', $dot = $path/policy-options) {
with $content = {
<community> {
<name> "MATCH_" _ $name _ "_PREPEND_ONE";
<members> "^" _ $asn _ ":1" _ $regexp;
}
<community> {y {
<name> "MATCH_" _ $name _ "_PREPEND_TWO";
<members> "^" _ $asn _ ":2" _ $regexp;
}}
<community> {
<name> "MATCH_" _ $name _ "_PREPEND_THREE";
<members> "^" $asn ":3" $regexp;<members> _ $asn _ :3 _ $regexp;
}
By Richard Steenbergen, nLayer Communications, Inc. 10
Automated BGP Policy GenerationAutomated BGP Policy Generation
• Script builds per ASN communities/policies for:• Script builds per-ASN communities/policies for:
• Prepend AS-PATH 1x
P d AS PATH 2• Prepend AS-PATH 2x
• Prepend AS-PATH 3x
S• Prepend AS-PATH 4x
• Set BGP MED to 0
• Deny export of BGP route
• Allow export of BGP route (override a broader Deny)
• Also builds generic community tags for the router:
• Match routes from current continent/region/cityg y
• Tag route learned in current continent/region/city
By Richard Steenbergen, nLayer Communications, Inc. 11
Automated BGP Policy GenerationAutomated BGP Policy Generation
• Dynamically creates community expressions that look like this:y y y p
community MATCH_3356_PREPEND_ONE members "^3356:1((000)|(010)|(012)|(116))$";
community MATCH_3356_PREPEND_TWO members "^3356:2((000)|(010)|(012)|(116))$";
community MATCH 3356 PREPEND THREE members "^3356:3((000)|(010)|(012)|(116))$";y _ _ _ (( )|( )|( )|( ))$ ;
community MATCH_3356_PREPEND_FOUR members "^3356:4((000)|(010)|(012)|(116))$";
community MATCH_3356_MED_ZERO members "^3356:5((000)|(010)|(012)|(116))$";
community MATCH_3356_DENY_EXPORT members "^3356:6((000)|(010)|(012)|(116))$";y (( )|( )|( )|( ))
community MATCH_3356_FORCE_EXPORT members "^3356:9((000)|(010)|(012)|(116))$";
• And the policies which reference these expressions
term PREPEND ONE {term PREPEND_ONE {
from community MATCH_3356_PREPEND_ONE;
then as-path-prepend “1234”;
}}
term PREPEND_TWO {
from community MATCH_3356_PREPEND_TWO;
then as-path-prepend “1234 1234";then as path prepend 1234 1234 ;
}
…
By Richard Steenbergen, nLayer Communications, Inc. 12
Automated BGP Policy GenerationAutomated BGP Policy Generation
Al f l f b ildi AS PATH l k filt• Also useful for building AS-PATH leak filters
• Define a list of major ASNs you only want to hear “directly”
Bl k t ith f th d ASN i th AS PATH if• Block any route with one of these reserved ASNs in the AS-PATH if
the route didn’t come directly from one of those ASNs.
• Useful for preventing leaks and suboptimal routing.p g p g
• If I peer directly with AS701, I don’t ever want to accept a route with
701 in the AS-PATH from anyone other than a AS701 neighbor.
• The same script can build a per-peer AS-PATH filter which
blocks every ASN on the list except the ASN of the peer.
• This can’t be done via RegExp in Cisco or Juniper (or any other• This can t be done via RegExp in Cisco or Juniper (or any other
major router vendor) today, a per-ASN AS-PATH filter policy is
the only way to accomplish this task.
• This filter is highly effective at blocking accidental leaks.
By Richard Steenbergen, nLayer Communications, Inc. 13
Automated BGP Policy GenerationAutomated BGP Policy Generation
Al f l f b ildi li f k• Also useful for building policy frameworks
• Script scan for the existence of a policy with a standard
( POLICY AS#### IN) f BGP i hbname (e.g. POLICY-AS####-IN) for every BGP neighbor.
• If the policy exists, it is automatically linked in to the policy
chain as a “subroutine” to existing standardized policieschain as a “subroutine” to existing standardized policies.
• The standardized policy enforces certain requirements for
the BGP neighbor such as the BGP Community tagthe BGP neighbor, such as the BGP Community tag.
• While also allowing operations staff to tweak the route.
• Allow your operations staff to tweak a local pref or a MED• Allow your operations staff to tweak a local-pref or a MED
without ever being able to accidentally leak the route.
• Simplifies BGP configuration policies linked automatically• Simplifies BGP configuration, policies linked automatically.
By Richard Steenbergen, nLayer Communications, Inc. 14
Automated BGP Policy GenerationAutomated BGP Policy Generation
• Insert the newly created policies into the import/export policy chains
f h ( t l /b / / i hb [ ]) {for-each (protocols/bgp/group/neighbor[peer-as]) {
var $import = jcs:first-of(import, ../import, ../../import);
var $export = jcs:first-of(export, ../export, ../../export);
var $in first = $import[position() = 1];var $in_first $import[position() 1];
var $out_first = $export[position() = 1];
call jcs:emit-change($tag = 'transient-change') {
with $content = {
<import> $import;
<import insert="after" name=$in_first> "AUTOCOMM-" _ peer-as _ "-IN";
<export> $export;<export> $export;
<export insert="after" name=$out_first> "AUTOCOMM-“ _ peer-as _ "-OUT";
}
}}
}
By Richard Steenbergen, nLayer Communications, Inc. 15
Automated BGP Policy GenerationAutomated BGP Policy Generation
S i t R lt• Script Results
• Script automatically generates and maintains 44 lines of new
router configuration for every configured BGP peerrouter configuration for every configured BGP peer.
• Script automatically build many of the BGP community
definitions for the router.
• Script automatically links all the new policies together correctly,
avoiding rote human effort and potential mistakes.
• The Net Effect
• For routers with hundreds of BGP peers, thousands of lines of
configuration are automated, the user visible config is simplified.
• Enables new features (per-ASN communities, leak filters, policy
frame ork etc) that most net orks don’t implement todaframework, etc) that most networks don’t implement today.
By Richard Steenbergen, nLayer Communications, Inc. 16
Automated BGP Prefix-Limit Managementg
By Richard Steenbergen, nLayer Communications, Inc. 17
BGP Prefix LimitsBGP Prefix Limits
• Operators use BGP prefix-limits as policy safety nets
• If a BGP neighbor sends more prefixes than we believe is
normal, drop the BGP session for a certain period of time.
• Somewhat effective at protecting against the propagation
of major leaks, and a commonly used tool for most peers.
• But they are somewhat difficult to maintain
• The concept of “normal” is always evolving, as networks
grow, shrink, or otherwise change their announcements.
• Stale prefix-limit configurations are probably responsible
for thousands of peering outages every year.
• But keeping the limits set at sensible values is hard work.
By Richard Steenbergen, nLayer Communications, Inc. 18
Use Router Scripting to Automate LimitsUse Router Scripting to Automate Limits
• How do you determine a sensible prefix limit?
• Typically based on the number of current prefixes.
• Plus some percentage extra for growth
• Plus some fixed number to handle small prefix counts.
• Example: (PfxCnt*1.25)+500
• But you also want to react to changes slowlyBut you also want to react to changes slowly
• Don’t slash your prefix-limit because the peer happens to
be announcing 0 prefixes due to an outage one night.be announcing 0 prefixes due to an outage one night.
• Use a weighted moving average to adjust the limit slowly
over time, towards the newly computed value., y p
By Richard Steenbergen, nLayer Communications, Inc. 19
Use Router Scripting to Automate LimitsUse Router Scripting to Automate Limits
• Write a script to update the prefix-limit accordingly.
• Have it run automatically on the router every night.
• Allow a manual run to tune the limits if necessary.
var $config = jcs:invoke($get-config)/configuration/protocols/bgp;
var $neighbors = jcs:invoke('get-bgp-summary-information');
for-each ($config/group/neighbor[peer-as]) {
var $address = name;
var $neighbor = $neighbors/bgp-peer[peer-address == $address];var $neighbor $neighbors/bgp peer[peer address $address];
var $pfxlimit = apply-macro[name == 'prefix-limit']/data[name == 'inet'];
var $pfxrecv = $neighbor/bgp-rib[name == 'inet.0']/received-prefix-count;
var $rcvlimit = ceiling((($pfxrecv * 1.25) + 500) div 500) * 500;$ g((($p ) ) ) ;
…
By Richard Steenbergen, nLayer Communications, Inc. 20
Automating Support Casesg pp
By Richard Steenbergen, nLayer Communications, Inc. 21
Opening Vendor Support CasesOpening Vendor Support Cases
• We all find bugs or need to open support cases
• Many times gathering the support information and
uploading them to the Vendor can be long and painful.
• Support information, current configuration, scripts, log
files, on the active and backup management cards, etc.
• Solution: Automate it with a script
• Gather the most common log files and support
components, and automatically upload them to the
vendor FTP site.
By Richard Steenbergen, nLayer Communications, Inc. 22
Gather and Upload the DataGather and Upload the Data
var $dest = jcs:first-of($destination, "ftp://ftp.juniper.net/pub/incoming/");
var $support = jcs:invoke('get-support-information');
var $config = jcs:invoke('get-configuration');
call upload($file = $re _ ":/tmp/support", $dest = $dest _ $case);
$ $ $ $ $call upload($file = $re _ ":/tmp/configuration", $dest = $dest _ $case);
call upload($file = $re _ ":/var/log/messages", $dest = $dest _ $case);
call upload($file = $re _ ":/var/log/chassisd", $dest = $dest _ $case);
…
var $filename = jcs:regex("[^/]+$", $file)[1];
var $destfile = $hostname _ "." _ $filename;
var $copy upload = {var $copy_upload = {
<file-copy> {
<source> $tmpfile;
<destination> $dest "/" $destfile;<destination> $dest _ / _ $destfile;
}
}
<output> "Uploading " $filename " to " $dest;<output> Uploading _ $filename _ to _ $dest;
jcs:invoke($copy_upload);
By Richard Steenbergen, nLayer Communications, Inc. 23
How Effective Is It?How Effective Is It?
• Router configuration size reduced by 62%
ras@randomrouter> show configuration | countras@randomrouter> show configuration | count
Count: 2587 lines
ras@randomrouter> show configuration | display commit-scripts | count
Count: 6742 lines
By Richard Steenbergen, nLayer Communications, Inc. 24
Send questions, comments, complaints to:q p
Richard A Steenbergen ras@nlayer.net

Weitere ähnliche Inhalte

Was ist angesagt?

An Introduction to BGP Flow Spec
An Introduction to BGP Flow SpecAn Introduction to BGP Flow Spec
An Introduction to BGP Flow SpecShortestPathFirst
 
Part 10 : Routing in IP networks and interdomain routing with BGP
Part 10 : Routing in IP networks and interdomain routing with BGPPart 10 : Routing in IP networks and interdomain routing with BGP
Part 10 : Routing in IP networks and interdomain routing with BGPOlivier Bonaventure
 
Managing Traffic Flows via BGP Flowspec by Mohd Izni Zuhdi Mohamed Rawi
Managing Traffic Flows via BGP Flowspec by Mohd Izni Zuhdi Mohamed RawiManaging Traffic Flows via BGP Flowspec by Mohd Izni Zuhdi Mohamed Rawi
Managing Traffic Flows via BGP Flowspec by Mohd Izni Zuhdi Mohamed RawiMyNOG
 
Funtions of i pv6
Funtions of i pv6Funtions of i pv6
Funtions of i pv6thanhthat1
 
LinkedIn's Approach to Programmable Data Center
LinkedIn's Approach to Programmable Data CenterLinkedIn's Approach to Programmable Data Center
LinkedIn's Approach to Programmable Data CenterShawn Zandi
 
BIRD Routing Daemon
BIRD Routing DaemonBIRD Routing Daemon
BIRD Routing DaemonAPNIC
 
Traffic Engineering Using Segment Routing
Traffic Engineering Using Segment Routing Traffic Engineering Using Segment Routing
Traffic Engineering Using Segment Routing Cisco Canada
 
How LinkedIn used TCP Anycast to make the site faster
How LinkedIn used TCP Anycast to make the site fasterHow LinkedIn used TCP Anycast to make the site faster
How LinkedIn used TCP Anycast to make the site fasterShawn Zandi
 
SDN Traffic Engineering, A Natural Evolution
SDN Traffic Engineering, A Natural EvolutionSDN Traffic Engineering, A Natural Evolution
SDN Traffic Engineering, A Natural EvolutionAPNIC
 
Whitepaper: Network transitioning from IPv4 to IPv6 Document - Happiest Minds
Whitepaper: Network transitioning from IPv4 to IPv6 Document - Happiest MindsWhitepaper: Network transitioning from IPv4 to IPv6 Document - Happiest Minds
Whitepaper: Network transitioning from IPv4 to IPv6 Document - Happiest MindsHappiest Minds Technologies
 
I pv6 routing_protocol_for_low_power_and_lossy_
I pv6 routing_protocol_for_low_power_and_lossy_I pv6 routing_protocol_for_low_power_and_lossy_
I pv6 routing_protocol_for_low_power_and_lossy_Sheetal Kshirsagar
 
SGNOG2 - Using communities for multihoming ISP workshop
SGNOG2 - Using communities for multihoming ISP workshopSGNOG2 - Using communities for multihoming ISP workshop
SGNOG2 - Using communities for multihoming ISP workshopAPNIC
 
Interior Routing Protocols
Interior Routing ProtocolsInterior Routing Protocols
Interior Routing ProtocolsKHNOG
 

Was ist angesagt? (20)

An Introduction to BGP Flow Spec
An Introduction to BGP Flow SpecAn Introduction to BGP Flow Spec
An Introduction to BGP Flow Spec
 
SEGMENT Routing
SEGMENT RoutingSEGMENT Routing
SEGMENT Routing
 
Part 10 : Routing in IP networks and interdomain routing with BGP
Part 10 : Routing in IP networks and interdomain routing with BGPPart 10 : Routing in IP networks and interdomain routing with BGP
Part 10 : Routing in IP networks and interdomain routing with BGP
 
bgp(border gateway protocol)
bgp(border gateway protocol)bgp(border gateway protocol)
bgp(border gateway protocol)
 
Managing Traffic Flows via BGP Flowspec by Mohd Izni Zuhdi Mohamed Rawi
Managing Traffic Flows via BGP Flowspec by Mohd Izni Zuhdi Mohamed RawiManaging Traffic Flows via BGP Flowspec by Mohd Izni Zuhdi Mohamed Rawi
Managing Traffic Flows via BGP Flowspec by Mohd Izni Zuhdi Mohamed Rawi
 
Funtions of i pv6
Funtions of i pv6Funtions of i pv6
Funtions of i pv6
 
Ipv6 routing
Ipv6 routingIpv6 routing
Ipv6 routing
 
LinkedIn's Approach to Programmable Data Center
LinkedIn's Approach to Programmable Data CenterLinkedIn's Approach to Programmable Data Center
LinkedIn's Approach to Programmable Data Center
 
BGP Overview
BGP OverviewBGP Overview
BGP Overview
 
BIRD Routing Daemon
BIRD Routing DaemonBIRD Routing Daemon
BIRD Routing Daemon
 
Cisco OTV 
Cisco OTV Cisco OTV 
Cisco OTV 
 
Traffic Engineering Using Segment Routing
Traffic Engineering Using Segment Routing Traffic Engineering Using Segment Routing
Traffic Engineering Using Segment Routing
 
How LinkedIn used TCP Anycast to make the site faster
How LinkedIn used TCP Anycast to make the site fasterHow LinkedIn used TCP Anycast to make the site faster
How LinkedIn used TCP Anycast to make the site faster
 
SDN Traffic Engineering, A Natural Evolution
SDN Traffic Engineering, A Natural EvolutionSDN Traffic Engineering, A Natural Evolution
SDN Traffic Engineering, A Natural Evolution
 
Whitepaper: Network transitioning from IPv4 to IPv6 Document - Happiest Minds
Whitepaper: Network transitioning from IPv4 to IPv6 Document - Happiest MindsWhitepaper: Network transitioning from IPv4 to IPv6 Document - Happiest Minds
Whitepaper: Network transitioning from IPv4 to IPv6 Document - Happiest Minds
 
I pv6 routing_protocol_for_low_power_and_lossy_
I pv6 routing_protocol_for_low_power_and_lossy_I pv6 routing_protocol_for_low_power_and_lossy_
I pv6 routing_protocol_for_low_power_and_lossy_
 
BGP Advanced topics
BGP Advanced topicsBGP Advanced topics
BGP Advanced topics
 
EVPN Introduction
EVPN IntroductionEVPN Introduction
EVPN Introduction
 
SGNOG2 - Using communities for multihoming ISP workshop
SGNOG2 - Using communities for multihoming ISP workshopSGNOG2 - Using communities for multihoming ISP workshop
SGNOG2 - Using communities for multihoming ISP workshop
 
Interior Routing Protocols
Interior Routing ProtocolsInterior Routing Protocols
Interior Routing Protocols
 

Ähnlich wie Scripting on Routers - NANOG 47

Openconfig
OpenconfigOpenconfig
OpenconfigAPNIC
 
Model driven telemetry
Model driven telemetryModel driven telemetry
Model driven telemetryCisco Canada
 
Cisco Connect Toronto 2017 - Model-driven Telemetry
Cisco Connect Toronto 2017 - Model-driven TelemetryCisco Connect Toronto 2017 - Model-driven Telemetry
Cisco Connect Toronto 2017 - Model-driven TelemetryCisco Canada
 
DEVNET-1191 BGP Enabled Application Development
DEVNET-1191	BGP Enabled Application DevelopmentDEVNET-1191	BGP Enabled Application Development
DEVNET-1191 BGP Enabled Application DevelopmentCisco DevNet
 
Initial Experiences Route Filtering at the Edge AS15169 by Arturo L. Servin
Initial Experiences Route Filtering at the Edge AS15169 by Arturo L. ServinInitial Experiences Route Filtering at the Edge AS15169 by Arturo L. Servin
Initial Experiences Route Filtering at the Edge AS15169 by Arturo L. ServinMyNOG
 
Routing Security Roadmap
Routing Security RoadmapRouting Security Roadmap
Routing Security RoadmapAPNIC
 
Creating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at ScaleCreating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at ScaleSean Chittenden
 
Internet Measurement Tools & Their Usefulness by Gaurab Raj Upadhaya
Internet Measurement Tools & Their Usefulness by Gaurab Raj UpadhayaInternet Measurement Tools & Their Usefulness by Gaurab Raj Upadhaya
Internet Measurement Tools & Their Usefulness by Gaurab Raj UpadhayaMyNOG
 
Building CloudScale Networks - AWS Summit Sydney 2018
Building CloudScale Networks - AWS Summit Sydney 2018Building CloudScale Networks - AWS Summit Sydney 2018
Building CloudScale Networks - AWS Summit Sydney 2018Amazon Web Services
 
PLNOG 13: Krzysztof Mazepa: BGP FlowSpec
PLNOG 13: Krzysztof Mazepa: BGP FlowSpecPLNOG 13: Krzysztof Mazepa: BGP FlowSpec
PLNOG 13: Krzysztof Mazepa: BGP FlowSpecPROIDEA
 
Model-driven Telemetry: The Foundation of Big Data Analytics
Model-driven Telemetry: The Foundation of Big Data AnalyticsModel-driven Telemetry: The Foundation of Big Data Analytics
Model-driven Telemetry: The Foundation of Big Data AnalyticsCisco Canada
 
DIY Netflow Data Analytic with ELK Stack by CL Lee
DIY Netflow Data Analytic with ELK Stack by CL LeeDIY Netflow Data Analytic with ELK Stack by CL Lee
DIY Netflow Data Analytic with ELK Stack by CL LeeMyNOG
 
How our Cloudy Mindsets Approached Physical Routers
How our Cloudy Mindsets Approached Physical RoutersHow our Cloudy Mindsets Approached Physical Routers
How our Cloudy Mindsets Approached Physical RoutersSteffen Gebert
 
Инновации Cisco для операторов связи
Инновации Cisco для операторов связиИнновации Cisco для операторов связи
Инновации Cisco для операторов связиCisco Russia
 

Ähnlich wie Scripting on Routers - NANOG 47 (20)

Openconfig
OpenconfigOpenconfig
Openconfig
 
Model driven telemetry
Model driven telemetryModel driven telemetry
Model driven telemetry
 
Cisco Connect Toronto 2017 - Model-driven Telemetry
Cisco Connect Toronto 2017 - Model-driven TelemetryCisco Connect Toronto 2017 - Model-driven Telemetry
Cisco Connect Toronto 2017 - Model-driven Telemetry
 
DEVNET-1191 BGP Enabled Application Development
DEVNET-1191	BGP Enabled Application DevelopmentDEVNET-1191	BGP Enabled Application Development
DEVNET-1191 BGP Enabled Application Development
 
Part1
Part1Part1
Part1
 
Tale of a New Bangladeshi NIX
Tale of a New Bangladeshi NIXTale of a New Bangladeshi NIX
Tale of a New Bangladeshi NIX
 
Initial Experiences Route Filtering at the Edge AS15169 by Arturo L. Servin
Initial Experiences Route Filtering at the Edge AS15169 by Arturo L. ServinInitial Experiences Route Filtering at the Edge AS15169 by Arturo L. Servin
Initial Experiences Route Filtering at the Edge AS15169 by Arturo L. Servin
 
Routing Security Roadmap
Routing Security RoadmapRouting Security Roadmap
Routing Security Roadmap
 
Route Origin Validation - A MANRS Approach
Route Origin Validation - A MANRS ApproachRoute Origin Validation - A MANRS Approach
Route Origin Validation - A MANRS Approach
 
Creating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at ScaleCreating PostgreSQL-as-a-Service at Scale
Creating PostgreSQL-as-a-Service at Scale
 
BGP
BGPBGP
BGP
 
Internet Measurement Tools & Their Usefulness by Gaurab Raj Upadhaya
Internet Measurement Tools & Their Usefulness by Gaurab Raj UpadhayaInternet Measurement Tools & Their Usefulness by Gaurab Raj Upadhaya
Internet Measurement Tools & Their Usefulness by Gaurab Raj Upadhaya
 
Building Cloudscale Networks
Building Cloudscale NetworksBuilding Cloudscale Networks
Building Cloudscale Networks
 
Building CloudScale Networks - AWS Summit Sydney 2018
Building CloudScale Networks - AWS Summit Sydney 2018Building CloudScale Networks - AWS Summit Sydney 2018
Building CloudScale Networks - AWS Summit Sydney 2018
 
PLNOG 13: Krzysztof Mazepa: BGP FlowSpec
PLNOG 13: Krzysztof Mazepa: BGP FlowSpecPLNOG 13: Krzysztof Mazepa: BGP FlowSpec
PLNOG 13: Krzysztof Mazepa: BGP FlowSpec
 
CCCNP ROUTE v6_ch05
CCCNP ROUTE  v6_ch05CCCNP ROUTE  v6_ch05
CCCNP ROUTE v6_ch05
 
Model-driven Telemetry: The Foundation of Big Data Analytics
Model-driven Telemetry: The Foundation of Big Data AnalyticsModel-driven Telemetry: The Foundation of Big Data Analytics
Model-driven Telemetry: The Foundation of Big Data Analytics
 
DIY Netflow Data Analytic with ELK Stack by CL Lee
DIY Netflow Data Analytic with ELK Stack by CL LeeDIY Netflow Data Analytic with ELK Stack by CL Lee
DIY Netflow Data Analytic with ELK Stack by CL Lee
 
How our Cloudy Mindsets Approached Physical Routers
How our Cloudy Mindsets Approached Physical RoutersHow our Cloudy Mindsets Approached Physical Routers
How our Cloudy Mindsets Approached Physical Routers
 
Инновации Cisco для операторов связи
Инновации Cisco для операторов связиИнновации Cisco для операторов связи
Инновации Cisco для операторов связи
 

Kürzlich hochgeladen

Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxeditsforyah
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Sonam Pathan
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationLinaWolf1
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxDyna Gilbert
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一Fs
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa494f574xmv
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Sonam Pathan
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationMarko4394
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书rnrncn29
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作ys8omjxb
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一Fs
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)Christopher H Felton
 
Magic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMagic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMartaLoveguard
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一z xss
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhimiss dipika
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predieusebiomeyer
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Paul Calvano
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一Fs
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Excelmac1
 

Kürzlich hochgeladen (20)

Q4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptxQ4-1-Illustrating-Hypothesis-Testing.pptx
Q4-1-Illustrating-Hypothesis-Testing.pptx
 
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
Call Girls In The Ocean Pearl Retreat Hotel New Delhi 9873777170
 
PHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 DocumentationPHP-based rendering of TYPO3 Documentation
PHP-based rendering of TYPO3 Documentation
 
Top 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptxTop 10 Interactive Website Design Trends in 2024.pptx
Top 10 Interactive Website Design Trends in 2024.pptx
 
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
定制(Lincoln毕业证书)新西兰林肯大学毕业证成绩单原版一比一
 
Film cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasaFilm cover research (1).pptxsdasdasdasdasdasa
Film cover research (1).pptxsdasdasdasdasdasa
 
Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170Call Girls Near The Suryaa Hotel New Delhi 9873777170
Call Girls Near The Suryaa Hotel New Delhi 9873777170
 
NSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentationNSX-T and Service Interfaces presentation
NSX-T and Service Interfaces presentation
 
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
『澳洲文凭』买拉筹伯大学毕业证书成绩单办理澳洲LTU文凭学位证书
 
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
Potsdam FH学位证,波茨坦应用技术大学毕业证书1:1制作
 
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
定制(Management毕业证书)新加坡管理大学毕业证成绩单原版一比一
 
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
A Good Girl's Guide to Murder (A Good Girl's Guide to Murder, #1)
 
Magic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptxMagic exist by Marta Loveguard - presentation.pptx
Magic exist by Marta Loveguard - presentation.pptx
 
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
办理(UofR毕业证书)罗切斯特大学毕业证成绩单原版一比一
 
Contact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New DelhiContact Rya Baby for Call Girls New Delhi
Contact Rya Baby for Call Girls New Delhi
 
SCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is prediSCM Symposium PPT Format Customer loyalty is predi
SCM Symposium PPT Format Customer loyalty is predi
 
Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24Font Performance - NYC WebPerf Meetup April '24
Font Performance - NYC WebPerf Meetup April '24
 
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
定制(AUT毕业证书)新西兰奥克兰理工大学毕业证成绩单原版一比一
 
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort ServiceHot Sexy call girls in  Rk Puram 🔝 9953056974 🔝 Delhi escort Service
Hot Sexy call girls in Rk Puram 🔝 9953056974 🔝 Delhi escort Service
 
Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...Blepharitis inflammation of eyelid symptoms cause everything included along w...
Blepharitis inflammation of eyelid symptoms cause everything included along w...
 

Scripting on Routers - NANOG 47

  • 1. Scripting on Routersp g Richard A Steenbergen <ras@nlayer.net> nLayer Communications, Inc. By Richard Steenbergen, nLayer Communications, Inc. 1
  • 2. Why Script on Routers?Why Script on Routers? • What do we mean by “Scripting on Routers?”What do we mean by Scripting on Routers? • Provide network operators with the ability to write custom software which runs on routers to simplify configurationssoftware which runs on routers, to simplify configurations, react to network events, and/or automate complex tasks. • Why do we need scripting on routers?Why do we need scripting on routers? • Router configurations are complex and often repetitive. • Scripts can simplify existing repetitive configurations• Scripts can simplify existing repetitive configurations. • Can also enable new features which might otherwise be impossible. • Humans frequently make mistakes.Humans frequently make mistakes. • Scripts can provide complex error checking to prevent accidents. • Humans cost a lot of money to maintain and administer.y • Scripts can reduce the manpower necessary to run a network. By Richard Steenbergen, nLayer Communications, Inc. 2
  • 3. What About Offline Automation?What About Offline Automation? • We have existing router management tools today• We have existing router management tools today • Expect/Perl/etc scripting over CLI Telnet/SSH IETF t d di d N tC f (XML b d) P t l• IETF standardized NetConf (XML based) Protocol • Some networks are entirely managed offline With h l i i t t l i t• With no humans logging into routers, only scripts. • But most networks are still run the old fashioned way • Writing offline tools requires dedicated/experienced staff. • It is difficult to pre-plan for every possible configuration. • Most networks use a mix of tools + standard CLI configs. • Scripting on the router provides the advantages of router management software, while still allowing manual one-offs. By Richard Steenbergen, nLayer Communications, Inc. 3
  • 4. Some Router Scripting ExamplesSome Router Scripting Examples E l t ti f 3 t ki t k• Example automation of 3 common networking tasks • Automated BGP Policy Generation • Per-ASN BGP communities and their associated policies. • Other Per-ASN policies such as AS-PATH leak filters. • All automated and built automatically for every BGP peer• All automated and built automatically for every BGP peer. • Automated BGP Prefix-Limit Management • Auto-tuning prefix-limits which adjust to follow changes in BGPAuto tuning prefix limits which adjust to follow changes in BGP. • Without requiring human intervention to maintain. • Support case data gathering scriptspp g g p • Automatically compiles and uploads logs/info when opening cases. By Richard Steenbergen, nLayer Communications, Inc. 4
  • 5. Automated BGP Policy Generationy By Richard Steenbergen, nLayer Communications, Inc. 5
  • 6. Automated BGP Policy GenerationAutomated BGP Policy Generation St t b d fi i “BGP l ti ”• Start by defining a “BGP location” macro: • Essentially a piece of custom router configuration which t i t i t b d b th i t l toperators can maintain, to be used by the script later on. • Here we define the values for continent, region, and city codes to be used for BGP Communities for the routercodes to be used for BGP Communities for the router. • system { location {location { apply-macro bgp { city 16;y ; continent 1; region 2; … By Richard Steenbergen, nLayer Communications, Inc. 6
  • 7. Automated BGP Policy GenerationAutomated BGP Policy Generation • Configure a BGP Peer like normal protocols { b {bgp { group PNI { import PRIVPEER-IN; export PRIVPEER-OUT; neighbor 1.2.3.4 { description “Example BGP Peer”;p p ; peer-as 1234; } }} } By Richard Steenbergen, nLayer Communications, Inc. 7
  • 8. Automated BGP Policy GenerationAutomated BGP Policy Generation • Commit the configuration, and the script runs. • The script reads the “location” data from our config: • var $location = system/location/apply-macro[bgp]; var $continent = $location/data[‘continent’]/value; $ i $l ti /d t [‘ i ’]/ lvar $region = $location/data[‘region’]/value; var $city = $location/data[‘city’]/value; • Calls a function to build policy for every BGP neighbor• Calls a function to build policy for every BGP neighbor • for-each (protocols/bgp/group/neighbor[peer-as]) { call example($asn $name $continent $region $city);call example($asn, $name, $continent, $region, $city); … } By Richard Steenbergen, nLayer Communications, Inc. 8
  • 9. Automated BGP Policy GenerationAutomated BGP Policy Generation Generate some new configurations defining BGP policies• Generate some new configurations defining BGP policies <policy-statement> { <name> "AUTO-COMMUNITY-" _ $name _ "-OUT"; <term> { <name> "PREPEND_ONE"; <from> { <community> "MATCH_" _ $name _ "_PREPEND_ONE"; } <then> {{ <as-path-prepend> $local-as; } }} … By Richard Steenbergen, nLayer Communications, Inc. 9
  • 10. Automated BGP Policy GenerationAutomated BGP Policy Generation Generate some new configurations defining BGP communities• Generate some new configurations defining BGP communities var $regexp = "((000)|" _ $reg_continent _ "|" _ $reg_continentregion _ "|" _ $reg_city _ ")$"; call jcs:emit-change($tag = 'transient-change', $dot = $path/policy-options) { with $content = { <community> { <name> "MATCH_" _ $name _ "_PREPEND_ONE"; <members> "^" _ $asn _ ":1" _ $regexp; } <community> {y { <name> "MATCH_" _ $name _ "_PREPEND_TWO"; <members> "^" _ $asn _ ":2" _ $regexp; }} <community> { <name> "MATCH_" _ $name _ "_PREPEND_THREE"; <members> "^" $asn ":3" $regexp;<members> _ $asn _ :3 _ $regexp; } By Richard Steenbergen, nLayer Communications, Inc. 10
  • 11. Automated BGP Policy GenerationAutomated BGP Policy Generation • Script builds per ASN communities/policies for:• Script builds per-ASN communities/policies for: • Prepend AS-PATH 1x P d AS PATH 2• Prepend AS-PATH 2x • Prepend AS-PATH 3x S• Prepend AS-PATH 4x • Set BGP MED to 0 • Deny export of BGP route • Allow export of BGP route (override a broader Deny) • Also builds generic community tags for the router: • Match routes from current continent/region/cityg y • Tag route learned in current continent/region/city By Richard Steenbergen, nLayer Communications, Inc. 11
  • 12. Automated BGP Policy GenerationAutomated BGP Policy Generation • Dynamically creates community expressions that look like this:y y y p community MATCH_3356_PREPEND_ONE members "^3356:1((000)|(010)|(012)|(116))$"; community MATCH_3356_PREPEND_TWO members "^3356:2((000)|(010)|(012)|(116))$"; community MATCH 3356 PREPEND THREE members "^3356:3((000)|(010)|(012)|(116))$";y _ _ _ (( )|( )|( )|( ))$ ; community MATCH_3356_PREPEND_FOUR members "^3356:4((000)|(010)|(012)|(116))$"; community MATCH_3356_MED_ZERO members "^3356:5((000)|(010)|(012)|(116))$"; community MATCH_3356_DENY_EXPORT members "^3356:6((000)|(010)|(012)|(116))$";y (( )|( )|( )|( )) community MATCH_3356_FORCE_EXPORT members "^3356:9((000)|(010)|(012)|(116))$"; • And the policies which reference these expressions term PREPEND ONE {term PREPEND_ONE { from community MATCH_3356_PREPEND_ONE; then as-path-prepend “1234”; }} term PREPEND_TWO { from community MATCH_3356_PREPEND_TWO; then as-path-prepend “1234 1234";then as path prepend 1234 1234 ; } … By Richard Steenbergen, nLayer Communications, Inc. 12
  • 13. Automated BGP Policy GenerationAutomated BGP Policy Generation Al f l f b ildi AS PATH l k filt• Also useful for building AS-PATH leak filters • Define a list of major ASNs you only want to hear “directly” Bl k t ith f th d ASN i th AS PATH if• Block any route with one of these reserved ASNs in the AS-PATH if the route didn’t come directly from one of those ASNs. • Useful for preventing leaks and suboptimal routing.p g p g • If I peer directly with AS701, I don’t ever want to accept a route with 701 in the AS-PATH from anyone other than a AS701 neighbor. • The same script can build a per-peer AS-PATH filter which blocks every ASN on the list except the ASN of the peer. • This can’t be done via RegExp in Cisco or Juniper (or any other• This can t be done via RegExp in Cisco or Juniper (or any other major router vendor) today, a per-ASN AS-PATH filter policy is the only way to accomplish this task. • This filter is highly effective at blocking accidental leaks. By Richard Steenbergen, nLayer Communications, Inc. 13
  • 14. Automated BGP Policy GenerationAutomated BGP Policy Generation Al f l f b ildi li f k• Also useful for building policy frameworks • Script scan for the existence of a policy with a standard ( POLICY AS#### IN) f BGP i hbname (e.g. POLICY-AS####-IN) for every BGP neighbor. • If the policy exists, it is automatically linked in to the policy chain as a “subroutine” to existing standardized policieschain as a “subroutine” to existing standardized policies. • The standardized policy enforces certain requirements for the BGP neighbor such as the BGP Community tagthe BGP neighbor, such as the BGP Community tag. • While also allowing operations staff to tweak the route. • Allow your operations staff to tweak a local pref or a MED• Allow your operations staff to tweak a local-pref or a MED without ever being able to accidentally leak the route. • Simplifies BGP configuration policies linked automatically• Simplifies BGP configuration, policies linked automatically. By Richard Steenbergen, nLayer Communications, Inc. 14
  • 15. Automated BGP Policy GenerationAutomated BGP Policy Generation • Insert the newly created policies into the import/export policy chains f h ( t l /b / / i hb [ ]) {for-each (protocols/bgp/group/neighbor[peer-as]) { var $import = jcs:first-of(import, ../import, ../../import); var $export = jcs:first-of(export, ../export, ../../export); var $in first = $import[position() = 1];var $in_first $import[position() 1]; var $out_first = $export[position() = 1]; call jcs:emit-change($tag = 'transient-change') { with $content = { <import> $import; <import insert="after" name=$in_first> "AUTOCOMM-" _ peer-as _ "-IN"; <export> $export;<export> $export; <export insert="after" name=$out_first> "AUTOCOMM-“ _ peer-as _ "-OUT"; } }} } By Richard Steenbergen, nLayer Communications, Inc. 15
  • 16. Automated BGP Policy GenerationAutomated BGP Policy Generation S i t R lt• Script Results • Script automatically generates and maintains 44 lines of new router configuration for every configured BGP peerrouter configuration for every configured BGP peer. • Script automatically build many of the BGP community definitions for the router. • Script automatically links all the new policies together correctly, avoiding rote human effort and potential mistakes. • The Net Effect • For routers with hundreds of BGP peers, thousands of lines of configuration are automated, the user visible config is simplified. • Enables new features (per-ASN communities, leak filters, policy frame ork etc) that most net orks don’t implement todaframework, etc) that most networks don’t implement today. By Richard Steenbergen, nLayer Communications, Inc. 16
  • 17. Automated BGP Prefix-Limit Managementg By Richard Steenbergen, nLayer Communications, Inc. 17
  • 18. BGP Prefix LimitsBGP Prefix Limits • Operators use BGP prefix-limits as policy safety nets • If a BGP neighbor sends more prefixes than we believe is normal, drop the BGP session for a certain period of time. • Somewhat effective at protecting against the propagation of major leaks, and a commonly used tool for most peers. • But they are somewhat difficult to maintain • The concept of “normal” is always evolving, as networks grow, shrink, or otherwise change their announcements. • Stale prefix-limit configurations are probably responsible for thousands of peering outages every year. • But keeping the limits set at sensible values is hard work. By Richard Steenbergen, nLayer Communications, Inc. 18
  • 19. Use Router Scripting to Automate LimitsUse Router Scripting to Automate Limits • How do you determine a sensible prefix limit? • Typically based on the number of current prefixes. • Plus some percentage extra for growth • Plus some fixed number to handle small prefix counts. • Example: (PfxCnt*1.25)+500 • But you also want to react to changes slowlyBut you also want to react to changes slowly • Don’t slash your prefix-limit because the peer happens to be announcing 0 prefixes due to an outage one night.be announcing 0 prefixes due to an outage one night. • Use a weighted moving average to adjust the limit slowly over time, towards the newly computed value., y p By Richard Steenbergen, nLayer Communications, Inc. 19
  • 20. Use Router Scripting to Automate LimitsUse Router Scripting to Automate Limits • Write a script to update the prefix-limit accordingly. • Have it run automatically on the router every night. • Allow a manual run to tune the limits if necessary. var $config = jcs:invoke($get-config)/configuration/protocols/bgp; var $neighbors = jcs:invoke('get-bgp-summary-information'); for-each ($config/group/neighbor[peer-as]) { var $address = name; var $neighbor = $neighbors/bgp-peer[peer-address == $address];var $neighbor $neighbors/bgp peer[peer address $address]; var $pfxlimit = apply-macro[name == 'prefix-limit']/data[name == 'inet']; var $pfxrecv = $neighbor/bgp-rib[name == 'inet.0']/received-prefix-count; var $rcvlimit = ceiling((($pfxrecv * 1.25) + 500) div 500) * 500;$ g((($p ) ) ) ; … By Richard Steenbergen, nLayer Communications, Inc. 20
  • 21. Automating Support Casesg pp By Richard Steenbergen, nLayer Communications, Inc. 21
  • 22. Opening Vendor Support CasesOpening Vendor Support Cases • We all find bugs or need to open support cases • Many times gathering the support information and uploading them to the Vendor can be long and painful. • Support information, current configuration, scripts, log files, on the active and backup management cards, etc. • Solution: Automate it with a script • Gather the most common log files and support components, and automatically upload them to the vendor FTP site. By Richard Steenbergen, nLayer Communications, Inc. 22
  • 23. Gather and Upload the DataGather and Upload the Data var $dest = jcs:first-of($destination, "ftp://ftp.juniper.net/pub/incoming/"); var $support = jcs:invoke('get-support-information'); var $config = jcs:invoke('get-configuration'); call upload($file = $re _ ":/tmp/support", $dest = $dest _ $case); $ $ $ $ $call upload($file = $re _ ":/tmp/configuration", $dest = $dest _ $case); call upload($file = $re _ ":/var/log/messages", $dest = $dest _ $case); call upload($file = $re _ ":/var/log/chassisd", $dest = $dest _ $case); … var $filename = jcs:regex("[^/]+$", $file)[1]; var $destfile = $hostname _ "." _ $filename; var $copy upload = {var $copy_upload = { <file-copy> { <source> $tmpfile; <destination> $dest "/" $destfile;<destination> $dest _ / _ $destfile; } } <output> "Uploading " $filename " to " $dest;<output> Uploading _ $filename _ to _ $dest; jcs:invoke($copy_upload); By Richard Steenbergen, nLayer Communications, Inc. 23
  • 24. How Effective Is It?How Effective Is It? • Router configuration size reduced by 62% ras@randomrouter> show configuration | countras@randomrouter> show configuration | count Count: 2587 lines ras@randomrouter> show configuration | display commit-scripts | count Count: 6742 lines By Richard Steenbergen, nLayer Communications, Inc. 24
  • 25. Send questions, comments, complaints to:q p Richard A Steenbergen ras@nlayer.net