Network Automate - 04. Using Netmiko

แชร์
ฝัง
  • เผยแพร่เมื่อ 16 ม.ค. 2025

ความคิดเห็น • 57

  • @rkveni
    @rkveni 7 ปีที่แล้ว +3

    The "attention to details" in every video session is simply superb.... This is a great learning for everyone. Thanks a ton..

  • @sammy242251k
    @sammy242251k 4 ปีที่แล้ว

    I have seen so many documents and videos. But, I think this is the best way to teach "Network Engineers" how to do coding. We all network engineers are used to login into device first and then make changes. That' the way you explain it. I am really thankful of you. Once I know how to login into the Router / Switch, it will be easier to configure them (I hope).

  • @AhmedAli-dz1hy
    @AhmedAli-dz1hy 4 ปีที่แล้ว

    I hope I can get training from you. You are great

  • @Doest700
    @Doest700 5 ปีที่แล้ว

    Great video. Thank you sir!

  • @anonnewuserp9530
    @anonnewuserp9530 4 ปีที่แล้ว

    Hi Greg,
    I have no network devices. Are there any dummy devices that I can use to practice what you have explained?
    Thanks

    • @Grelleum
      @Grelleum  4 ปีที่แล้ว

      Here is a project that attempts to simulate a cisco device:
      github.com/tbotnz/cisgo-ios

    • @anonnewuserp9530
      @anonnewuserp9530 4 ปีที่แล้ว

      Thank you

    • @anonnewuserp9530
      @anonnewuserp9530 4 ปีที่แล้ว

      Sorry, I'm new to this field. Do I need to install git on windows and then clone the repository?
      I installed git on windows and from windows cmd, I did 'git clone github.com/tbotnz/cisgo-ios.git'
      I changed directory to cisgo-ios folder
      As per the instructions from README file, I tried to run the command 'go run cis.go' but I got an error - 'go' is not recognized as an internal or external command
      Am I missing something?
      Thanks

    • @Grelleum
      @Grelleum  4 ปีที่แล้ว

      @@anonnewuserp9530 The application is written in Go (golang), so you would need to have Go installed.
      golang.org/doc/install
      I don't know if cis.go works on Windows. You can certainly try installing running it on Windows.
      You could also try running it on the windows subsystem for linux.
      My recommendation is to install a Linux virtual machine such that you can learn linux at the same time. VirtualBox is a free hypervisor that can run a linux VM. There are thousands of blogs and videos on how to get a linux VM running on VirtualBox on Windows.

    • @Grelleum
      @Grelleum  4 ปีที่แล้ว

      Also - Cisco DevNet has something called sandbox that provides free access to network equipment.
      th-cam.com/video/761glRrJhX4/w-d-xo.html
      developer.cisco.com/site/sandbox/

  • @diazernesto
    @diazernesto 8 ปีที่แล้ว

    Excellent Videos!!! I subscribed your channel, btw is Netmiko an implementation of Paramiko?

    • @Grelleum
      @Grelleum  8 ปีที่แล้ว

      Thank you. Yes, netmiko is a wrapper around paramiko to take the complexity out of establishing a shell to network devices.

  • @anonnewuserp9530
    @anonnewuserp9530 4 ปีที่แล้ว

    Hi Greg,
    Can I use Netmiko to connect to a linux virtual machine on Virtual box and execute linux commands?
    Thanks

  • @GajendraKarle
    @GajendraKarle 8 ปีที่แล้ว

    Thanks Greg. what u will suggest if I install Ubuntu on virtual machine. In that case I can install netmiko in Ubuntu right

    • @Grelleum
      @Grelleum  8 ปีที่แล้ว

      Using a Linux virtual machine is a great way to get your environment setup, as well as being a great way to hone you Linux skills at the same time.
      Once you install Ubuntu, I suggest running the following commands:
      ## update system
      sudo apt-get update
      sudo apt-get -y upgrade
      ## for python3
      sudo apt-get -y install python3-pip python3-paramiko
      sudo pip3 install netmiko
      ## or, if you prefer python2 ...
      sudo apt-get -y install python-pip python-paramiko
      sudo pip install netmiko
      The python3-paramiko package includes all the tricky dependencies (mainly the C crypto library) so once that is installed, installing netmiko should be pretty simple.
      Anytime a new version of netmiko is released, you can update your copy using one of these commands:
      sudo pip3 install --upgrade netmiko ## for python3 users
      sudo pip install --upgrade netmiko ## for python2 users

    • @GajendraKarle
      @GajendraKarle 8 ปีที่แล้ว

      can u plz guide me to set up netmiko in Ubuntu

    • @Grelleum
      @Grelleum  8 ปีที่แล้ว

      The above commands should get it setup for you. If you are using Ubuntu 16.04 or newer and want to run Python version 3, just run these commands:
      sudo apt-get -y install python3-pip python3-paramiko
      sudo pip3 install netmiko
      sudo (superuser do) requires you enter your password.

  • @navyny
    @navyny 6 ปีที่แล้ว

    greg...Is there any way for us to know What ConnectionHandler requires only those specific 4 pieces of information (ip,decice_type, username & password). Or what parameters any object needs as input.

  • @GajendraKarle
    @GajendraKarle 8 ปีที่แล้ว

    Hi Grag,
    I am not able to figure out how to install Netmiko or Paramiko in my windows and ubuntu environment.
    Can you help me out to download the netmiko in windows.

    • @Grelleum
      @Grelleum  8 ปีที่แล้ว

      Installing netmiko in windows is tricky - the toughest part is getting the crypto library installed. I suggest trying the anaconda, or miniconda distributions. www.continuum.io/downloads .. what this does is it installs a complete Python environment that includes a lot of the tricky parts, so for example, the crypto library will also be installed. Once you get that installed, you can simply 'pip install netmiko' and that should work for you.

    • @sammy242251k
      @sammy242251k 4 ปีที่แล้ว

      Use anaconda with Junyper notebook and then add with pip. Its long time you asked but might be helpful

  • @wecare30333333
    @wecare30333333 6 ปีที่แล้ว

    Hi , greg thanks for the video. when I am trying to use connection.send_command('show ip int br') I am facing below error :
    Router prompt not found: could you suggest what could be the problem.

  • @高子健
    @高子健 8 ปีที่แล้ว

    awesome

  • @balajimohanakrishnan743
    @balajimohanakrishnan743 7 ปีที่แล้ว

    Hello Greg, When I am typing the netmiko commands at the python interface, the characters are getting overwritten when I am typing a line which is lengthier, Is there anything that can be done to prevent this from happening?

    • @Grelleum
      @Grelleum  7 ปีที่แล้ว

      Are you accessing the Python interpreter over a serial console? That is the only time I have seen that sort of thing happen, and that is not Python specific. If not via serial console access, then what version of Python are you using and on what operating system?

    • @balajimohanakrishnan743
      @balajimohanakrishnan743 7 ปีที่แล้ว

      From SecureCRT, I am connecting to the GNS3 Ubuntu Docker, I tried to different terminal in the "global options" but I continue to see this problem., Windows 10 is the OS

  • @JohnCosmas
    @JohnCosmas 5 ปีที่แล้ว

    Hi Greg, thanks for the video tutorial. My Netmiko commands work if I use my local loopback IP address and issue commands from Netmiko on my Ubuntu Linux Virtual Machine but not if I use the address of another target Ubuntu Linux Virtual Machine on my Widows Virtual Box. Does that mean I have to also install Netmiko on my target Ubuntu Linux Virtual Machine? Does that machine need to be running a Netmiko program?

    • @Grelleum
      @Grelleum  5 ปีที่แล้ว

      That should not make a difference. Have you verified that you have IP connectivity from one VM to another? Netmiko is just creating an SSH connection to the target machine so as long as you can ssh from your Netmiko VM to you target VM, then it should work.

    • @JohnCosmas
      @JohnCosmas 5 ปีที่แล้ว

      Thanks for the reply.
      This ping proves connectivity to my remote PC:
      floodlight@floodlight:~$ ping 192.168.56.101
      PING 192.168.56.101 (192.168.56.101) 56(84) bytes of data.
      64 bytes from 192.168.56.101: icmp_seq=1 ttl=128 time=0.300 ms
      64 bytes from 192.168.56.101: icmp_seq=2 ttl=128 time=0.299 ms
      64 bytes from 192.168.56.101: icmp_seq=3 ttl=128 time=0.710 ms
      64 bytes from 192.168.56.101: icmp_seq=4 ttl=128 time=1.75 ms
      64 bytes from 192.168.56.101: icmp_seq=5 ttl=128 time=2.44 ms
      ^C
      --- 192.168.56.101 ping statistics ---
      5 packets transmitted, 5 received, 0% packet loss, time 4003ms
      rtt min/avg/max/mdev = 0.299/1.101/2.441/0.856 ms
      floodlight@floodlight:~$
      and this the problem with Netmiko:
      >>> connection = netmiko.ConnectHandler(ip='192.168.56.101',device_type='linux',username='stack',password='stack')
      Traceback (most recent call last):
      File "", line 1, in
      File "/usr/local/lib/python2.7/dist-packages/netmiko/ssh_dispatcher.py", line 228, in ConnectHandler
      return ConnectionClass(*args, **kwargs)
      File "/usr/local/lib/python2.7/dist-packages/netmiko/base_connection.py", line 312, in __init__
      self.establish_connection()
      File "/usr/local/lib/python2.7/dist-packages/netmiko/base_connection.py", line 864, in establish_connection
      raise NetMikoTimeoutException(msg)
      netmiko.ssh_exception.NetMikoTimeoutException: Connection to device timed-out: linux 192.168.56.101:22
      >>> connection = netmiko.ConnectHandler(ip='127.0.0.1',device_type='linux',username='floodlight',password='floodlight')
      >>>
      Should I be using python3?
      thanks and regards John

    • @JohnCosmas
      @JohnCosmas 5 ปีที่แล้ว

      Hi Greg I can also create a SSH session into the target machine regards
      John

    • @Grelleum
      @Grelleum  5 ปีที่แล้ว

      Python2 should work fine with Netmiko.
      Looking at the last line in the traceback:
      netmiko.ssh_exception.NetMikoTimeoutException: Connection to device timed-out: linux 192.168.56.101:22
      This indicates that connection is timing out, which means the TCP handshake is failing, so it looks like connectivity or the inability to open port 22 on that host.
      I suggest running a tcpdump on the ethernet interface of both VMs, use the capture filter "port 22" to limit the traffic.
      something like "tcpdump -nni eth0 port 22" -- this way you should see the TCP handshake from both sides.

    • @JohnCosmas
      @JohnCosmas 5 ปีที่แล้ว

      Thanks Greg it worked when I sorted out port 22.
      Why do I get so many deprecation warnings related to python 2.7 packages? Should I be using different version of Netmiko or Python?

  • @guptarahul97480
    @guptarahul97480 4 ปีที่แล้ว

    where do i get my device_name ? or is it same for all ?

    • @Grelleum
      @Grelleum  4 ปีที่แล้ว

      There is no 'device_name' in the script, perhaps you mean 'device_type'? The device_type depends on the type of device you are trying to connect to. If the device is from Cisco and it is running the Cisco IOS software, then you can set the device_type='cisco_ios'. Also, many network devices use a CLI similar to Cisco IOS, so you are usually safe to use device_type='cisco_ios'.

  • @AJAL9574
    @AJAL9574 7 ปีที่แล้ว

    I did install netmiko ,,,,but when I use it ..it shows Requirement already satisfied: pycparser in /usr/local/lib/python3.4/dist-packages (from cffi>=1.4.1->cryptography>=1.1->paramiko>=1.13.0->netmiko)
    import netmiko
    ImportError: No module named netmiko

    • @Grelleum
      @Grelleum  7 ปีที่แล้ว

      Several people have reported something like this. I suspect it could be an issue of installing netmiko to a different copy of python than the one you are using.
      I see that netmiko is installed to your python 3.4 installation. Do you have this issue if you start python by running the command python3.4 ?

    • @AJAL9574
      @AJAL9574 7 ปีที่แล้ว

      well .. I tried to remove/uninstall that module and reinstall it again ....sometimes there is broken modules, or they break while setting up the environment ..so its fine now except this error (AttributeError: 'module' object has no attribute 'connectHandler')

    • @Grelleum
      @Grelleum  7 ปีที่แล้ว +1

      ConnectHandler should be upper case 'C'
      I think I am going to recommend that people use anaconda or miniconda for python - it installs the dependencies and does a good job managing those.

    • @AJAL9574
      @AJAL9574 7 ปีที่แล้ว

      Thanks a lot,,u r right

  • @AhmedAli-dz1hy
    @AhmedAli-dz1hy 4 ปีที่แล้ว

    Can I have your email please. I have some questions. I hope you accept that

  • @mirabella1284
    @mirabella1284 ปีที่แล้ว

    why evry time i try to run this command "connection.send_command('show ip int brief)" its shows [
    Command 'show' not found, but can be installed with:

    apt install mailutils-mh # version 1:3.7-2.1, or
    apt install mmh # version 0.4-2
    apt install nmh # version 1.7.1-6

    root@eve-ng:~] i tried to install like it say but it's not working anyway