Thursday, January 11, 2018

What are the supported RADIUS attributes in CoovaChilli Captive Portal

Its been running on my pf platform for months.

Chilli uses RADIUS to provision access and to provide accounting. 

Direction of Input and Output 
The original ChilliSpot defined input and output as being data uploaded and downloaded by the client respectively. Uses the reverse meaning (per default) making it more compatible with some other commercial access controllers. 

In RFC 2866, it says: 

This attribute indicates how many octets have been received from the port over the course of this service being provided. 
This attribute indicates how many octets have been sent to the port in the course of delivering this service. 

However, this is not very conclusive as it depends on what side of the port you are referring to. In the manual for a popular commercial access controller, is says: 

Number of octets/bytes received by the customer. 
Number of octets/bytes sent by the customer. 

This is the definition adopted by CoovaChilli - one of the very first changes made to ChilliSpot, for use with back-end systems also supporting commercial access controllers.

Access Provisioning 
The following RADIUS attributes are used to place limits on a session authorized by a RADIUS Access-Accept response: 

Session-Timeout = seconds
Standard RADIUS attribute (defined in RFC 2865) for setting the maximum session timeout. The user is logged out after this amount of time; session duration. 

Idle-Timeout = seconds
Standard RADIUS attribute (defined in RFC 2865) for setting the maximum idle timeout. The user is logged out after this amount of time of inactivity (no traffic).

ChilliSpot-Max-Input-Octets = bytes
ChilliSpot-Max-Output-Octets = bytes
ChilliSpot-Max-Total-Octets = bytes
Chilli vendor specific attributes for setting the max in, out, or total bytes transferred for the session. See above for the meaning of input and output. 

WISPr-Bandwidth-Max-Up = bits/second 
WISPr-Bandwidth-Max-Down = bits/second 
WISPr vendor specific attributes for setting the maximum bandwidth rate in bits per second. 

ChilliSpot-Bandwidth-Max-Up = kbits/second 
ChilliSpot-Bandwidth-Max-Down = kbits/second 
Chilli vendor specific attributes for setting the maximum bandwidth rate in kbits per second. Internally, chilli multiplies this value by 1000 in converting to bits per second. 
In all cases, the ChilliSpot vendor specific attributes override WISPr attribute values. However, using the WISPr attributes is perhaps the more standard way to go. 

Session Accounting 
In RADIUS Accounting, the following attributes are used to report session statistics: 

Acct-Session-Time = seconds 
Duration of session in seconds. 

Acct-Input-Octets = bytes 
Acct-Output-Octets = bytes 
The lower 32-bit value of the number of bytes of input and output (see above for a discussion of the meaning of input vs. output). 

Acct-Input-Gigawords = gigawords 
Acct-Output-Gigawords = gigawords 
The upper 32-bit value of the number of bytes of input and output; or how many times the above attributes have rolled-over the 32-bit value. 

Acct-Input-Packets = num-packets 
Acct-Output-Packets = num-packets 
The number of packets carrying input or output octets.

