Mastering Python networking: advanced networking with Python 9781784397005, 1784397008

Become an expert in implementing advanced, network-related tasks with Python. About This Book - Build the skills to perf

626 113 10MB

English Pages viii, 426 pages: illustrations; 24 cm [573] Year 2017

Report DMCA / Copyright

DOWNLOAD PDF FILE

Table of contents :
Preface......Page 25
What this book covers......Page 26
What you need for this book......Page 29
Who this book is for......Page 30
Conventions......Page 31
Reader feedback......Page 33
Customer support......Page 34
Downloading the example code......Page 35
Downloading the color images of this book......Page 36
Errata......Page 37
Piracy......Page 38
Questions......Page 39
Review of TCP/IP Protocol Suite and Python Language......Page 40
The internet overview......Page 41
Servers, hosts, and network components......Page 42
The rise of datacenter......Page 43
Enterprise datacenters......Page 44
Cloud datacenters......Page 45
Edge datacenters......Page 47
The OSI model......Page 48
Client server models......Page 50
Network protocol suites......Page 51
The Transmission Control Protocol (TCP)......Page 52
Functions and Characteristics of TCP......Page 53
TCP messages and data transfer......Page 54
User Datagram Protocol (UDP)......Page 55
The Internet Protocol (IP)......Page 57
The IP NAT and security......Page 59
IP routing concepts......Page 60
Python language overview......Page 61
Python versions......Page 63
Operating system......Page 64
Running a Python program......Page 65
Python built-In types......Page 67
The None type......Page 68
Numerics......Page 69
Sequences......Page 70
Mapping......Page 73
Sets......Page 74
Python operators......Page 75
Python control flow tools......Page 76
Python functions......Page 78
Python classes......Page 79
Python modules and packages......Page 80
Summary......Page 82
Low-Level Network Device Interactions......Page 83
The challenges of CLI......Page 84
Constructing a virtual lab......Page 86
Cisco Virtual Internet Routing Lab (VIRL)......Page 88
VIRL tips......Page 90
Cisco DevNet and dCloud......Page 93
GNS3......Page 96
Python Pexpect Library......Page 98
Installation......Page 99
The Pexpect overview......Page 100
Our first Expect program......Page 104
More Pexpect features......Page 105
Pexpect and SSH......Page 107
Putting things together for Pexpect......Page 108
The Python Paramiko library......Page 110
Installating Paramiko......Page 111
The Paramiko overview......Page 112
Our first Paramiko program......Page 115
More Paramiko features......Page 117
Paramiko for Servers......Page 118
Putting things together for Paramiko......Page 120
Looking ahead......Page 122
Downsides of Pexpect and Paramiko compared to other tools......Page 123
Idempotent network device interaction......Page 124
Bad automation speeds bad things up......Page 125
Summary......Page 126
API and Intent-Driven Networking......Page 127
Infrastructure as the Python code......Page 129
Screen scraping versus API structured output......Page 130
Data modeling for infrastructure as code......Page 134
The Cisco API and ACI......Page 136
Cisco NX-API......Page 137
Lab Software Installation and Device Preparation......Page 138
NX-API examples......Page 139
Cisco and YANG model......Page 144
The Cisco ACI......Page 146
The Python API for Juniper networks......Page 148
Juniper and NETCONF......Page 149
Device Preparation......Page 150
Juniper NETCONF examples......Page 152
Juniper PyEZ for developers......Page 154
Installation and preparation......Page 155
PyEZ examples......Page 158
The Arista Python API......Page 161
The Arista eAPI management......Page 163
The eAPI preparation......Page 164
eAPI examples......Page 168
The Arista Pyeapi library......Page 171
The Pyeapi installation......Page 172
Pyeapi examples......Page 173
Vendor neutral libraries......Page 176
Summary......Page 177
The Python Automation Framework - Ansible Basics......Page 178
A quick Ansible example......Page 181
The control node installation......Page 182
Your first Ansible playbook......Page 184
The Public key authorization......Page 185
The inventory file......Page 186
Our first playbook......Page 188
The advantages of Ansible......Page 191
Agentless......Page 192
Idempotent......Page 193
Simple and extensible......Page 194
The vendor Support......Page 196
The Ansible architecture......Page 198
YAML......Page 200
Inventories......Page 201
Variables......Page 203
Templates with Jinja2......Page 207
Ansible networking modules......Page 208
Local connections and facts......Page 209
Provider arguments......Page 210
The Ansible Cisco example......Page 212
The Ansible Juniper example......Page 215
The Ansible Arista example......Page 217
Summary......Page 219
The Python Automation Framework - Ansible Advance Topics......Page 220
Ansible conditionals......Page 221
The when clause......Page 222
Network module conditional......Page 225
Ansible loops......Page 227
Standard loops......Page 228
Looping over dictionaries......Page 230
Templates......Page 232
The Jinja2 template......Page 234
Jinja2 loops......Page 235
The Jinja2 conditional......Page 236
Group and host variables......Page 238
Group variables......Page 239
Host variables......Page 240
The Ansible vault......Page 241
The Ansible include and roles......Page 243
The Ansible include statement......Page 244
Ansible roles......Page 246
Writing your own custom module......Page 250
The first custom module......Page 251
The second custom module......Page 253
Summary......Page 255
Network Security with Python......Page 256
The lab setup......Page 257
Python Scapy......Page 261
Installing Scapy......Page 262
Interactive examples......Page 263
Sniffing......Page 265
The TCP port scan......Page 266
The ping collection......Page 270
Common attacks......Page 272
Scapy resources......Page 273
Access lists......Page 274
Implementing access lists with Ansible......Page 276
MAC access lists......Page 280
The syslog search......Page 281
Searching with regular expressions......Page 283
Other tools......Page 285
Private VLANs......Page 286
UFW with Python......Page 288
Summary......Page 290
Network Monitoring with Python - Part 1......Page 291
Lab setup......Page 293
SNMP......Page 294
Setup......Page 296
PySNMP......Page 298
Python visualization......Page 303
Matplotlib......Page 304
Installation......Page 305
Matplotlib - the first example......Page 306
Matplotlib for SNMP results......Page 308
Additional Matplotlib resources......Page 313
Pygal......Page 314
Installation......Page 315
Pygal - the first example......Page 316
Pygal for SNMP results......Page 318
Additional Pygal resources......Page 321
Python for Cacti......Page 322
Installation......Page 323
Python script as an input source......Page 325
Summary......Page 327
Network Monitoring with Python - Part 2......Page 328
Graphviz......Page 330
Lab setup......Page 331
Installation......Page 333
Graphviz examples......Page 334
Python with Graphviz examples......Page 337
LLDP neighbor graphing......Page 338
Information retrieval......Page 340
Python parser script......Page 341
Final playbook......Page 345
Flow-based monitoring......Page 347
NetFlow parsing with Python......Page 349
Python socket and struct......Page 351
ntop traffic monitoring......Page 354
Python extension for ntop......Page 357
sFlow......Page 361
SFlowtool and sFlow-RT with Python......Page 362
Elasticsearch (ELK stack)......Page 366
Setting up a hosted ELK service......Page 367
The logstash format......Page 369
Python helper script for Logstash formatting......Page 370
Summary......Page 372
Building Network Web Services with Python......Page 373
Comparing Python web frameworks......Page 375
Flask and lab setup......Page 378
Introduction to Flask......Page 380
The HTTPie client......Page 382
URL routing......Page 384
URL variables......Page 385
URL generation......Page 386
The jsonify return......Page 387
Network static content API......Page 388
Flask-SQLAlchemy......Page 389
Network content API......Page 391
Devices API......Page 395
The device ID API......Page 397
Network dynamic operations......Page 398
Asynchronous operations......Page 401
Security......Page 404
Additional resources......Page 407
Summary......Page 409
OpenFlow Basics......Page 410
Lab setup......Page 413
Introducing OpenFlow......Page 417
Basic operations......Page 419
OpenFlow 1.0 vs 1.3......Page 424
Mininet......Page 425
The Ryu controller with Python......Page 428
Open vSwitch commands......Page 431
The Ryu firewall application......Page 434
Layer 2 OpenFlow switch......Page 437
Planning your application......Page 438
Application components......Page 440
The POX controller......Page 446
Summary......Page 448
Advanced OpenFlow Topics......Page 449
Setup......Page 450
OpenFlow operations with Ryu......Page 451
Packet inspection......Page 454
Static router......Page 456
Mininet topology......Page 457
Ryu controller code......Page 459
Ryu flow installation......Page 461
Ryu packet generation......Page 464
Final result......Page 466
Router with API......Page 471
Ryu controller with API......Page 472
API usage examples......Page 475
BGP router with OpenFlow......Page 478
Lab router setup......Page 479
Python with the BGP speaker library......Page 481
Ryu BGP application......Page 484
Firewall with OpenFlow......Page 487
Summary......Page 490
OpenStack, OpenDaylight, and NFV......Page 491
OpenStack......Page 493
OpenStack overview......Page 494
Networking in OpenStack......Page 499
Trying out OpenStack......Page 505
OpenDaylight......Page 510
OpenDaylight programming overview......Page 512
OpenDaylight example......Page 514
Summary......Page 521
Hybrid SDN......Page 522
Preparing the network......Page 525
Familiarize yourself with the existing framework and tools......Page 526
Network standardization......Page 527
Create minimum viable products......Page 528
Relentlessly experiment......Page 529
Greenfield deployment......Page 530
Controller redundancy......Page 532
Multiple controller example......Page 533
BGP migration example......Page 537
Migration segmentation......Page 538
VIRL and Mininet setup......Page 540
Cisco device configuration......Page 542
Ryu BGP speaker......Page 544
Mininet and REST Router......Page 547
Result and verification......Page 550
More BGP example......Page 552
Examine the JSONRPC over WebSocket......Page 556
Monitoring integration......Page 558
Secure TLS connection......Page 561
Physical switch selection......Page 564
Lab OpenFlow switches......Page 566
Incumbent vendor switches......Page 569
Whitebox Switches......Page 571
Summary......Page 573

Mastering Python networking: advanced networking with Python
 9781784397005, 1784397008

  • 0 0 0
  • Like this paper and download? You can publish your own PDF file online for free in a few minutes! Sign Up
File loading please wait...
Recommend Papers