Get all connected device name on the network – Python

Question:

I try to get all connected device name and IP on my network.

I’ve a raspberry pi and I want to use it as a “Network supervisor”. For example if a new device is connected I want to display its IP and name.

I tried some libraries like nmap and scapy but isn’t really what I try to do.

Thanks for your help.

Asked By: amiceli

||

Answers:

You can get the nmap data into python by using subprocess

import subprocess
nmap = subprocess.Popen('nmap', stdout=subprocess.PIPE)
ipout = nmap.communicate()[0]

from there you can use basic python to strip down what you have in ipout and check if there are any differences and if so state those differences.

Answered By: Scott Paterson

Typo @ Scott’s answer, …stdout**=**subprocess.PIPE). I dont have the rep to just comment.

import subprocess
nmap = subprocess.Popen(('nmap'), stdout=subprocess.PIPE)
ipout = nmap.communicate()[
Answered By: MLMiller