Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Voucher expiry

    Scheduled Pinned Locked Moved Captive Portal
    9 Posts 3 Posters 875 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • D
      david6464
      last edited by

      Hello,
      I created 10 Hour vouchers for clients.

      I realized that the person connects with the voucher, the voucher expires 10 hours.

      Example :
      Login at 8 a.m.
      Disconnection at 9:00 a.m. (with the logout button)
      Connection at 8 p.m. voucher expired.

      Is there a solution for the voucher to be valid for 7 days?

      thank you beforehand

      1 Reply Last reply Reply Quote 0
      • F
        FSC830
        last edited by FSC830

        There is something wrong:
        From 8.00 a.m. to 8.00 p.m. it is 12 hours, not 10!?
        So voucher should expire 6.00 p.m. (8.00 a.m. to 6.00 p.m. are 10 hours).

        If you need a 7 day voucher you need to create a roll with 7 day validity.

        Regards

        1 Reply Last reply Reply Quote 0
        • D
          david6464
          last edited by

          Hello,
          I have customers who stay 1 week in my hotel, I give them a 10H voucher.
          Currently as soon as a user connects 10 hours later the voucher expires even if my client clicks on disconnect.

          I would like the voucher to be valid for 1 week but that it can only be used 10 hours a week.
          Example:
          Monday he uses the internet from 10 to 11 a.m.
          Tuesday 10 a.m. to 12 p.m.
          Wednesday no connection
          Thursday 9 a.m. to 12 p.m.
          Friday 2:30 p.m. to 3 p.m.
          Saturday 12 p.m. to 2 p.m.
          Sunday 4 p.m. to 5.30 p.m.

          GertjanG 1 Reply Last reply Reply Quote 0
          • GertjanG
            Gertjan @david6464
            last edited by Gertjan

            @david6464 said in Voucher expiry:

            I have customers who stay 1 week in my hotel, I give them a 10H voucher.
            Currently as soon as a user connects 10 hours later the voucher expires even if my client clicks on disconnect.
            I would like the voucher to be valid for 1 week but that it can only be used 10 hours a week.

            Vouchers : as soon as you use them, the counter starts. NO way to stop it.
            So vouchers is not what you want.

            The FreeRadius can do what you want :

            42a72400-b037-47cc-af0f-8cddd618e961-image.png

            You probably have to add an "Expiration Date" for each created user. Other wise, the login would be available the very next week (maybe this is not an issue).
            The other settings, "one week" and "600 minutes" are always the same.

            Set the captive portal Idle time-out to a low value, like 15 minutes or so.

            I would probably write some scripts myself that 'creates' a FreeRadius user with the needed settings

            The scripts should generate a login user name and password, and an expiry date, and write them to the pfSense / Freeradius config. Use the (see image below) page below.
            Also add the 'weekly' and '600 minutes'.

            And a time based (ones a day ?) script that runs and purges all users that have an expiry date that is passed.

            Or : no script writing, and do things manually : visit the FreeRadius

            787b2a26-b680-4e31-9595-cca74ca7fbd1-image.png

            yourself and create a user.

            No "help me" PM's please. Use the forum, the community will thank you.
            Edit : and where are the logs ??

            1 Reply Last reply Reply Quote 0
            • D
              david6464
              last edited by

              Thanks, I'll try that and get back to you.

              1 Reply Last reply Reply Quote 0
              • D
                david6464
                last edited by

                Good morning,

                I just tried, I can connect with the user fine. on the other hand when the time is exceeded, the user can reconnect.

                Looking on the internet the pfsense will not handle the Max-Daily-Session.

                Do you have a solution?

                GertjanG 1 Reply Last reply Reply Quote 0
                • GertjanG
                  Gertjan @david6464
                  last edited by Gertjan

                  @david6464 said in Voucher expiry:

                  I just tried, I can connect with the user fine. on the other hand when the time is exceeded, the user can reconnect.
                  Looking on the internet the pfsense will not handle the Max-Daily-Session.

                  Don't look on the Internet ...Look at the device you use ;)

                  I've created a a user "001" with a 'password'.

                  Under FreeRadius, for this '001' user, I set this :

                  984d721f-c80d-496a-a13d-b536d1e570cd-image.png

                  and nothing more.

                  Then, "because I love real time colored logs that show all the details", I de activated FreeRadius in the GUI :

                  ee573d59-d852-4003-bc79-3e3f866d4869-image.png

                  and I entered the console, my favorite, option 8.

                  I started 'radiusd' (the name of the process) manually with the 'run from command line option '-X') :

                  radiusd -X
                  

                  Some serious login scolls over the screen.
                  I advise you to have your session written to disk for later analyses.

                  I used my phone to login onto my captive portal, using the user '001' and password.
                  I succeeded.

                  I waited 10 minutes.

                  After 10 minutes, I saw this in the pfSense portal logs :

                  77624687-29c1-4451-bc19-da8d81d92144-image.png

                  and on the command line (console) I saw this :

                  91c51aec-5095-4dc4-9843-7cf4a2c63160-image.png

                  I took my phone, and yes, no more 'wifi' connection.

                  I tried to login again with the '001' user :
                  I saw this :

                  501e1320-a3cf-4517-9119-13a91db4664c-image.png

                  and on my phone I saw this ;

                  9395a84d-d45f-42fa-895e-e4d008328198-image.png

                  I was unable to login. And that's ok - my ten minutes where over for today.

                  I do presume that I will be able to login again when my 'cron tasks' reset the daily counters : the first line, where I reset the daily counter at 12h00' or 'noon' :

                  b441d62b-3972-45d7-b41d-53ced577aa38-image.png

                  Be warned : I don't know why it works for me ;)
                  I do remember that I was messing around with radius for weeks if not months, just to get the impression that I was starting to understand how it works ...
                  Radius is hard. FreeRadius is better. Documentation is ...... strange. And this is understanable, as many use web servers, DNS servers and mail servers.
                  But very few use (so document) radius stuff.

                  edit 2023-02-17 : I mentioned cron above.
                  That was wrong.
                  Daily, or weekly, or monthly session time usage is pure SQL (for me) based.
                  The counter starts running as soon as the user logs in.

                  I saw this in the SQL log upon initial login :

                  SELECT SUM(acctsessiontime - GREATEST((1676588400 - UNIX_TIMESTAMP(acctstarttime)), 0)) FROM radacct WHERE username = '001' AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '1676588400';
                  INSERT INTO radpostauth (username, pass, reply, authdate ) VALUES ( '001', 'climat', 'Access-Accept', '2023-02-17 10:52:39.225078' );
                  
                  

                  This tells me that first, with the "SELECT SUM" etc the total session time is generated for 'today'.
                  Btw : the unix time stimp = 1676588400 = 2023-02-17 at 0:00 AM = the start of the day ( ? )

                  Then this test is redone every 60 seconds, because

                  672fed52-90d4-4f98-8cf1-d5b239758ebd-image.png
                  ( snip of my captive portal settings )

                  When the users '001' total session time exceeds my '600' seconds (daily), I see this :

                  SELECT SUM(acctsessiontime - GREATEST((1676588400 - UNIX_TIMESTAMP(acctstarttime)), 0)) FROM radacct WHERE username = '001' AND UNIX_TIMESTAMP(acctstarttime) + acctsessiontime > '1676588400';
                  INSERT INTO radpostauth (username, pass, reply, authdate ) VALUES ( '001', 'climat', 'Access-Reject', '2023-02-17 11:36:49.858247' );
                  

                  The Reject is correct because I can check the SELECT SUM blabla SQL request for myself (I'm using phpmyadmin on my NAS), so I can check this SQL sequence myself.
                  It returned '603' that that's just above '600' : FreeRadius return a Reject and I was disconnected.

                  No "help me" PM's please. Use the forum, the community will thank you.
                  Edit : and where are the logs ??

                  1 Reply Last reply Reply Quote 0
                  • D
                    david6464
                    last edited by david6464

                    Good morning,
                    on the level of the logs I have the same thing
                    after 10 min I get disconnected, however if I put the login and password back it reconnects well.

                    Can you give me your version of PFSENSE

                    Can you send me screenshots of your captive portal and freeradius config?

                    TXH

                    GertjanG 1 Reply Last reply Reply Quote 0
                    • GertjanG
                      Gertjan @david6464
                      last edited by

                      @david6464 said in Voucher expiry:

                      Can you send me screenshots of your captive portal and freeradius config?

                      Of course.
                      But before we compare apples with oranges, I'll describe my setup.
                      I have a dedicated 192.168.2.1/24 captive portal network interface.
                      I'm using the "https" access with known signed certs - I use acme.sh - this isn't related to your question I guess.
                      I'm using my own login and error page, just to add some logos etc - the internal html is identical ti the build in pages.

                      cpsettings.jpg

                      The auth server settings page :

                      9796d5cc-72a2-4a9f-8db0-b993c1a4b572-image.png

                      FreeRadius :
                      I have a bunch of users :

                      9796f809-cd8e-49f7-b3f2-23d36b9c4ac1-image.png

                      Most of them have only there 'name' and password set.
                      User '001' has a daily limit of 600 seconds.

                      Keep in mind : I use Radius, but are not really bit counting, are rate limiting, or whatever.
                      I'm not selling my access, and I don't have to educate kids or so.
                      My portal has one rule : if it works for you, then that's fine.
                      If it doesn't, then you (the portal user) has an issue - not me ;)

                      The MACs page is empty.

                      f32b9571-5ae0-4190-a1af-60db30e0a87e-image.png

                      75ff5cfc-16f4-443d-823e-8dbe58d13128-image.png

                      78b102e0-0c18-419e-9051-198c907e74ab-image.png

                      d63eda76-1ab3-465b-896b-fe7ccd408ba6-image.png

                      Note : the FreeRadius cert was auto generated ? I don't remember any more. The Youtube => Netgate FreeRadius movies will help you.

                      4193c5f4-102e-4f1c-99ac-4bb475feff22-image.png

                      Note 192.168.1.33 is my Synoloy NAS with the SQL server.

                      The last 3, LDAP View Config and XMLRPC Sync are not used by me.

                      Last image : My Mariadb (SQL) database with the tables.

                      fe060bb6-7f1e-44bb-9e79-7b48d1f1e361-image.png

                      Note : keep in mind : The pfSense FreeRadius package is a partial implementation of what FreeRadius can really do.
                      A lot is hard coded in the FreeRadius config, as bringing them to the GUI would be ..... mission impossible.
                      To understand what I mean look here : /usr/local/etc/raddb/ and have a look at
                      ALL the files and ALL the files in ALL the sub folders.

                      The main file is /usr/local/etc/raddb/sites-enabled/default , it all starts there.
                      Most of it is purely hard coded.

                      FreeRadius is complicated.

                      No "help me" PM's please. Use the forum, the community will thank you.
                      Edit : and where are the logs ??

                      1 Reply Last reply Reply Quote 0
                      • First post
                        Last post
                      Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.