This project demonstrates foundational Network Automation using Python and the Netmiko library. The primary goal is to manage a Cisco router (IOSv-Router) programmatically from a Linux control node (Control-Node) via SSH.
- Data Retrieval: Programmatically collect operational data (active interfaces) and save it locally.
- Configuration Deployment: Push standard configuration commands (Loopback interface setup) from a local file.
| File Name | Description |
|---|---|
IOSv-Router1_config.txt |
The complete running configuration required for IOSv-Router (includes SSH, management IP, and user credentials). |
gns3_portable_project.gns3project |
The topology file containing the Router, EtherSwitch, and VM nodes with correct interconnectivity. |
automate.py |
The script that handles SSH connection, executes show commands, saves output, and pushes configuration commands. |
commands_file.txt |
Configuration commands to create Loopback111 (10.111.111.111/24). |
requirements.txt |
Contains netmiko. Used to quickly install dependencies on the VM. |
- Load Project: Open GNS3 and go to File > Open portable project...
- Select
gns3_portable_project.gns3project. - Ensure the necessary appliance images (Cisco IOSv and Ubuntu/Arch VM) are linked and available in your GNS3 setup.
- Start all nodes (IOSv-Router, EtherSwitch, Control-Node).
The easiest way to configure IOSv-Router is to paste the prepared configuration.
- Open the console for IOSv-Router.
- Enter privileged EXEC mode:
enable configure terminal - Copy all content from the provided
IOSv-Router1_config.txtfile. - Paste the entire content into the IOSv-Router console and wait for the commands to process.
- Save the configuration:
end write memory
Step 3: Prepare the Control-Node (IPs, secrets, passwords and other valuez can vary depending on your case!)
- Open the console for the Control-Node.
- Configure the static IP (
192.168.1.10/24) and ensure connectivity to IOSv-Router (192.168.1.1).- Verification:
ping 192.168.1.1should succeed.
- Verification:
- Install Dependencies: Use the
requirements.txtfile to install Netmiko.# Install pip and update packages first (if not already done) sudo apt update sudo apt install python3-pip -y # Install Netmiko using the requirements file pip install -r requirements.txt
- Copy the script files (
automate.pyandcommands_file.txt) from your host machine into a directory on the Control-Node.
- Navigate to the directory containing the Python script on the Control-Node.
- Execute the automation script:
python3 automate.py
- When prompted, enter the router password (e.g.,
1234).
| Task | Command to Verify | Expected Result |
|---|---|---|
| Data Retrieval | On the VM: cat interface_list.txt |
File contains the output of show ip interface brief | include up. |
| Config Deployment | On IOSv-Router: show run interface Loopback111 |
Interface exists with IP 10.111.111.111/24 and the correct description. |
| Connectivity | On the VM: ping 10.111.111.111 |
Ping should succeed, confirming the loopback is configured and reachable. |

