Skip to content

Send a set of Cisco commands to Multiple Network Devices from Text Files

License

Notifications You must be signed in to change notification settings

Tes3awy/Send-Config-From-File-To-Devices

Repository files navigation

Tested on Python 3.9.4 Contributions Welcome License Code style: black

Send Cisco Commands to Multiple Network Devices

This program is designed to send a set of Cisco commands to multiple network devices from text files.

This Python script was tested in a physical lab environment and on IOS XE on CSR Latest AlwaysOn v17.3.1 Cisco DevNet Sandbox.

Table of Contents

  1. Installation
  2. Usage
  3. Best Case Scenario
  4. TODO

Installation

$ git clone https://github.com/Tes3awy/Send-Config-From-File-To-Devices.git
$ cd Send-Config-From-File-To-Devices
$ pip install -r requirements.txt

Usage

python main.py

The Python script runs as following:

  1. Reads IP addresses in data/device_ip_list.txt.
  2. Checks if those IP addresses are valid IPv4 addresses using built-in Python3 ipaddress module.
  3. Pings those IP addresses using Ping3 to check reachability.
    • If an IP address is UNREACHABLE for whatever reason, then this IP is added to data/failure.txt with its error message.
    • If an IP address is REACHABLE, then this IP is added to data/success.txt.
  4. Reads each IP addresse in data/success.txt one by one.
  5. Prompts the user to enter a username and a password.

These username and password will be used for all network devices of those IP addresses in data/device_ip_list.txt.

  1. Initiates a Telnet session to each device one by one using Netmiko.
  2. Sends commands from data/config.txt to the device of that IP address.
  3. Saves the configuration on the device.
  4. Terminates the session.

Best Case Scenario

  1. You want to add the same exact set of commands to all the devices in your network. Then this script is the best option for this task.
  2. Username you are logging in with has privilege 15 in it. i.e.
username cisco privilege 15 algorithm-type scrypt secret cisco

This Python script does not check for enable mode. It's left to the user to add the (en)able command at the very top in the data/config.txt file and not set an enable secret command.

TODO

  1. Enable MultiThreading.