Professional Documents
Culture Documents
Python App#3: DHCP client simulator for testing a DHCP server in the local
network.
Python App#5: OSPF network discovery via SNMP. Building the OSPF
topology.
Sounds unbelievable given your current programming experience? Well, it's true! How?
First, you will learn and practice every Python key concept, which is explained in one or
more video lectures, followed by a short quiz. Each video is filled with relevant
examples, in a learn-by-doing fashion and the quizzes will help you consolidate the
main ideas behind each Python topic.
After laying the foundation (and also exploring some advanced Python topics), you will
dive right into the real-life network scenarios and apply your knowledge to build 7
great network tools.
Equipped with working files, network topologies and Python code samples (in .pdf and
.py formats), you will be able to work alongside me on each lecture and each
application. I will provide a virtual machine with all the Python modules already installed
and also the full code for each application, so you can save time and start coding
and testing on the spot.
We will use emulated routers in GNS3 to test our Python apps in a network
environment, so you can see the actual results of running your code.
I encourage you to learn Python, an amazingly beginner-friendly programming
language and take your (networking) job to a higher level of automation.
except IOError:
print "Input parameter error! Please check username, password and file name."
username = selected_user_file.readlines()[0].split(',')[0]
password = selected_user_file.readlines()[0].split(',')[1]
session.set_missing_host_key_policy(
paramiko.AutoAddPolicy())
connection = session.invoke_shell()
except paramiko.AuthenticationException:
print "* Invalid username or password. \n* Please check the username/password
file or the device configuration!"
print "* Closing program...\n"
10
#SNMP function
def snmp_get(ip):
errorIndication,
errorStatus,
errorIndex,
cmdGen.nextCmd(cmdgen.CommunityData(comm),
varBindNbrTable
cmdgen.UdpTransportTarget((ip,
161)),
'1.3.6.1.2.1.14.10.1.3')
11
#print
cmdGen.nextCmd(cmdgen.CommunityData(comm),cmdgen.UdpTransportTarget((ip,
161)),'1.3.6.1.2.1.14.10.1.3')
#print varBindNbrTable
errorIndication,
errorStatus,
errorIndex,
cmdGen.nextCmd(cmdgen.CommunityData(comm),
varBindNbrIpTable
cmdgen.UdpTransportTarget((ip,
161)),
'1.3.6.1.2.1.14.10.1.1')
#print varBindNbrIpTable
errorIndication,
errorStatus,
errorIndex,
cmdGen.nextCmd(cmdgen.CommunityData(comm),
varBindHostTable
cmdgen.UdpTransportTarget((ip,
161)), '1.3.6.1.4.1.9.2.1.3')
#print varBindHostTable
errorIndication,
errorStatus,
errorIndex,
cmdGen.nextCmd(cmdgen.CommunityData(comm),
varBindHostIdTable
cmdgen.UdpTransportTarget((ip, 161)),
'1.3.6.1.2.1.14.1.1')
#print varBindHostIdTable
12
13
Then, at line 80, the user is asked to enter the number of packets he wishes to be
captured by the sniffer:
pkt_to_sniff = raw_input("Enter the number of packets to capture (0 is infinity): ")
At line 92, the program requires the number of seconds to run the capture:
time_to_sniff = raw_input("* Enter the number of seconds to run the capture: ")
At line 103, the program asks the user for the protocol to filter the packets by:
proto_sniff = raw_input("* Enter the protocol to filter by (arp|bootp|icmp|0 is all):
")
Lines 115 and 116 are dedicated to choosing the file name and creating the file, by
opening it for writing (w):
file_name = raw_input("* Please give a name to the log file: ")
sniffer_log = open(file_name, "w")
At line 124, you can find the function that takes care of the parameter extraction from
each packet and logging the packet info to the file: def packet_log(pkt)
The program implements a counter for each packet, then records the source MAC
address and destination MAC address to the file, on a single row.
Finally, the sniffing process is initialized by the sniff() function in Scapy, at line 138,
passing the values collected from the user as arguments to this function.
pkt = sniff(iface=net_iface, count=int(pkt_to_sniff), timeout=int(time_to_sniff),
prn=packet_log)
Now, to test the program, first you should have direct connectivity from the Debian VM
to the router in GNS3 (R1 - 192.168.2.101 was my test device):
root@debian:/home/debian/workingdir# ping 192.168.2.101
PING 192.168.2.101 (192.168.2.101) 56(84) bytes of data.
64 bytes from 192.168.2.101: icmp_req=1 ttl=255 time=429 ms
14
Lets choose ICMP packets for capturing purposes and after the capture is started, I am
going to ping the VM (192.168.2.100) from R1.
Please see the following way to use the program menu as an example:
15
16
17
18
Now, lets make a quick test. If you have just started the router and made no config yet,
then the startup-config and running-config are the same. No surprise here. But, to make
the test more relevant, lets configure a few things before starting the comparison,
without saving the changes to the startup-config. So, lets go to router R1:
R1(config)#username udemy1 password udemy
R1(config)#username udemy2 password udemy
R1(config)#username udemy3 password udemy
Now, these three configurations are the differences between the startup-config and the
running-config. We should see them after running our program, saved in
the file_diff.txt file. Lets test this:
root@debian:/home/debian/workingdir# python ConfigFileComp.py
Use this tool to:
1 - Compare running-config with startup-config
2 - Compare running-config with local file
3 - Compare startup-config with local file
e - Exit program
Enter your choice: 1
Enter an IP address: 192.168.2.101
Please wait while the config file is being analyzed...
Use this tool to:
1 - Compare running-config with startup-config
2 - Compare running-config with local file
3 - Compare startup-config with local file
e - Exit program
Enter your choice: e
Exiting... See ya...
Now lets check the results. We should see all three commands with a +sign, right?
root@debian:/home/debian/workingdir# cat file_diff.txt
+username udemy1 password 0 udemy
19
20
"I've seen the blueprint and some demo videos and I was convinced right away.
Without a doubt, it's one of the best trainings a network engineer can have. It
gives you actual valuable and marketable skills that you can use in your daily job.
Mihai explains the topics really well, with practical examples making it a fun way
to learn. Highly recommended." by Vlad Vlaicu
"There is no major prerequisite and the material is hand-on from the go. Besides
new lectures are being uploaded in response to suggestions and discussions." by
Zafar Iqbal
"I've [been] doing many Python courses, but till now this is the best by far. Very
self paced, Mihai explains each step in a very simple manner that any beginner
could understand. The courses approach for me is the best. Very oriented to real
application development. Very good, would recommend to anyone beginning in
python." by Felipe
21
"As always for learning programming language I would always recommend going
through a well rated tutorial video lecture series than going through a 1000 page
text. A well designed course can impart knowledge at a much faster rate and with
less effort from the listener. Of course the course has to fantastically designed.
And this course is just that, that lectures are easy to comprehend, the concepts
are thoroughly learnt using simple & effective examples. So I highly recommend
this course." by Musarrat Rahman
"I find this course very useful for beginners in programming or for those who
especially want to learn Python/networking. I think a new language is learned
more practicing, and this course has many practical examples with clear
explanations." by Mihaela Dvornic
"I have been programming since 1978 and wanted to learn python. I have had no
java or OOP experience, and I tried several 'paper' tutorials but got little out of
them. The first part of this course is a steady walk through the Python language
at just the right speed. The instructor seems to touch all the basis in a logical and
methodical way while providing examples and explanations. I can only conclude
the instructor is a professional educator who spent considerable time structuring
and organizing the course. The result is evident. THIS IS A GREAT WAY TO
LEARN PYTHON!" by Larry Laswell
"I've tried learning from the books & multiple videos - most were too basic to
make a practical app. Some books were too thick and made me sleep. But still
none of the materials had the perfect balance like this course where all the basics
were covered, instructions were concise, and Mihai walks you through how to
create 5 practical apps step by step. I've also tried reading some advanced
python book which didn't make sense because it was too advanced. Let me tell
you, this is hands down "that course that takes you up to beyond the basics" to
bridge you to the advance topics. Right now I'm hitting the advanced topics and it
finally makes sense..." by Joon Park
22
"Usually I'm not doing courses review but this time I will make an exception.
During time I took a lot of trainings but very few provided by Udemy proved as
having the right approach in teaching the audience. I will mark this one as being
one of my personal top three best trainings as content's quality, technical
explanations, and additional learning materials perspective. Long story short this
course is a very simple, straight forward way of learning Python for managing IT
networks." by Johnny Stanescu
Great course for beginners. Mihai is very straight forward, he doesnt beat
around the bush, and the applications that he builds during the course are
priceless if you are a network engineer. Fully recommend it. by Joo Paulo
Barcelos
Mihai is very knowledgeable and a valuable instructor. His lessons are clear,
easy to follow along with, easy to understand, and interesting. The flow of the
course is very good. He spends sufficient time on each subject to teach them
well, but not so much time that you get bored. The additional resources that he
provides, including a pre-built Debian VM image, shows his dedication to helping
students get started and move through the course easily so that the subject of
the class can be the focus.I highly recommend this class and anything else Mihai
is teaching. by Dennis Werthman
23
I encourage you to take your networking job to a higher level of automation, thus
allowing you to save time and take care of complex network issues or improvements.
Enroll NOW and hop on the Python network programming train. Let's get started!
24
Still not convinced? Check out some free preview videos from the course on my
YouTube channel, before you spend your money on it! Seems fair.
Go to the YouTube channel: https://www.youtube.com/c/MihaiCatalinTeodosiu
Go right to the Python Tutorial: Python Network Programming - Build 7 Apps Playlist:
https://www.youtube.com/playlist?list=PLYifE5kLxky4v9ZBbCX9ftGWT8gBSwvi0
*** For the FULL course with LIFETIME ACCESS please use the link below! ***
*** The course also comes with a 95% DISCOUNT! Buy now to SAVE $284! ***
*** Limited Time Offer On My Official Website ***
25