root@localhost ~ # emerge -v freeradius
root@localhost ~ # radiusd -fX
root@localhost ~ # cp -r /etc/raddb /etc/raddb.olg root@localhost ~ # find /etc/raddb -type f -exec file {} \; | grep 'text' | cut -d':' -f1 | xargs sed -i '/^ *\t* *#/d;/^$/d'
root@localhost ~ # cat /etc/raddb/clients.conf | sed '/client test-wifi/,/}/!d' client test-wifi { ipaddr = 192.168.0.1 #IP , secret = secret_key # . Wi-Fi . require_message_authenticator = no # , - D-Link }
root@localhost ~ # cat /etc/raddb/proxy.conf | sed '/realm DEFAULT/, /^}/!d' realm DEFAULT { type = radius authhost = LOCAL acchost = LOCAL }
root@localhost ~ # cat /etc/raddb/users | sed '10,$!d' user1 Cleartext-Password := "password1" user2 Cleartext-Password := "password2" user3 Cleartext-Password := "password3"
root@localhost ~ # radiusd -fX
root@localhost ~ # psql -U postgres radius_wifi=> create user radius_wifi with password 1111; radius_wifi=> create database radius_wifi with owner=radius_wifi; radius_wifi=> \q
root@localhost ~ # cat /etc/raddb/sql/postgresql/schema.sql | psql -U radius_wifi radius_wifi
root@localhost ~ # cat /etc/raddb/sql/postgresql/schema.sql | sed '/^--/d;/\/\*/d;/\*/d;/^$/d;' CREATE TABLE radacct ( RadAcctId BIGSERIAL PRIMARY KEY, AcctSessionId VARCHAR(64) NOT NULL, AcctUniqueId VARCHAR(32) NOT NULL UNIQUE, UserName VARCHAR(253), GroupName VARCHAR(253), Realm VARCHAR(64), NASIPAddress INET NOT NULL, NASPortId VARCHAR(15), NASPortType VARCHAR(32), AcctStartTime TIMESTAMP with time zone, AcctStopTime TIMESTAMP with time zone, AcctSessionTime BIGINT, AcctAuthentic VARCHAR(32), ConnectInfo_start VARCHAR(50), ConnectInfo_stop VARCHAR(50), AcctInputOctets BIGINT, AcctOutputOctets BIGINT, CalledStationId VARCHAR(50), CallingStationId VARCHAR(50), AcctTerminateCause VARCHAR(32), ServiceType VARCHAR(32), XAscendSessionSvrKey VARCHAR(10), FramedProtocol VARCHAR(32), FramedIPAddress INET, AcctStartDelay INTEGER, AcctStopDelay INTEGER ); CREATE INDEX radacct_active_user_idx ON radacct (UserName, NASIPAddress, AcctSessionId) WHERE AcctStopTime IS NULL; CREATE INDEX radacct_start_user_idx ON radacct (AcctStartTime, UserName); CREATE TABLE radcheck ( id SERIAL PRIMARY KEY, UserName VARCHAR(64) NOT NULL DEFAULT '', Attribute VARCHAR(64) NOT NULL DEFAULT '', op CHAR(2) NOT NULL DEFAULT '==', Value VARCHAR(253) NOT NULL DEFAULT '' ); create index radcheck_UserName on radcheck (UserName,Attribute); CREATE TABLE radgroupcheck ( id SERIAL PRIMARY KEY, GroupName VARCHAR(64) NOT NULL DEFAULT '', Attribute VARCHAR(64) NOT NULL DEFAULT '', op CHAR(2) NOT NULL DEFAULT '==', Value VARCHAR(253) NOT NULL DEFAULT '' ); create index radgroupcheck_GroupName on radgroupcheck (GroupName,Attribute); CREATE TABLE radgroupreply ( id SERIAL PRIMARY KEY, GroupName VARCHAR(64) NOT NULL DEFAULT '', Attribute VARCHAR(64) NOT NULL DEFAULT '', op CHAR(2) NOT NULL DEFAULT '=', Value VARCHAR(253) NOT NULL DEFAULT '' ); create index radgroupreply_GroupName on radgroupreply (GroupName,Attribute); CREATE TABLE radreply ( id SERIAL PRIMARY KEY, UserName VARCHAR(64) NOT NULL DEFAULT '', Attribute VARCHAR(64) NOT NULL DEFAULT '', op CHAR(2) NOT NULL DEFAULT '=', Value VARCHAR(253) NOT NULL DEFAULT '' ); create index radreply_UserName on radreply (UserName,Attribute); CREATE TABLE radusergroup ( UserName VARCHAR(64) NOT NULL DEFAULT '', GroupName VARCHAR(64) NOT NULL DEFAULT '', priority INTEGER NOT NULL DEFAULT 0 ); create index radusergroup_UserName on radusergroup (UserName); CREATE TABLE radpostauth ( id BIGSERIAL PRIMARY KEY, username VARCHAR(253) NOT NULL, pass VARCHAR(128), reply VARCHAR(32), CalledStationId VARCHAR(50), CallingStationId VARCHAR(50), authdate TIMESTAMP with time zone NOT NULL default 'now()' );
$INCLUDE sql.conf
root@localhost ~ # cat /etc/raddb/sql.conf sql { database = "postgresql" driver = "rlm_sql_${database}" server = "localhost" login = "radius_wifi" password = "1111" radius_db = "radius_wifi" acct_table1 = "radacct" acct_table2 = "radacct" postauth_table = "radpostauth" authcheck_table = "radcheck" authreply_table = "radreply" groupcheck_table = "radgroupcheck" groupreply_table = "radgroupreply" usergroup_table = "radusergroup" deletestalesessions = yes sqltrace = no sqltracefile = ${logdir}/sqltrace.sql num_sql_socks = 5 connect_failure_retry_delay = 60 lifetime = 0 max_queries = 0 nas_table = "nas" $INCLUDE sql/${database}/dialup.conf }
root@localhost ~ # psql -U postgres radius_wifi=> insert into radcheck (username, attribute, op, value) values ('test1', 'Cleartext-Password', ':=', '1111'); radius_wifi=> insert into radcheck (username, attribute, op, value) values ('test2', 'Cleartext-Password', ':=', '1111'); radius_wifi=> insert into radcheck (username, attribute, op, value) values ('test3', 'Cleartext-Password', ':=', '1111'); radius_wifi=> insert into radcheck (username, attribute, op, value) values ('test3', 'Auth-Type', ':=', 'Reject');
Source: https://habr.com/ru/post/170949/
All Articles