This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm that you accept these cookies being set.

Is there any way that I can get DHCP table?
#3
(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
  ip = '192.168.1.' .. i
  res = os.execute('ping -c 2 -W 1 ' .. ip)
  if res == 0 then
    url='http://'..ip..'/httpapi.asp?command=getPlayerStatus'
    require('socket.http')
    res, err = socket.http.request(url)
    if res ~= nil then
      t1, t2 = string.find(res, 'Artist')
      if t1 ~= nil then
          --my code
      break
   end
  end
 end
Reply


Messages In This Thread
RE: Is there any way that I can get DHCP table? - by pouralise - 31.12.2020, 13:06

Forum Jump: