By Fathalla Ramadan | March 2026

If you’ve ever thought:

“I wish I didn’t have to log into 10 routers just to check their configs…”

—you’re ready for Netmiko.

Netmiko is a free Python library that lets you automate Cisco (and other vendor) devices using simple scripts. And yes—you can go from zero to working script in under 10 minutes.

As a network architect who’s trained engineers from Alexandria to Riyadh, I’ve seen students use Netmiko to:

All with one script.

In netmiko for beginners guide, you’ll write your first Netmiko script—step by step—even if you’ve never touched Python before.

Prerequisite: You already have Python and Netmiko installed.
If not, see my Install Netmiko on Windows guide first.

Step 1: Set Up a Test Router (in GNS3 with FRRouting/Cisco IOS, CML, or physical gear)

Note: Cisco Packet Tracer does not support SSH and cannot be used with Netmiko.

You’ll need one Cisco router with:

Example config:

enable
configure terminal
username admin privilege 15 secret cisco
ip domain-name lab.local
crypto key generate rsa modulus 1024
line vty 0 4
transport input ssh
login local
exit

Note: Netmiko uses SSH—not Telnet. Make sure SSH is working! You can test manually with:
ssh admin@192.168.1.10

If you don’t have SSH-enabled devices yet, run the script anyway—it will fail to connect, but you’ll still validate your Python syntax. This ‘dry-run’ approach is how many engineers start.

Step 2: Write Your First Script

Open Notepad (or VS Code) and paste this:

# backup_router.py
from netmiko import ConnectHandler

# Define your device
router = {
"device_type": "cisco_ios",
"host": "192.168.1.10",
"username": "admin",
"password": "cisco"
}

# Connect and run a command
net_connect = ConnectHandler(**router)
output = net_connect.send_command("show ip interface brief")

# Print the result
print("=== Interface Status ===")
print(output)

Save it as backup_router.py on your Desktop.

Step 3: Run the Script

  1. Open Command Prompt
  2. Navigate to your Desktop:
    • cd desktop
  3. Run the script:
    • python backup_router.py

If successful, you’ll see:

=== Interface Status ===
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 192.168.1.10 YES manual up up
Loopback0 unassigned YES unset up up

You just automated a real Cisco command—without logging in!

Next: Back Up the Full Config

Modify your script to save the running config:

# Add this after the connection
config = net_connect.send_command("show running-config")
with open("R1-backup.cfg", "w") as f:
f.write(config)
print("**Config backed up to R1-backup.cfg**")

Now you have a real backup—ready for version control or disaster recovery.

Common Errors & Fixes

ErrorLikely CauseFix
AuthenticationExceptionWrong username/passwordDouble-check credentials
NetMikoTimeoutExceptionRouter unreachablePing first; verify IP/SSH
ModuleNotFoundErrorNetmiko not installedRun pip install netmiko

Tip: Always test connectivity with ping and ssh admin@192.168.1.10 first.

Where to Go From Here

Once you’ve mastered this, try:

All 26 guided automation labs—including Lab 26.1: Nightly Backup Script—are in my IP Routing and Switching Lab Handout Book, with validation checklists so you know you’ve done it right.

Final Thought

Automation isn’t about replacing engineers.
It’s about freeing you from repetitive tasks—so you can focus on design, security, and innovation.

And it starts with one script.

You’ve got this.
Fathalla Ramadan
Network Architect & Educator | InstaLumeo

Leave a Reply

Your email address will not be published. Required fields are marked *