Python network automation, BGP and IOS regular expressions (regex). Search output (Part 2).
Skills:
Prompting Basics70%
Key Takeaways
Use regular expressions with Python network automation for BGP and IOS configuration
Full Transcript
[Music] follow every trap every road additional strain analyze and try to feel you laugh those lines up on your face [Music] Oh Oh [Music] this is one of multiple videos discussing regular expressions another regular expression is a star this matches zero or more sequences of the character preceding the star or asterisk it also acts as a wild-card for matching any number of characters so five star matches any occurrence of the number five including none this matches the character eighteen dot because we escaping the special meaning of this value and any characters are that to follow 18 so on a switch in my journey through topology if I type shall run type include in user dot star that includes all lines that have user followed by zero or more characters so this is looking for any character repeated zero more times if we do this we get that output that's looking for use followed by zero or more occurrences of our so we don't want zero or more occurrences of our we want the user followed by zero or more occurrences of something so we get output like that now in Python we can do something similar so let me show you some Python theory on the Python documentation page they talk about regular expression subtext it's very similar to what you'll find on Cisco dodge in default mode matches any character except a newline star or asterisk causes the resulting regular expression to match zero or more repetitions of the preceding regular expression as many repetitions as are possible so this matches a a B or a followed by any number of bees so again use a dot star gives us that but the user star gives us that notice we have zero or more occurrences of the letter R ok so cat reg X 3 dot py here's a Python script that I've created and we are searching for user dot star just like we did on the Cisco IOS here so again we should if our Python script works properly see this information returned so I'll run the script Python reg X 3 dot py and notice that's what's returned now the great thing about regular expressions is you can use show commands to test things before you add them to scripts or to BGP statements so as an example looking at the regular expressions in BGP in this example notice they've got a permit dot star that permits anything so they've got an IP access path access list one two nine an underscore means space for is the digit fall and end of line and then this matches anything else so this is like a permit any any so they are denying BGP advertisements from this neighbor so inbound from that neighbor based on this IP autonomous system private access list so here they are denying all routes that originate in autonomous system for and then they are permitting all other routes so this is denying all BGP advertisements that originated from autonomous system for but then they are permitting everything else now you can test that kind of thing in the CLI again by typing so run pipe include and let's include e that will show me all a lines that have a in them and as you can see there are many lines if I say e dollar that shows me all lines that end in E in this case only control plane if I touch to run we can see a whole bunch of lines let's look for lines that end in zero so firstly without the dollar that's all lines that include zero such as this line here and this line here that if we say zero dollar that's all lines that end in zero so notice all of these lines end in a zero if we say space $0 that's all lines that have a space to then a zero and then end of line so notice space zero end of line that's different to what we saw over here here we weren't looking for a space here we were just looking for lines of that end in zero but now we're looking for lines for that end in space zero and that's what they doing here they're looking for all bgp advertisements that originated from autonomous system call if you look at BGP routing tables you'll notice that the autonomous system that rad originates from exactly the end so notice they don't say for dollar they say space a for dollar because otherwise you would match autonomous system numbers like sixty five thousand and four or one thousand and four and so forth and so on now in subsequent videos I'll continue talking about various regular expressions hope you enjoyed with this video if you did please like it and please subscribe to my youtube channel I wish you all the very best [Music]
Original Description
In this video I demonstrate how to use regular expressions with Python network automation. Learn how to use regular expression with BGP, Cisco IOS and Python.
Get $200 worth of network software for free here: https://goo.gl/613TUF
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from David Bombal · David Bombal · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
RYU SDN Controller Part 4: Graphical User Interface (GUI): Practical GNS3 SDN and OpenFlow
David Bombal
HPE Network Protector SDN Application Part 1 - Introduction
David Bombal
HPE Network Protector SDN Application Part 2 : DNS Interception using OpenFlow
David Bombal
HPE Network Protector SDN Application Part 3 - Lab Setup using Physical Switches
David Bombal
HPE Network Protector SDN Application Part 4 - Demo of malicious websites blocked
David Bombal
HPE Network Protector SDN Application Part 5 - Demo OpenFlow table interception flows
David Bombal
HPE Network Protector SDN Application Part 6 - Demo of Physical Switch configuration
David Bombal
HPE Network Protector SDN Application Part 7 - Demo Service Insertion Tunnel / GRE Tunnel
David Bombal
HPE Network Protector SDN Application Part 8 - Demo SDN OpenFlow Reporting
David Bombal
HPE Network Protector SDN Application Part 9 - Demo switches interception of DNS traffic
David Bombal
GNS3 Talks: GNS3 version 1.5.X Appliance Tips
David Bombal
CCNA 200-125 Exam: AAA demo: TACACS+ with GNS3
David Bombal
GNS3 2.0.0 beta 2 install
David Bombal
CCNA #012: Learn SNMP with GNS3, Wireshark and Solarwinds NPM - CCNA 200-125 exam
David Bombal
CCNA #013: Spanning Tree CCNA Exam Questions: Know the answer? CCNA 200-125 exam
David Bombal
GNS3 2.0.0 beta : GNS3 VM integration with GNS3 GUI
David Bombal
CCNA #018: Routing exam questions: Who wins? OSPF, EIGRP or RIP? Sure? CCNA 200-125 exam
David Bombal
CCNA #019: Spanning Tree CCNA Exam Questions: Root Bridge, Root Port and more: CCNA 200-125 exam
David Bombal
GNS3 Download, installation and configuration - GNS3 1.5.3 and Windows 10
David Bombal
CCNA #023 EIGRP Neighbor Troubleshooting (DUAL Issues) for the CCNA 200-125 Exam
David Bombal
GNS3 2.0 Architecture and schema Part 1: What is the GNS3 Controller?
David Bombal
GNS3 2.0 Architecture and schema Part 2: Emulators and virtualization
David Bombal
CCNA #028 VTP Troubleshooting for the CCNA 200-125 Exam
David Bombal
CCNA #029 VTP & DTP Troubleshooting for the CCNA 200-125 Exam
David Bombal
CCNA #030 VTP Troubleshooting for the CCNA 200-125 Exam
David Bombal
GNS3 : How to download Cisco IOS images and VIRL images. Which is the best? How do you get them?
David Bombal
GNS3 ASA setup: Import and configure Cisco ASAv with GNS3
David Bombal
GNS3 switching setup and options: Cisco and other switching options in GNS3
David Bombal
GNS3 switching setup and options Part 2: GNS3 unmanaged built-in switch
David Bombal
GNS3 switching setup and options Part 3: Router on a sick with GNS3 unmanaged built-in switch
David Bombal
GNS3 switching setup and options Part 4: Etherswitch Router for Cisco Dynamips Part 1
David Bombal
GNS3 switching setup and options Part 5: Etherswitch Router for Cisco Dynamips Part 2
David Bombal
GNS3 switching setup and options Part 6: Etherswitch, Wireshark, 802.1Q, InterVLAN routing
David Bombal
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 1: GNS3 Switching Part 7
David Bombal
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 2: GNS3 Switching Part 8
David Bombal
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 3: GNS3 Switching Part 9
David Bombal
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 4: GNS3 Switching Part 10
David Bombal
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 5: GNS3 Switching Part 11
David Bombal
GNS3 Nexus (NX-OSv) switch setup and configuration Part 1: GNS3 switching options Part 12
David Bombal
GNS3 Nexus (NX-OSv) switch setup and configuration Part 2: GNS3 switching options Part 13
David Bombal
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 6: GNS3 Switching Part 14
David Bombal
GNS3 Talks: Docker, Open vSwitch, SDN and OpenFlow Part 7: GNS3 Switching Part 15
David Bombal
GNS3 Cisco CSR 1000v setup and configuration Part 1: GNS3 NFV
David Bombal
GNS3 Cisco CSR 1000v setup and configuration Part 2: GNS3 NFV
David Bombal
GNS3 Talks: Use the NAT node to connect GNS3 to the Internet easily!
David Bombal
GNS3 Talks: GNS3 2.0 RC1 is now available
David Bombal
GNS3 Talks: GNS3 2.0 Portable Projects - easily export and import GNS3 projects
David Bombal
GNS3 Talks: Multiple clients sharing projects in real time, plus console session shadowing!
David Bombal
CCNA #035 NAT Troubleshooting Scenario 1 - Can you find the issue? CCNA Exam 200-125 troubleshooting
David Bombal
CCNA #036 NAT Troubleshooting Scenario 2 - Can you find the issue? CCNA Exam 200-125 troubleshooting
David Bombal
GNS3 Talks: ESXi, GNS3 VM and KVM support Part 1: leverage servers and the cloud
David Bombal
CCNA #037 OSPF Troubleshooting - can you find the issue? CCNA Exam 200-125 troubleshooting
David Bombal
GNS3 Talks: ESXi, GNS3 VM and KVM support Part 2: leverage servers and the cloud
David Bombal
CCNA #038 NAT Troubleshooting Scenario 3 - Can you find the issue? CCNA Exam 200-125 troubleshooting
David Bombal
CCNA #039 - OSPF DR, BR and DROTHER Election - do you know the answers?
David Bombal
CCNA #040 NAT Troubleshooting Scenario 4 - Can you find the issue? CCNA Exam 200-125 troubleshooting
David Bombal
GNS3 Talks: Arista vEOS GNS3 import and configuration Part 1
David Bombal
CCNA #041 - OSPF DR, BR and DROTHER Election - do you know the answers?
David Bombal
GNS3 Talks: Arista vEOS GNS3 import and configuration Part 2
David Bombal
GNS3 Talks: ipterm: Linux, Docker, Python, SDN and more! Part 1
David Bombal
More on: Prompting Basics
View skill →Related Reads
📰
📰
📰
📰
Cyber Security:
Medium · Data Science
A Secure Mobile Handoff Checklist for Copilot Conflict Resolution
Dev.to · Roronoa
BitLocker Explained: The Feature That Protects Your Files Even If Your Laptop Is Stolen
Medium · Programming
BitLocker Explained: The Feature That Protects Your Files Even If Your Laptop Is Stolen
Medium · DevOps
🎓
Tutor Explanation
DeepCamp AI