Below you can find the RADIUS Attributes used by chilli and a short description:
Attribute(type) Description
User-name (1) Full username as entered by the user.
User-Password (2) Used for UAM as alternative to CHAP-Password and CHAP-Challenge.
CHAP-Password (3) Used for UAM CHAP Authentication
CHAP-Challenge (60) Used for UAM CHAP Authentication
EAP-Message (79) Used for WPA Authentication
NAS-IP-Address (4) IP address of Chilli (set by the ‘‘nasip’’ or ‘‘radiuslisten’’ option, and otherwise “”)
Service-Type (6) Set to Login (1) for normal authentication requests. The Access-Accept message from the radius server for configuration management messages must also be set to Administrative-User.
Framed-IP-Address (8) IP address of the user, which is configurable during MAC authentication in the Access-Accept.
Framed-IP-Netmask (9) IP netmask of the user, which is configurable during MAC authentication in the Access-Accept.
Filter-ID (11) Filter ID pass on to scripts possibly.
Reply-Message (18) Reason of reject if present.
State (24) Sent to chilli in Access-Accept or Access-Challenge. Used transparently in subsequent Access-Request.
Class (25) Copied transparently by chilli from Access-Accept to Accounting-Request.
Session-Timeout (27) Logout once session timeout is reached (seconds)
Idle-Timeout (28) Logout once idle timeout is reached (seconds)
Called-Station-ID (30) Set to the ‘‘nasmac’’ option or the MAC address of chilli.
Calling-Station-ID (31) MAC address of client
NAS-Identifier (32) Set to radiusnasid option if present
Acct-Status-Type (40) 1=Start, 2=Stop, 3=Interim-Update
Acct-Input-Octets (42) Number of octets received from client
Acct-Output-Octets (43) Number of octets transmitted to client.
Acct-Session-ID (44) Unique ID to link Access-Request and Accounting-Request messages.
Acct-Session-Time (46) Session duration in seconds.
Acct-Input-Packets (47) Number of packets received from client.
Acct-Output-Packets (48) Number of packets transmitted to client.
Acct-Terminate-Cause (49) 1=User-Request, 2=Lost-Carrier, 4=Idle-Timeout, 5=Session-Timeout, 11=NAS-Reboot
Acct-Input-Gigawords (52) Number of times the Acct-Input-Octets counter has wrapped around.
Acct-Output-Gigawords (53) Number of times the Acct-Output-Octets counter has wrapped around.
NAS-Port-Type (61) 19=Wireless-IEEE-802.11
Message-Authenticator (80) Is always included in Access-Request. If present in Access-Accept, Access-Challenge or Access-reject chilli will validate that the Message-Authenticator is correct.
Acct-Interim-Interval (85) If present in Access-Accept chilli will generate interim accounting records with the specified interval (seconds).
WISPr-Location-ID (14122, 1) Location ID is set to the radiuslocationid option if present. Should be in the format: isocc=, cc=, ac=, network=
WISPr-Location-Name (14122, 2) Location Name is set to the radiuslocationname option if present. Should be in the format: ,
WISPr-Logoff-URL (14122, 3) Included in Access-Request to notify the operator of the log off URL. Defaults to “http://uamlisten:uamport/logoff”.
WISPr-Redirection-URL (14122, 4) If present the client will be redirected to this URL once authenticated. This URL should include a link to WISPr-Logoff-URL in order to enable the client to log off.
WISPr-Bandwidth-Max-Up (14122, 7) Maximum transmit rate (b/s). Limits the bandwidth of the connection. Note that this attribute is specified in bits per second.
WISPr-Bandwidth-Max-Down (14122, 8) Maximum receive rate (b/s). Limits the bandwidth of the connection. Note that this attribute is specified in bits per second.
WISPr-Session-Terminate-Time (14122, 9) The time when the user should be disconnected in ISO 8601 format (YYYY-MM-DDThh:mm:ssTZD). If TZD is not specified local time is assumed. For example a disconnect on 18 December 2001 at 7:00 PM UTC would be specified as 2001-12-18T19:00:00+00:00.
ChilliSpot-Max-Input-Octets (14559, 1) Maximum number of octets the user is allowed to transmit. After this limit has been reached the user will be disconnected.
ChilliSpot-Max-Output-Octets (14559, 2) Maximum number of octets the user is allowed to receive. After this limit has been reached the user will be disconnecte
ChilliSpot-Max-Total-Octets (14559, 3) Maximum total octets the user is allowed to send or receive. After this limit has been reached the user will be disconnected.
ChilliSpot-Bandwidth-Max-Up (14559, 4) Maximum bandwidth up
ChilliSpot-Bandwidth-Max-Down (14559, 5) Maximum bandwidth down
ChilliSpot-Config (14559, 6) Configurations passed between chilli and back-end as name value pairs
ChilliSpot-Lang (14559, 7) Language selected in user interface
ChilliSpot-Version (14559, 8) Contains the version of the running CoovaChilli
ChilliSpot-DHCP-Netmask (14559, 61) DHCP IP netmask of the user, which is configurable during MAC authentication in the Access-Accept.
ChilliSpot-DHCP-DNS1 (14559, 62) DHCP DNS1 of the user, which is configurable during MAC authentication in the Access-Accept.
ChilliSpot-DHCP-DNS2 (14559, 63) DHCP DNS2 of the user, which is configurable during MAC authentication in the Access-Accept.
ChilliSpot-DHCP-Gateway (14559, 64) DHCP Gateway of the user, which is configurable during MAC authentication in the Access-Accept
ChilliSpot-DHCP-Domain (14559, 65) DHCP Domain of the user, which is configurable during MAC authentication in the Access-Accept.
MS-MPPE-Send-Key (311,16) Used for WPA
MS-MPPE-Recv-Key (311,17) Used for WPA

