1.安裝web環(huán)境,使用lnmp一鍵安裝包
具體安裝步驟參考
2.安裝完成后,安裝LNMP缺少的組件
ionCube組件安裝
進(jìn)入lnmp解壓后的目錄,執(zhí)行:./addons.sh install ionCube
回車(chē)確認(rèn)后就會(huì)自動(dòng)安裝ionCube loader。
yum install perl-DBI
yum freeradius-mysql freeradius-utils
3.安裝FreeRadius
wget
tar xvf freeradius-server-2.1.8-dmamod-1.tar.gz
cd freeradius-server-2.1.8
./configure
make
make install
4.文件所有者和權(quán)限配置
chmod 644 /usr/local/etc/raddb/dictionary
chown www /usr/local/etc/raddb
chown www /usr/local/etc/raddb/clients.conf
5.測(cè)試FreeRadius
radiusd ?-X
出現(xiàn)錯(cuò)誤
“error while loading shared libraries:libfreeradius-radius-2.1.8.so: cannot open shared object file : no such file or directory.”
采取的解決方式是將/usr/local/lib添加到/etc/ld.so.conf中
ld.so.conf文件內(nèi)容如下:
include /etc/ld.so.conf.d/*.conf
添加一行 /usr/local/lib
完成后輸入/sbin/ldconfig,再重新進(jìn)行上面步驟。
Ldconfig命令是將/etc/ld.so.conf列出的路徑下的庫(kù)文件緩存到/etc/ld.
在此命令調(diào)試radiusd ?-X
出現(xiàn)錯(cuò)誤
Failed binding to authentication address * port 1812: Address already in use
/usr/local/etc/raddb/radiusd.conf[240]: Error binding to port for 0.0.0.0 port 1812
端口占用問(wèn)題.
?使用命令lsof -i:1812
得到
COMMAND ? PID ? ?USER ? FD ? TYPE DEVICE SIZE/OFF NODE NAME
radiusd 11163 radiusd ? ?5u ?IPv4 949974 ? ? ?0t0 ?UDP *:radius
發(fā)現(xiàn)居然是radius自己占用了
處理方法(暴力點(diǎn))
kill 11163(radius進(jìn)程的PID,centos查看進(jìn)程PID命令:ps -ef)
如發(fā)現(xiàn)沒(méi)有這個(gè)命令可以使用yum install psmisc進(jìn)行安裝
再次radiusd -X調(diào)試
顯示Ready to process requests.
Listening on authentication address * port 1812
Listening on accounting address * port 1813
Listening on command file /usr/local/var/run/radiusd/radiusd.sock
Listening on proxy address * port 1814
Ready to process requests.
到此處freeradius已經(jīng)安裝成功了
6.對(duì)freeradius詳細(xì)配置,因?yàn)槲覀冃枰蚏M整合,這里就需要詳細(xì)的配置radius文件
首先說(shuō)明一下在使用LNMP環(huán)境包,也可以簡(jiǎn)單的安裝freeradius,簡(jiǎn)單安裝步驟如下
使用命令:yum install perl-DBI freeradius freeradius-mysql freeradius-utils
可以一步到位安裝好radius,我個(gè)人建議使用安裝包一步步安裝,這樣發(fā)現(xiàn)問(wèn)題可以隨時(shí)找到問(wèn)題并解決
對(duì)于配置radius文件有兩種方法:
A:簡(jiǎn)單的方法使用glzjin(趙一初心)寫(xiě)好的文件直接覆蓋
wget ?-O /etc/raddb/radiusd.conf
wget ?-O /etc/raddb/sites-enabled/default
wget ?-O /etc/raddb/sql/mysql/dialup.conf
wget ?-O /etc/raddb/dictionary
wget ?-O /etc/raddb/sql/mysql/counter.conf
B:詳細(xì)的手動(dòng)配置如下
#編輯/usr/local/etc/raddb/radiusd.conf文件
vi /usr/local/etc/raddb/radiusd.conf
查找”allow_vulnerabel_openssl = no”改為yes
查找” $INCLUDE sql.conf”(743行),去掉#號(hào)
查找” $INCLUDE sql/mysql/counter.conf”(712行),去掉#號(hào)
#清空/usr/local/etc/raddb/sites-enabled/default文件,直接把已經(jīng)配置好的文件內(nèi)容復(fù)制進(jìn)去保存
cat /dev/null > /usr/local/etc/raddb/sites-enabled/default
vi /usr/local/etc/raddb/sites-enabled/default
#清空/usr/local/etc/raddb/sites-enabled/inner-tunnel文件,直接把已經(jīng)配置好的文件內(nèi)容復(fù)制進(jìn)去保存
cat /dev/null > /usr/local/etc/raddb/sites-enabled/inner-tunnel
vi ?/usr/local/etc/raddb/sites-enabled/inner-tunnel
#編輯/usr/local/etc/raddb/eap.conf,修改MD5驗(yàn)證方式為peap方式
vi ?/usr/local/etc/raddb/eap.conf
第30行default_eap_type = md5改為default_eap_type = peap
#編輯/usr/local/etc/raddb/modules/mschap文件,修改為如下內(nèi)容
vi /usr/local/etc/raddb/modules/mschap
mschap { use_mppe = yes require_encryption = yes require_strong = yes }
#編輯/usr/local/etc/raddb/sql/mysql/dialup.conf文件
vi /usr/local/etc/raddb/sql/mysql/dialup.conf
查找simul_count_query將279-282行注釋去掉,打開(kāi)simul_count_query函數(shù)
#編輯/usr/local/etc/raddb/sql/mysql/counter.conf文件,添加自定義計(jì)算函數(shù)
monthlytrafficcounter(每月計(jì)算流量) 和 yearlytrafficcounter(每年計(jì)算流量)
vi /usr/local/etc/raddb/sql/mysql/counter.conf
在末尾加入
sqlcounter monthlytrafficcounter {
? ?counter-name = Monthly-Traffic
? ?check-name = Max-Monthly-Traffic
? ?reply-name = Monthly-Traffic-Limit
? ?sqlmod-inst = sql
? ?key = User-Name
? ?reset = monthly
? ?query = ” SELECT ABS(SUM(acctinputoctets + acctoutputoctets) DIV 1048576) FROM radacct WHERE UserName=’%{%k}’ AND AcctStartTime >= date_sub(curdate(),interval 30 day)”
}
sqlcounter yearlytrafficcounter {
? ?counter-name = Yearly-Traffic
? ?check-name = Max- Yearly-Traffic
? ?reply-name = Yearly-Traffic-Limit
? ?sqlmod-inst = sql
? ?key = User-Name
? ?reset = never
? ?query = ” SELECT ABS(SUM(acctinputoctets + acctoutputoctets) DIV 1048576) FROM radacct WHERE UserName=’%{%k}’ AND AcctStartTime >= date_sub(curdate(),interval 365 day)”
}
#編輯字典文件/usr/local/etc/raddb/dictionary
vi /usr/local/etc/raddb/dictionary
#添加以下內(nèi)容
ATTRIBUTE ? ? ? Max-Monthly-Traffic ? ? 3003 ? ?integer
ATTRIBUTE ? ? ? Monthly-Traffic-Limit ? 3004 ? ?integer
ATTRIBUTE ? ? ? Acct-Interim-Interval ? 85 ? ? ?integer
ATTRIBUTE ? ? ? Max-Yearly-Traffic ? ? ?3003 ? ?integer
ATTRIBUTE ? ? ? Yearly-Traffic-Limit ? ?3004 ? ?integer
7.建立MySql相關(guān)的數(shù)據(jù)庫(kù)并作設(shè)置
兩種方法如下:
A。使用phpmyadmin建立
LNMP環(huán)境下帶phpmyadmin,http://你的IP/phpmyadmin
建立兩個(gè)數(shù)據(jù)庫(kù)radius和conntrack
進(jìn)入后點(diǎn):賬號(hào)—新增用戶(hù)賬號(hào)
填寫(xiě)好用戶(hù)名和密碼,一定點(diǎn)擊(用戶(hù)賬號(hào)數(shù)據(jù)庫(kù)下的創(chuàng)建與用戶(hù)同名的數(shù)據(jù)庫(kù)并授予所有權(quán)限。)
B。使用ssh登陸命令建立
mysql -u root -p密碼 ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #登錄mysql,超級(jí)賬號(hào)root和密碼
CREATE DATABASE radius; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #創(chuàng)建radius數(shù)據(jù)庫(kù)
CREATE DATABASE conntrack; ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?#創(chuàng)建conntrack數(shù)據(jù)庫(kù)
CREATE USER ‘radius’@’localhost’ IDENTIFIED BY ‘radius123′; ? ? #創(chuàng)建用戶(hù)radius,密碼radius123
CREATE USER ‘conntrack’@’localhost’ IDENTIFIED BY ‘conn123′; ? ?#創(chuàng)建用戶(hù)conntrack,密碼conn123
GRANT ALL ON radius.* TO radius@localhost; ? ? ? ? ? ? ? ? ? ? ?#給radius數(shù)據(jù)庫(kù)設(shè)置訪問(wèn)權(quán)限
GRANT ALL ON conntrack.* TO conntrack@localhost; ? ? ? ? ? ? ? ?#給conntrack數(shù)據(jù)庫(kù)設(shè)置訪問(wèn)權(quán)限
8.配置freeradius數(shù)據(jù)庫(kù)
/usr/local/etc/raddb/sql.conf ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? #使用radius/radius123
# Connection info:
server = “l(fā)ocalhost”
#port = 3306
login = “radius”
password = “radius123″
找到readclients一行,設(shè)為yes并去掉注釋符號(hào)#
這里要特別說(shuō)明一下,如果在安裝freeraduis是使用的是第6點(diǎn)里yun直接安裝的話,那么sql.conf這個(gè)文件
在/etc/raddb/sql.conf 這個(gè)目錄里。
9.關(guān)閉SELINUX(需重啟機(jī)器生效)
/etc/sysconfig/selinux
SELINUX=disabled
10.修改機(jī)器MAC地址,因?yàn)槲蚁螺dRM3.9版本是破解的,授權(quán)文件和MAC地址都是破解者發(fā)布的(需要重啟生效PS:RM4.16是不是也可以使用同樣方法處理,有研究出來(lái)的朋友,可以和我交流一下)
不能使用這個(gè)命令:ifconfig eth0 down(禁用網(wǎng)卡),你是ssh鏈接的使用了這個(gè),你立馬就掉線了,不用我說(shuō)原因吧。
正確的方法:
使用winscp下載 /etc/sysconfig/network-scripts里ifcfg-eth0
修改其中的”HWADDR=xx:xx:xx:xx:xx:xx”為”MACADDR=00:D0:09:B8:B7:34″
上傳覆蓋,重啟機(jī)器以后生效。
11.安裝Radius Manager
首先為Radius Manager建立一個(gè)web
使用lnmp vhost add,此次不需要?jiǎng)?chuàng)建mysql數(shù)據(jù)庫(kù)了,在上面我們已經(jīng)創(chuàng)建好了。
使用winscp上傳radiusmanager-3.9.0.tar.gz到root目錄
tar zxvf radiusmanager-3.9.0.tar.gz
cd radiusmanager-3.9.0
chmod ?755 ?install.sh
./install.sh
出現(xiàn)Radius Manager installer
Copyright 2004-2011, DMA Softlab LLC
All right reserved.
(Use CTRL+C to abort any time)
Select the type of your operating system:
1. Redhat (Fedora, CentOS etc.)
2. Debian (Ubuntu etc.)
Choose an option: [1](我的是centos系統(tǒng))
Selected operating system is: REDHAT
Select installation type:
1. New installation
2. Upgrade old system
Choose an option: [1](全新安裝)
Selected installation method: NEW INSTALLATION
WWW root path: [/var/www/html] ? ? ? 這里改成我們建立的web目錄/home/wwwroot/你的域名
RADIUS database host: [localhost]
RADIUS database username: [radius] ? ? ? ? ? ? ? ? ? ? ? ?#使用radius
RADIUS database password: [radius123] ? ? ? ? ? ?你建立的radius數(shù)據(jù)庫(kù)的密碼
CTS database host: [localhost]
CTS database username: [conntrack] ? ? ? ? ? ? ? ? ? ? ? ?#使用conntrack
CTS database password: [conn123] ? ? ? ? ? ? ? ? 你建立的conntrack的密碼
Freeradius UNIX user: [root] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?#使用root
Httpd UNIX user: [apache] ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? 改成WWW
Create rmpoller service: [y]
Create rmconntrack service: [y]
Back up RADIUS database: [y]
WARNING! If You continue You will overwrite the existing RADIUS database!
Are You sure to start the installation? [n] y
Starting installation process…
Copying WEB content to /home/wwwroot/你的域名/radiusmanager
Copying binaries to /usr/local/bin
Copying rootexec to /usr/local/sbin
Copying radiusmanager.cfg to /etc
Backing up RADIUS database…
Creating MySQL tables
Creating rmpoller service
Creating rmconntrack service
Copying logrotate script
Setting permission on raddb files
Copying radiusd init script to /etc/init.d
Installation finished!
12.修改RM配置文件
/etc/radiusmanager.cfg
/home/wwwroot/你的域名/radiusmanager/config/system_cfg.php
13.修改RM文件從根目錄到主目錄
cd radiusmanager –> mv * ../ –> cd ../
14.修改目錄文件權(quán)限
chattr -i /home/wwwroot/你的域名/.user.ini
chown www:www -R /home/wwwroot/你的域名
chmod -R 777 /home/wwwroot/你的域名
chmod 755 /usr/local/bin/rmauth
chmod 755 /usr/local/bin/rmacnt
chmod 755 /usr/local/bin/rmpoller
chmod 600 /etc/radiusmanager.cfg
chmod 755 /usr/local/bin/rmconntrack
chmod 4755 /usr/local/sbin/rootexec
重啟服務(wù)器。訪問(wèn)地址你的域名/admin.php ?賬號(hào)admin 密碼1111
? ? ? ? ? ?用戶(hù)訪問(wèn)地址你的域名/user.php 賬號(hào)user 密碼1111
?