Community discussions

MikroTik App
t3wera
newbie
Topic Author
Posts: 35
加入: Mon Mar 02, 2009 2:39 am

script remove none host name from dhcp lease

Thu Dec 06, 2012 6:51 pm

嘿,一个ll
i can`t complete this one
Code:Select all
/ip dhcp-server lease remove [find host-name=none]
none = there no active host name:lol:
Top
用户头像
nest
Forum Veteran
Forum Veteran
Posts: 820
加入: Tue Feb 27, 2007 1:52 am
Location:UK
Contact:

Re: script remove none host name from dhcp lease

Thu Dec 06, 2012 6:59 pm

what happens when you use
Code:Select all
/ip dhcp-server lease remove [find host-name=""]
Top
t3wera
newbie
Topic Author
Posts: 35
加入: Mon Mar 02, 2009 2:39 am

Re: script remove none host name from dhcp lease

Thu Dec 06, 2012 7:08 pm

no thin
i also try
Code:Select all
/ip dhcp-server lease remove [find host-name=]
Code:Select all
/ip dhcp-server lease remove [find host-name="none"]
i have machines that changed mac address it lossing me more ips in my dhcp
i can know them with no host name
iwant who haven`t host name
Last edited byt3weraon Thu Dec 06, 2012 7:25 pm, edited 1 time in total.
Top
用户头像
nest
Forum Veteran
Forum Veteran
Posts: 820
加入: Tue Feb 27, 2007 1:52 am
Location:UK
Contact:

Re: script remove none host name from dhcp lease

Thu Dec 06, 2012 7:25 pm

just tried a few various ideas and it looks like a "feature":-(
Top
t3wera
newbie
Topic Author
Posts: 35
加入: Mon Mar 02, 2009 2:39 am

Re: script remove none host name from dhcp lease

Thu Dec 06, 2012 7:31 pm

ican`t do nothin in scripts so i need help:lol:only ineed remove who haven`t active host name
can u help
Top
用户头像
skot
Long time Member
Long time Member
Posts: 584
加入: Wed Nov 30, 2011 3:05 am

Re: script remove none host name from dhcp lease

Fri Dec 07, 2012 9:29 am

Try something like this. If length of host-name is zero, remove it.
Code:Select all
foreach i in=[/ip dhcp-server lease find] do={ :if ([:len [/ip dhcp-server lease get $i host-name]] = 0) do={ /ip dhcp-server lease remove $i; } }
Top
t3wera
newbie
Topic Author
Posts: 35
加入: Mon Mar 02, 2009 2:39 am

Re: script remove none host name from dhcp lease

Sat Dec 08, 2012 3:00 pm

worked thanx
Top
mwe4memo
刚刚加入了
Posts: 1
加入: Sun Aug 30, 2015 4:05 pm

Re: script remove none host name from dhcp lease

Sun Aug 30, 2015 4:09 pm

/system script
add comment="\CD\D0\DD \C7\E1\E5\E6\D3\CA \E4\ED\E3 \C7\E1\DD\C7\D1\DB" name=\
host-name policy=ftp,reboot,read,write,policy,test,password,sniff,sensitive \
source="foreach i in=[/ip dhcp-server lease find] do={\r\
\n :if ([:len [/ip dhcp-server lease get \$i host-name]] = 0) do={\r\
\n /ip dhcp-server lease remove \$i;\r\
\n }\r\
\n}"

/system scheduler
add interval=20m name=host-name on-event=host-name policy=\
ftp,reboot,read,write,policy,test,password,sniff,sensitive start-date=\
feb/24/2015 start-time=18:40:00
Top

Who is online

Users browsing this forum: No registered users and 11 guests