Is there any way that I can get DHCP table? I need to get the IP address (and name or MAC if possible) of all device on the network. Thank you
Is there any way that I can get DHCP table?
|
31.12.2020, 12:14
This depends on what kind of router you have and how easy it is to get information from it. Mikrotik is fully supported, Unify should also be possible via HTTP API. If you want to do presence detection this way you need ARP table instead of DHCP.
(31.12.2020, 12:14)admin Wrote: This depends on what kind of router you have and how easy it is to get information from it. Mikrotik is fully supported, Unify should also be possible via HTTP API. If you want to do presence detection this way you need ARP table instead of DHCP. Can you tell me how to do? I use os.execute('arp -a') or get info from proc/net/arp but they show nothing. I want to find a device that use DHCP (because it doesnt has option to use static IP) and want to find it whenever it's local IP change. Currently I use this code to ping to every IP from 1 to 255 and find it but it's way too slow. So it's best if I can find IP of all device on the network, and look for it by it's name or MAC but I dont know how to do Code: for i = 1, 255 do
31.12.2020, 13:09
This has to be done on your router. See if you can enable a static DHCP entry for a certain MAC.
(31.12.2020, 13:09)admin Wrote: This has to be done on your router. See if you can enable a static DHCP entry for a certain MAC. How can some software like Fing on mobile or Angry IP Scanner can scan all IP in the network so fast, They send some UDP packet and get response I think?. I use packet capture and see that they send request to port 137 (NetBios) of all the IP from .1 to .255 and see the response to see if the IP is available. I want to do something like that, is it possible (31.12.2020, 13:09)admin Wrote: This has to be done on your router. See if you can enable a static DHCP entry for a certain MAC. And the device will be move from house to house, it means that I should write a code to detect the device so I don't need to setup every router that it will be install. Currently I use this code to ping to every IP from 1 to 255 and find it but it's way too slow. So it's best if I can find IP of all device on the network, and look for it by it's name or MAC but I dont know how to do 1
Code: for i = 1, 255 do
04.01.2021, 07:57
You should save the device IP in storage and periodically run the scan via a scheduled scripts to check for IP changes. You should also set a lower value for socket.http.TIMEOUT because default is 60 seconds to speed up the script. Check if your device has a non-standard TCP port open so the scan more consistent, because many network devices can have port 80 open.
Here's a script that can quickly check if any of local IPs have port 80 open: Code: require('socket') (04.01.2021, 07:57)admin Wrote: You should save the device IP in storage and periodically run the scan via a scheduled scripts to check for IP changes. You should also set a lower value for socket.http.TIMEOUT because default is 60 seconds to speed up the script. Check if your device has a non-standard TCP port open so the scan more consistent, because many network devices can have port 80 open. Thank you. I will test it soon It work like a charm
10.01.2021, 12:16
(04.01.2021, 07:57)admin Wrote: You should save the device IP in storage and periodically run the scan via a scheduled scripts to check for IP changes. You should also set a lower value for socket.http.TIMEOUT because default is 60 seconds to speed up the script. Check if your device has a non-standard TCP port open so the scan more consistent, because many network devices can have port 80 open. Is it possible to get Name and MAC adress with this script?
11.01.2021, 08:03
You can get a list table with IP -> MAC mapping from the ARP table like this:
Code: macs = {} Name is a part of DHCP and only the DHCP server / router has this information.
11.01.2023, 13:23
Is there a way to rewrite this where you specify IP and get the Mac address in return?
11.01.2023, 13:26
macs table already contains ip -> mac mapping:
Code: ip = '192.168.0.2'
11.01.2023, 13:30
Many thanks, works great!
|
« Next Oldest | Next Newest »
|