Community discussions

MikroTik App
speedzonenetwork
Member Candidate
Member Candidate
Topic Author
Posts: 110
加入: 我2009年8月3日14点

Can DHCP Stop Leasing Ip On Provided Date?

Mon Nov 23, 2009 7:00 pm

Can DHCP Stop Leasing Ip On Provided Date?
For Example : User Cannot Get Ip After 30 Days (Like 30 Of Every Month at 12:00 am)
Top
fewi
Forum Guru
Forum Guru
Posts: 7717
加入: Tue Aug 11, 2009 3:19 am

Re: Can DHCP Stop Leasing Ip On Provided Date?

Mon Nov 23, 2009 7:36 pm

No, you cannot.

I'm guessing at your use case since you don't give many details, but you're selling service and want to block users at the end of the month unless they've paid for the next month. One feasible workaround would be to enter static leases for the customers in "/ip dhcp-server lease". Mark them with comments. Then schedule a script at the end of the month that finds all those leases with those comments and sets "block-access" to "yes":
Code:Select all
[admin@MikroTik] > /ip dhcp-server lease print detail where comment="test" Flags: X - disabled, R - radius, D - dynamic, B - blocked 2 ;;; test mac-address=AA:BB:CC:DD:EE:FF [admin@MikroTik] > :foreach LEASE in=[/ip dhcp-server lease find comment="test"] do={ /ip dhcp-server lease set $LEASE block-access=yes } [admin@MikroTik] > /ip dhcp-server lease print detail where comment="test" Flags: X - disabled, R - radius, D - dynamic, B - blocked 2 B ;;; test mac-address=AA:BB:CC:DD:EE:FF block-access=yes
Top
speedzonenetwork
Member Candidate
Member Candidate
Topic Author
Posts: 110
加入: 我2009年8月3日14点

Re: Can DHCP Stop Leasing Ip On Provided Date?

Tue Nov 24, 2009 12:11 am

Thanks alot Fewi.

can u guide me in winbox interface?
it take ur couple of mins but this will make us able to configure this rule perfectly.

Thanks Again.
Top
fewi
Forum Guru
Forum Guru
Posts: 7717
加入: Tue Aug 11, 2009 3:19 am

Re: Can DHCP Stop Leasing Ip On Provided Date?

Tue Nov 24, 2009 12:20 am

I don't have access to winbox on this machine.
Top
speedzonenetwork
Member Candidate
Member Candidate
Topic Author
Posts: 110
加入: 我2009年8月3日14点

Re: Can DHCP Stop Leasing Ip On Provided Date?

Tue Nov 24, 2009 12:23 am

can u do that later ? or please ask someone else to provide this rule in winbox.

Thanks Alot.
Top
fewi
Forum Guru
Forum Guru
Posts: 7717
加入: Tue Aug 11, 2009 3:19 am

Re: Can DHCP Stop Leasing Ip On Provided Date?

Tue Nov 24, 2009 12:28 am

Which part don't you understand? Blindly running configuration you don't understand is generally a bad idea.
Top
speedzonenetwork
Member Candidate
Member Candidate
Topic Author
Posts: 110
加入: 我2009年8月3日14点

Re: Can DHCP Stop Leasing Ip On Provided Date?

Tue Nov 24, 2009 12:37 am

i read this method in pervious threads and tried my self but unable to get what i need.

thats y write this request. that rule require to be made in the end of the month.
but i need the automatically script by which users cannot get ip automatically on its last date.

i do that manually every month in the end of month by disabling their Ip but it take much time to disable Ips 1 by 1.

any option to make it automatic.?
Top
fewi
Forum Guru
Forum Guru
Posts: 7717
加入: Tue Aug 11, 2009 3:19 am

Re: Can DHCP Stop Leasing Ip On Provided Date?

Tue Nov 24, 2009 1:05 am

Right. So I gave you a script:
Code:Select all
:foreach LEASE in=[/ip dhcp-server lease find comment="test"] do={ /ip dhcp-server lease set $LEASE block-access=yes }
Which finds all static DHCP leases that have a comment of "test" and blocks access for those clients. You then create a scheduled job (System/Scheduler) and set it to run at midnight on the last of the month, and use that script as the code to run on the event. Just make sure to swap out the "test" comment for something sensible and edit the one line script to reflect that, set static DHCP leases for all clients and make sure to apply that comment to those that need to be disabled by the script.
Top

Who is online

Users browsing this forum:Ahrefs [Bot],alverman,dioeyandika,hm289and 28 guests