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.

how to know current ip and gateway?
#1
Hi, how I can get the current gateway when LM is in DHCP?

Thanks

Peppe
Reply
#2
Use this:
Code:
routes = io.readproc('route')
gateway = routes:match('default%s+([%d%.]+)')

ifinfo = require('ifinfo')()
ip = ifinfo.eth0.inetaddr

log(ip, gateway)

If DHCP is used it is highly recommended to use a static IP-MAC binding so LM IP cannot change randomly.
Reply
#3
(05.03.2024, 06:18)admin Wrote: Use this:
Code:
routes = io.readproc('route')
gateway = routes:match('default%s+([%d%.]+)')

ifinfo = require('ifinfo')()
ip = ifinfo.eth0.inetaddr

log(ip, gateway)

If DHCP is used it is highly recommended to use a static IP-MAC binding so LM IP cannot change randomly.

Thanks

Peppe
Reply


Forum Jump: