Syed Jahanzaib Personal Blog to Share Knowledge !

March 28, 2016

Mikrotik with Freeradius/mySQL – Change IP Pool After Expiration # Part-3

Filed under: freeradius — Tags: , — Syed Jahanzaib / Pinochio~:) @ 4:19 PM




Part # 3 > You are here …


Personnel Note:

This is another post about freeradius. My aim is to let people know that creating your own Radius Billing system is not ROCKET SCIENCE as some PRO in the industry try to pose. You can do it as well, the only thing required is the ultimate passion to achieve the goal. And with the right search, reading, understanding logic’s, you can do all on your own. I strongly encourage to read the FR mailing list and Google.



It is required that when user account expires, he can still login but he should get IP from ‘expired pool’ so that we can redirect him to payment reminder page or route/manage in some other customized way via NAS.


1- FREERADIUS Section:

For this purpose we will modify the EXPIRATION module. as mentioned below.

nano /etc/freeradius/sites-available/default

Add or modify

userlock = 1
update reply {
Reply-Message := "Your account has expired, %{User-Name} / Reason: DATE LIMIT REACHED / zaib"
Framed-Pool := "expired-pool"

Save & Exit.


Now add the user ‘expiration‘ in radcheck table using mysql

INSERT INTO `radius`.`radcheck` (
`id` ,
`username` ,
`attribute` ,
`op` ,
NULL , 'zaib', 'Expiration', ':=', '28 Mar 2016 15:35'

Note that I am using Expiration Date along with exact time as well. This can also be used to reduce receiving annoying customer call whose account expires default in night at 00:00 hours as default expiration is done in night and user will have no where to contact as in late night no one pick help support calls in DCN.

OR PHPMYADMIN as showed below …

1- exp

2- Mikrtoik Section

Add new IP pool with the name of ‘expired-pool‘ (or as mentioned in Framed-Pool section)

/ip pool

add name=expired-pool ranges=

2-exp pool

Now try to login with user (which expiry date(time) have passed. and you will observe that user will still be able to login but he will get ip from the expired pool, and NAS will handle the request afterwards, either to redirect to expired pool, or some other customized action : )



3- exp radclient


Syed Jahanzaib



  1. […] FREERADIUS WITH MIKROTIK – Part #3 […]

    Pingback by Mikrotik with Freeradius/mySQL # Part-1 | Syed Jahanzaib Personal Blog to Share Knowledge ! — March 28, 2016 @ 4:27 PM

  2. Hi
    if we want to use queue tree for trafic limit how can we do? With api?

    Comment by Mustafa sakir ozkan — May 25, 2016 @ 1:07 AM

  3. Hi there,
    How can I configure my Cable Company Router to direct the request coming from Mikrotik NAS to the LAN IP address which is acting as Radius Server? Much Appreciated.

    Comment by Rajnish — August 20, 2016 @ 1:16 AM

  4. Hi, my requirements is to setup a Web application on freeRadius which will sign-up/create ISP users, manage their account etc. and also when ISP account created they will have a sub-domain with their own users and management. Now the question is how to start this project, either i need to create a new database where we will mange ISP related info or all the above requirements can be handle in the FreeRadius database? Thanks

    Comment by Imran — September 8, 2016 @ 11:50 AM

    • You need a customized billing system that can be made in freeradius/mysql.
      But this requires some good knowledge and experience with the freeradius/mysql and above all PHP for frontend management.

      Comment by Syed Jahanzaib / Pinochio~:) — September 18, 2016 @ 4:10 PM

      • Thanks for your reply, but i have few questions when i create the ISP account (sub-domain) where to store their users (users of ISP)? means the ISP user will have their own Mikrotik router.

        Comment by Imran — September 20, 2016 @ 7:25 PM

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Create a free website or blog at

%d bloggers like this: