Toss for several days, look up a lot of information, finally buttoned up, tears cow face, the following record detailed operation process! Note: The test environment is CENTOS5.8 x86
Installing PPTP
Use the Chao PPTP one-click installation package directly
The code is as follows |
Copy Code |
wget Http://dl.zrblog.net/pptpd.sh;sh pptpd.sh; |
Install LNMP
I am using the AMH4.2, but also a key installation package
The code is as follows |
Copy Code |
Wget http://amysql.com/file/AMH/4.2/amh.sh; chmod 775 amh.sh;/amh.sh 2>&1 | Tee Amh.log;
|
Install Pear
AMH is installed without pear, and daloradius needs pear's db plugin
The code is as follows |
Copy Code |
wget http://pear.php.net/go-pear.phar;php Go-pear.phar;
|
You can return all the way
The code is as follows |
Copy Code |
/usr/local/php/bin/pear Install DB
|
Installing the DB plugin
Add a virtual Host
Login AMH background, install the Amchroot module, and then create a new virtual host, into the Amchroot the newly-created host is set to compatibility mode. Because of the strict permissions management, it caused the pear plugin to be unable to be invoked, tossing for several nights ...
Install Daloradius
The code is as follows |
Copy Code |
wget Http://downloads.sourceforge.net/project/daloradius/daloradius/daloradius0.9-9/daloradius-0.9-9.tar.gz;tar Xvzf DALORADIUS-0.9-9.TAR.GZ;MV daloradius-0.9-9/*/home/wwwroot/replaced by the domain name that just established the virtual host/web
|
Configure Daloradius
Create a new database with phpMyAdmin, and then import./contrib/db/fr2-mysql-daloradius-and-freeradius.sql
Edit./library/daloradius.conf.php
The code is as follows |
Copy Code |
$configValues [' config_db_host '] = ' localhost '; $configValues [' config_db_port '] = ' 3306 '; $configValues [' config_db_user '] = ' database username '; $configValues [' config_db_pass '] = ' database password '; $configValues [' config_db_name '] = ' database name '; $configValues [' config_path_dalo_variable_data '] = '/home/wwwroot/to replace the domain name/web/var ' which just established the virtual host; |
Install Freeradius (SERVER)
The code is as follows |
Copy Code |
Yum Install Freeradius2 Freeradius2-mysql freeradius2-utils |
Install Client
The code is as follows |
Copy Code |
wget Ftp://ftp.samba.org/pub/ppp/ppp-2.4.5.tar.gz;tar zxvf ppp-2.4.5.tar.gz;cp-r/root/ppp-2.4.5/pppd/plugins/ radius/etc//usr/local/etc/radiusclient |
Configure Freeradius
Edit Usr/local/etc/radiusclient/servers, tail add
The code is as follows |
Copy Code |
127.0.0.1 Xxvpn
|
Edit/usr/local/etc/radiusclient/dictionary, delete the last line, and then add
The code is as follows |
Copy Code |
Include/usr/local/etc/radiusclient/dictionary.microsoft Include/usr/local/etc/radiusclient/dictionary.merit |
Edit the/etc/raddb/clients.conf, the client localhost section of the secret changed to Xxvpn
Edit/etc/raddb/radiusd.conf, find $include sql.conf, remove the front #, find $include sql/mysql/counter.conf, remove the front #
Edit/etc/raddb/sql.conf, configure login (username), password (password), radius_db (database name) fields
Edit/etc/raddb/sites-enabled/default
The code is as follows |
Copy Code |
Authorize section, turn off Files, UNIX, open SQL PREACCT, turn off the files. Accounting section, open SQL, turn off UNIX Session segment, opening SQL Post-auth section, open SQL Pre-proxy, turn off the files. |
Configure PPTP
Edit/etc/ppp/options.pptpd, tail add
The code is as follows |
Copy Code |
Plugin radius.so Plugin radattr.so Radius-config-file/usr/local/etc/radiusclient/radiusclient.conf
|
Flow control
Edit/etc/raddb/sql/mysql/counter.conf, tail add
code is as follows |
copy code |
sqlcounter Monthlytrafficcounter { counter-name = monthly-traffic check-name = max-m Onthly-traffic reply-name = Monthly-traffic-limit sqlmod-inst = SQL & nbsp; key = User-name reset = monthly query = "SELECT SUM" (Acct Inputoctets + acctoutputoctets) from Radacct WHERE username= '%{%k} ' and Unix_timestamp (acctstarttime) > '%b ' }&NB sp; |
The above code means monthly statistics, from the database Radacct table, according to the user name (%K) to add all inbound and outbound traffic.
Time can also be customized (months, weeks, days, hours), you can also specify specific values, such as three days reset once "reset = 3 D"
Edit/etc/raddb/sites-enabled/default, add "Monthlytrafficcounter" at the end of authorize block
Edit/etc/raddb/dictionary, tail add
The code is as follows |
Copy Code |
ATTRIBUTE max-monthly-traffic 3003 Integer ATTRIBUTE monthly-traffic-limit 3004 Integer
|
Enter phpMyAdmin, execute SQL
The code is as follows |
Copy Code |
INSERT into Radgroupreply (groupname,attribute,op,value) VALUES (' User ', ' Mikrotik-rate-limi ', ': = ', ' 512k/1m '); INSERT into Radgroupreply (groupname,attribute,op,value) VALUES (' User ', ' acct-interim-interval ', ': = ', ' 300 '); INSERT into Radgroupcheck (groupname,attribute,op,value) VALUES (' User ', ' simultaneous-use ', ': = ', ' 1 '); INSERT into Radgroupcheck (groupname,attribute,op,value) VALUES (' User ', ' max-monthly-traffic ', ': = ', ' 1073741824 '); |
User Disconnection Detection Script
The code is as follows |
Copy Code |
#!/bin/bash Mysql_pass=xxxxxxxxxx /USR/LOCAL/MYSQL/BIN/MYSQL-UROOT-P$MYSQL_PASS-E "UPDATE database name. RADACCT SET acctstoptime = acctstarttime + Acctsessionti Me WHERE ((Unix_timestamp (acctstarttime) + Acctsessiontime + 240-unix_timestamp ()) <0) and Acctstoptime is NULL; " |
Multiple line limits
Modify/etc/raddb/sites-enabled/defalut, add in authorize block
The code is as follows |
Copy Code |
Update Request { group-name: = "%{sql:select groupname from Radusergroup WHERE u Sername= '%{user-name} ' ORDER by priority} ' } if (Group-name & amp;& "%{sql:select count (value) from Radgroupcheck WHERE groupname= '%{group-name} ' and attribute= ' nas-ip-address ' } "{ if ("%{sql:select count (value) from Radgroupcheck WHERE groupname= '%{group-name} ' and value= '%{nas-ip-address} '} ' < 1 { reject } } |