Thursday, December 21, 2017

httpd server option

Usage: httpd [-D name] [-d directory] [-f file]
             [-C "directive"] [-c "directive"]
             [-k start|restart|graceful|graceful-stop|stop]
             [-v] [-V] [-h] [-l] [-L] [-t] [-T] [-S] [-X]
  -D name            : define a name for use in directives
  -d directory       : specify an alternate initial ServerRoot
  -f file            : specify an alternate ServerConfigFile
  -C "directive"     : process directive before reading config files
  -c "directive"     : process directive after reading config files
  -e level           : show startup errors of level (see LogLevel)
  -E file            : log startup errors to file
  -v                 : show version number
  -V                 : show compile settings
  -h                 : list available command line options (this page)
  -l                 : list compiled in modules
  -L                 : list available configuration directives
  -t -D DUMP_VHOSTS  : show parsed vhost settings
  -t -D DUMP_RUN_CFG : show parsed run settings
  -S                 : a synonym for -t -D DUMP_VHOSTS -D DUMP_RUN_CFG
  -t -D DUMP_MODULES : show all loaded modules 
  -M                 : a synonym for -t -D DUMP_MODULES
  -t -D DUMP_INCLUDES: show all included configuration files
  -t                 : run syntax check for config files
  -T                 : start without DocumentRoot(s) check

  -X                 : debug mode (only one worker, do not detach)

Example command for checking included configuration file

Included configuration files:
  (*) /usr/local/etc/httpd/httpd.conf

    (505) /usr/local/etc/httpd/extra/httpd-vhosts.conf

Thursday, November 2, 2017

ENABLE General logs in MYSQL database

If you were login  with root user on mysql database . 
Use below command enable log 
SET GLOBAL general_log = 'ON';
command for disable mysql log   
SET GLOBAL general_log = 'OFF'; 

Thursday, October 12, 2017

SQLSTATE[HY000]: General error MySQL: 1364 Field 'coloum' doesn't have a default value, how to solve

With the root access of the mysql, do the following changes

select @@GLOBAL.sql_mode
In my case, I get the following:
Copy this result and remove STRICT_TRANS_TABLES. Then perform the following:

brew services start mysql


How to Disable MySQL Strict Mode?

It’s relatively easy to disable MySQL strict mode in Ubuntu 16.04 LTS. This may work on other versions of Linux such as CentOS. But I’m not testing it. You can let other know if it’s working on the comments section. Start by login in to your VPS as root user with SSH.
Create a new .cnf file.
nano /etc/mysql/conf.d/strict_mode.cnf
Paste the following code into that file,
Save and close the file. And then restart MySQL server.
systemctl restart mysql
Open your application and errors should have disappeared.

How to Enable MySQL Strict Mode back on?

You can turn strict mode back on in the future if your application become compatible with it. Just deleting the file you created earlier and the restarting MySQL will turn strict mode back on. Following command will delete the file,
rm /etc/mysql/conf.d/strict_mode.cnf
Restart MySQL,
systemctl restart mysql
That’s it. Feel free to use comments section if you’re having trouble disabling or re-enabling MySQL strict mode.

Friday, July 21, 2017

Laravel Interview questions and answers

1. What is Laravel

Laravel is free open source “PHP framework” based on MVC Design Pattern .
It is created by Taylor Otwell. Laravel provides expressive and elegant syntax that helps in creating a wonderful web application easily and quickly.

2. List some official packages provided by Laravel.

