Start a Conversation

Solved!

Go to Solution

824

September 26th, 2022 07:00

Python scripting with dell n-series switch, mapping connected devices

Hi all,

I'm trying to write a python script to extract connected clients from a dell n2000 series switch, no luck at this stage... I use to use switch miner in the past for Cisco extraction to detect the phones connected to what port of the switch but im unable to achieve this with dell. Has anyone tried to get an export of all connected devices from a dell switch?

10 Posts

October 2nd, 2022 01:00

Solution, make sure switchport loop guard is not enabled per interface. 

10 Posts

September 26th, 2022 18:00

Okay, Managed to get it working thanks to this youtube channel. However, the powerconnect 8024F I am unable to authenticate with at the moment... Now the challenge of marrying up ports to IP address. This was the script:

from netmiko import ConnectHandler
from netmiko import NetmikoTimeoutException
from paramiko.ssh_exception import SSHException
from paramiko.ssh_exception import AuthenticationException
import time
import datetime
#Types:
#dell_dnos9
#dell_force10
#dell_isilon
#dell_os10
#dell_os6
#dell_os9
#dell_powerconnect
#dell_sonic
TNOW = datetime.datetime.now().replace(microsecond=0)
IP_LIST = open('DellNseries_devices') #just a file with the IP addresses
TNOW=TNOW.strftime("%d%b%Y")
for IP in IP_LIST:
    print ('\n #### Connecting to the Switch '+ IP.strip() + ' #### \n' )
    RTR = {
    'ip':   IP,
    'username': 'username', #Set username 
    'password': 'password#', #Set password
    'device_type': 'dell_os6',
    }

    try:
        net_connect = ConnectHandler(**RTR)
    except NetmikoTimeoutException:
        print ('Device not reachable')
        continue
    except AuthenticationException:
        print ('Failed to Authenticate')
        continue
    except SSHException:
        print ("Make sure SSH is enabled in device.")
        continue

    print ('Initiating backup')
    net_connect.enable()
    output = net_connect.send_command('show startup-config')
    IP=IP.strip()
    SAVE_FILE = open(IP +'_'+TNOW,'w')
    SAVE_FILE.write(output)
    SAVE_FILE.close
    print ('Exporting macaddress table')
    output = net_connect.send_command('show mac address-table vlan 1')
    SAVE_FILE = open(IP +'_'+TNOW+"MacTable",'w')
    SAVE_FILE.write(output)
    SAVE_FILE.close
    print ('Exporting ARP for IP')
    output = net_connect.send_command('show arp')
    SAVE_FILE = open(IP +'_'+TNOW+"ARP",'w')
    SAVE_FILE.write(output)
    SAVE_FILE.close

10 Posts

September 26th, 2022 22:00

Okay, I have a problem
The MAC address shown to be plugged into the gigabit port is different the the mac address of the actual device. When I show arp, the device doesnt appear but when I ping the IP address it then shows in arp but the mac address table is still the wrong mac

No Events found!

Top