I’m a total network noob, so bear with me here. I need to be able to SSH into a virtual router inside a GNS3 network, from outside – that will be done through Python, using Netmiko. I’m running GNS3 on Linux. Everything I’ve done so far rendered no results: Python isn’t able to find the router.

Using a CISCO C7200 image, my topology is a Cloud node connected to a C7200 router.
This is the output of my ip addr show:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
2: wlp0s20f3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default qlen 1000
3: br-27b59ae2904c: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 
4: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default 

I tried connecting the router’s 0/0 to both the WiFi adapter (wlp0s20f3) and the loopback adapter in the Cloud node, but regardless of the connection, when I tried pinging from a Linux terminal the IP address I had set inside the router interface, nothing happened.

The commands I’m running (0/0 connected to lo):

conf t
interface Fa0/0
ip address
no shut
hostname R1
ip domain-name local
crypto key generate rsa (I'm using 2048 bits).
ip ssh version 2
line vty 0 4
transport input ssh
login local
username admin password 1234

The Python code:

from netmiko import ConnectHandler

router = {  
    'device_type': 'cisco_ios',
    'host':   '',
    'username': 'admin',
    'password': '1234',

net_connect = ConnectHandler(**router)

The output:

netmiko.exceptions.NetmikoTimeoutException: TCP connection to device failed.

Common causes of this problem are:
1. Incorrect hostname or IP address.
2. Wrong TCP port.
3. Intermediate firewall blocking access.

Device settings: cisco_ios

I know that I lack some core networking knowledge, but I suppose it shouldn’t been this hard. Ironically, everyone seems to do this inside Windows, so I guess I should just move on to Windows.

Leave a Reply

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