Below are some official packages provided by Laravel
  • Cashier :Laravel Cashier provides an expressive, fluent interface to Stripe’s and Braintree’s subscription billing services. It handles almost all of the boilerplate subscription billing code you are dreading writing. In addition to basic subscription management, Cashier can handle coupons, swapping subscription, subscription “quantities”, cancellation grace periods, and even generate invoice PDFs.Read More
  • Envoy :Laravel Envoy provides a clean, minimal syntax for defining common tasks you run on your remote servers. Using Blade style syntax, you can easily setup tasks for deployment, Artisan commands, and more. Currently, Envoy only supports the Mac and Linux operating systems.
  • Passport :Laravel makes API authentication a breeze using Laravel Passport, which provides a full OAuth2 server implementation for your Laravel application in a matter of minutes. Passport is built on top of the League OAuth2 server that is maintained by Alex Bilbie.
  • Scout :Laravel Scout provides a simple, driver based solution for adding full-text search to your Eloquent models. Using model observers, Scout will automatically keep your search indexes in sync with your Eloquent records
  • Socialite :Laravel Socialite provides an expressive, fluent interface to OAuth authentication with Facebook, Twitter, Google, LinkedIn, GitHub and Bitbucket. It handles almost all of the boilerplate social authentication code you are dreading writing.

3. What is Lumen?

Lumen is PHP micro framework that built on Laravel’s top components. It is created by Taylor Otwell.
It is the perfect option for building Laravel based micro-services and fast REST API’s.
It’s one of the fastest micro-frameworks available.

4. List out some benefits of Laravel over other Php frameworks ?

  1. Setup and customization process is  easy and fast as compared to others.
  2. Inbuilt Authentication System.
  3. Supports multiple file systems
  4. Pre-loaded packages like Laravel Socialite, Laravel cashier, Laravel elixir,Passport,Laravel Scout.
  5. Eloquent ORM (Object Relation Mapping) with PHP active record implementation. 
  6. Built in command line tool “Artisan” for creating a code skeleton ,database structure and build their migration.

5. List out some latest features of Laravel Framework

  • Inbuilt CRSF (cross-site request forgery ) Protection.
    Laravel provided an easy way to protect your website from cross-site request forgery (CSRF) attacks.
    Cross-site request forgeries are malicious attack that forces an end user to execute unwanted actions on a web application in which they’re currently authenticated.
  • Inbuilt paginations Laravel provides an easy approach to implement paginations in your application. Laravel’s paginator is integrated with the query builder and Eloquent ORM and provides convenient, easy-to-use pagination of database.
  • Reverse Routing
    In Laravel reverse routing is generating URL’s based on route declarations.Reverse routing makes your application so much more flexible.
  • Query builder:
    Laravel’s database query builder provides a convenient, fluent interface to creating and running database queries. It can be used to perform most database operations in your application and works on all supported database systems.
    The Laravel query builder uses PDO parameter binding to protect your application against SQL injection attacks. There is no need to clean strings being passed as bindings.
  • Route caching
  • Database Migration
  • IOC (Inverse of Control) Container Or service container.

6. What is composer ?

Composer is PHP dependency manager used for installing dependencies of PHP applications.
It allows you to declare the libraries your project depends on and it will manage (install/update) them for you.
It provides us a nice way to reuse any kind of code. Rather than all of us reinventing the wheel over and over, we can instead download popular packages.

7. How to install Laravel via composer ?

To install Laravel with composer run below command on your terminal.

composer create-project Laravel/Laravel your-project-name version

8. What is php artisan. List out some artisan commands ?

PHP artisan is the command line interface/tool included with Laravel. It provides a number of helpful commands that can help you while you build your application easily. Here are the list of some artisian command.
  • php artisan list
  • php artisan help
  • php artisan tinker
  • php artisan make
  • php artisan –versian
  • php artisan make modal modal_name
  • php artisan make controller controller_name 

9. How to check current installed version of Laravel ?

Use php artisan –version command to check current installed version of Laravel Framework
php artisan --version

10. List some Aggregates methods provided by query builder in Laravel ?

Aggregate function is a function where the values of multiple rows are grouped together as input on certain criteria to form a single value of more significant meaning or measurements such as a set, a bag or a list
Below is list of some Aggregates methods provided by Laravel query builder.
  • count()
    Usage:$products = DB::table(‘products’)->count();
  • max()
    Usage:$price = DB::table(‘orders’)->max(‘price’);
  • min()
    Usage:$price = DB::table(‘orders’)->min(‘price’);
  • avg()
    Usage:$price = DB::table(‘orders’)->avg(‘price’);
  • sum()
    Usage: $price = DB::table(‘orders’)->sum(‘price’);

11. Explain Events in Laravel ?

