Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python: to scan all IP devices connected in LAN

How to display all device IP address,Host Name, Manufacture Name,Physical address etc which are connected in LAN using python programming.

With help of arp - a I am able to get IP address mac and type(As shown below)enter image description here

but not able to get Manufacture Name and Host name I want to display the list as thisenter image description here

like image 368
SHIVA73 Avatar asked Jul 15 '26 11:07

SHIVA73


1 Answers

You can find Host Name using Following Method:

import socket
# Replace with your ip address
ip_address = "192.168.221.31"
print(socket.getfqdn(ip_address))

Use Following Code to find Manufacture name from mac address

import requests
 
for addr in ['B4:CD:27:81:F4:1C']:
        
    vendor = requests.get('http://api.macvendors.com/' + addr).text
    print(addr, vendor)

Note: For above method internet connectivity is required

like image 194
Amal Mathew Avatar answered Jul 18 '26 03:07

Amal Mathew