5 Replies Latest reply: Sep 26, 2019 8:16 AM by Rishabh RSS

    IOS for Python & GNS3

    Mohd

      Hi All,

       

      I am trying to connect Python with GNS3, But I struck, when I make link or connection with IOS/GNS3.

      can anyone tell me which(types) of IOS should I use, to make communication with my Python program OR How can I connect GNS3 with Python.

      Thanks all.

      Best wishes

        • 1. Re: IOS for Python & GNS3
          Martin

          not sure if u can; have u tried search this on gns3 forum ? let us know if u find solution

          • 2. Re: IOS for Python & GNS3
            Phoenix

            Hi Mohd,

             

            I tried IOSv with python code running in linux. It worked perfectly..just a simple topology like this below

             

            1.JPG

             

            1. At first, enable SSH login into the router..Because I'll use a python package to  ssh into router and run show commands.

            2. After that, you have to install python in linux . Also need another python package called netmiko to establish the connection..There are several other way to connect router using python..but I found this package very easy to use and configure..

            3. Confirm the connectivity is working between router and linux vm( check ssh login into router from linux )

             

            Sample Python code:

            2.png

            Results:


            just ran a show command and print that output into my linux console.. 

            3.png

             

            Hope this helps

            • 3. Re: IOS for Python & GNS3
              Mohd

              PhoenixHello

              Thank you, i will try, I have windows os.

              • 4. Re: IOS for Python & GNS3
                Phoenix

                Hi Mohd,

                 

                This code will work from windows as it is..you don't have to change anything at all in the python code or in the router..

                Just have to install python and netmiko (pip install netmiko) on windows as we did on linux..and you'll get similar output

                 

                py-code.JPG

                • 5. Re: IOS for Python & GNS3
                  Rishabh

                  Have you verified basic connectivity?

                  Run ifconfig on your Linux box and verify is ip is configured and connected to same network as configured on iOS router

                  On a side note, you should try using Network Automation appliance of GNS3 which has inbuilt netmiko and paramiko installed. No need to use big Linux image.