An event is an incident or occurrence detected and handled by the program. Laravel event provides a simple observer implementation, that allow us to subscribe and listen for events in our application.An event is an incident or occurrence detected and handled by the program. Laravel event provides a simple observer implementation, that allows us to subscribe and listen for events in our application.
Below are some events examples in Laravel:-
  • A new user has registered
  • A new comment is posted
  • User login/logout
  • New product is added.

12. How to turn off CRSF protection for a route in Laravel ?

To turn off or diasble CRSF protection for specific routes in Laravel open “app/Http/Middleware/VerifyCsrfToken.php” file and add following code in it
//add this in your class
private $exceptUrls = ['controller/route1', 'controller/route2'];

//modify this function

public function handle($request, Closure $next)

 //add this condition
foreach($this->exceptUrls as $route) {

 if ($request->is($route)) {

  return $next($request);


return parent::handle($request, $next);}

13. What happens when you type “php artisan” in the command line?

When you type “PHP artisan” it lists of a few dozen different command options.

14. Which template engine Laravel use ?

Laravel uses Blade Templating Engine.

Blade is the simple, yet powerful templating engine provided with Laravel. Unlike other popular PHP templating engines, Blade does not restrict you from using plain PHP code in your views. In fact, all Blade views are compiled into plain PHP code and cached until they are modified, meaning Blade adds essentially zero overhead to your application. Blade view files use the .blade.php file extension and are typically stored in the resources/views directory.

15. How can you change your default database type ?

By default Laravel is configured to use MySQL.In order to change your default database edit your config/database.php and search for ‘default’ => ‘mysql’ and change it to whatever you want (like ‘default’ => ‘sqlite’).

16. Explain Migrations in Laravel ? How can you generate migration .

Laravel Migrations are like version control for your database, allowing a team to easily modify and share the application’s database schema. Migrations are typically paired with Laravel’s schema builder to easily build your application’s database schema.

Steps to Generate Migrations in Laravel

  1. To create a migration, use the make:migration Artisan command
  2. When you create a migration file, Laravel stores it in /database/migrations directory.
  3. Each migration file name contains a timestamp which allows Laravel to determine the order of the migrations.
  4. Open the command prompt or terminal depending on your operating system.

17. What are service providers in laravel ?

Service providers are the central place of all Laravel application bootstrapping. Your own application, as well as all of Laravel’s core services are bootstrapped via service providers.

Service provider basically registers event listeners, middleware, routes to Laravel’s service container.
All service providers need to be registered in providers array of app/config.php file.

18. How do you register a Service Provider?

To register a service provider follow below steps

Open to config/app.php
Find ‘providers’ array of the various ServiceProviders.
Add namespace ‘Iluminate\Abc\ABCServiceProvider:: class,’ to the end of the array.
19. What are Implicit Controllers ?


Implicit Controllers allow you to define a single route to handle every action in the controller. You can define it in route.php file with Route: controller method.

Usage :

Route::controller('base URI','');

20. What does “composer dump-autoload” do?

Whenever we run “composer dump-autoload”
Composer re-reads the composer.json file to build up the list of files to autoload.

21. Explain Laravel service container ?

One of the most powerful feature of Laravel is its Service Container .
It is a powerful tool for resolving class dependencies and performing dependency injection in Laravel.
Dependency injection is a fancy phrase that essentially means class dependencies are “injected” into the class via the constructor or, in some cases, “setter” methods.

22. How can you get users IP address in Laravel ?

You can use request’s class ip() method to get IP address of user in Laravel.
public function getUserIp(Request $request){
// Getting ip address of remote user
return $user_ip_address=$request->ip();


23. How to enable query log in Laravel?

Use the enableQueryLog method: Use the enableQueryLog method:
You can get array of the executed queries by using getQueryLog method:
$queries = DB::getQueryLog(); 

24. What are Laravel Facades?

Laravel Facades provides a static like interface to classes that are available in the application’s service container.
Laravel self ships with many facades which provide access to almost all features of Laravel’s.
Laravel Facades serve as “static proxies” to underlying classes in the service container and provides benefits of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods of classes. All of Laravel’s facades are defined in the IlluminateSupportFacades namespace. You can easily access a Facade like so:
use IlluminateSupportFacadesCache;
Route::get('/cache', function () {
return Cache::get('key');

25. How to use custom table in Laravel Modal ?

We can use custom table in Laravel by overriding protected $table property of Eloquent. Below is sample uses
class User extends Eloquent{
 protected $table="my_custom_table";


26. How can you define Fillable Attribute in a Laravel Modal ?

You can define fillable attribute by overiding the fillable property of Laravel Eloquent. Here is sample uses
Class User extends Eloquent{
 protected $fillable =array('id','first_name','last_name','age');

27. What is the purpose of the Eloquent cursor() method in Laravel ?

The cursor method allows you to iterate through your database records using a cursor, which will only execute a single query. When processing large amounts of data, the cursor method may be used to greatly reduce your memory usage.
Example Usage
foreach (Product::where('name', 'bar')->cursor() as $flight) {

 //do some stuff


28. What are Closures in laravel ?

Closures are an anonymous function that can be assigned to a variable or passed to another function as an argument.A Closures can access variables outside the scope that it was created.

29. What is Kept in vendor directory of Laravel ?

Any packages that are pulled from composer is kept in vendor directory of Laravel.

30. What are Laravel Contracts ?

Laravel’s Contracts are nothing but set of interfaces that define the core services provided by the Laravel framework.
You can read about How to Laravel contracts by How to use Laravel facade

31. What does PHP compact function do ?

PHP compact function takes each key and tries to find a variable with that same name.If the variable is found, them it builds an associative array.

32. In which directory controllers are located in Laravel ?

We kept all controllers in App/Http/Controllers directory

33. Define ORM ?

Object-relational Mapping (ORM) is a programming technique for converting data between incompatible type systems in object-oriented programming languages.

34. How to create a record in Laravel using eloquent ?

To create a new record in the database using Laravel Eloquent, simply create a new model instance, set attributes on the model, then call the save method: Here is sample Usage.
public function saveProduct(Request $request )
 $product = new product;
 $product->name = $request->name;
 $product->description = $request->name;

35. How to get Logged in user info in Laravel ?

Auth::User() function is used to get Logged in user info in Laravel.

36. Does Laravel support caching?

Yes, Laravel supports popular caching backends like Memcached and Redis.
By default, Laravel is configured to use the file cache driver, which stores the serialized, cached objects in the file system .For large projects it is recommended to use Memcached or Redis.

37. What are named routes in Laravel ?

Named routing is another amazing feature of Laravel framework. Named routes allow referring to routes when generating redirects or Url’s more comfortably.
You can specify named routes by chaining the name method onto the route definition:
Route::get('user/profile', function () {

You can specify route names for controller actions:

Route::get('user/profile', 'UserController@showProfile')->name('profile');

Once you have assigned a name to your routes, you may use the route's name when generating URLs or redirects via the global route function:

// Generating URLs...
$url = route('profile');

// Generating Redirects...
return redirect()->route('profile');

38. What are traits in Laravel ?

PHP Traits are simply a group of methods that you want include within another class. A Trait, like an abstract classes cannot be instantiated by itself.Trait are created to reduce the limitations of single inheritance in PHP by enabling a developer to reuse sets of methods freely in several independent classes living in different class hierarchies.
Here is an example of trait.
trait Sharable {
  public function share($item)
    return 'share this item';
You could then include this Trait within other classes like this:

class Post {
  use Sharable;
class Comment {
  use Sharable;
Now if you were to create new objects out of these classes you would find that they both have the share() method available:
$post = new Post;
echo $post->share(''); // 'share this item' 
$comment = new Comment;
echo $comment->share(''); // 'share this item'

39. How to create migration via artisan ?

Use below commands to create migration data via artisan.
// creating Migration
php artisan make:migration create_users_table

40. Explain validations in laravel?

In Programming validations are a handy way to ensure that your data is always in a clean and expected format before it gets into your database. Laravel provides several different ways to validate your application incoming data.By default Laravel’s base controller class uses a ValidatesRequests trait which provides a convenient method to validate all incoming HTTP requests coming from client.You can also validate data in laravel by creating Form Request.

What are the supported RADIUS attributes in CoovaChilli Captive Portal

Its been running on my pf platform for months. Chilli uses RADIUS to provision access and to provide accounting.  Direction of Input and...