您好,欢迎访问一九零五行业门户网

CentOS 5.4 pptp + freeradius2 +mysql +daloradius完美整合(图_MySQL

pptpcentos
bitscn.com centos 5.4 pptp + freeradius2 +mysql +daloradius完美整合(图文并茂)
一、安装相关配置包
1、安装httpd、mysql及php相关包[plain] 1. [root@localhost ~]# yum -y install httpd httpd-devel mysql mysql-server mysql-devel 2. [root@localhost ~]# yum -y install php php-devel php-mysql php-common php-gd php-mbstring php-mcry 2、配置httpd服务:[plain] 1. [root@localhost ~]# netstat -ant |grep 80 2. [root@localhost ~]# /etc/init.d/httpd start 3. starting httpd: [ ok ] 4. [root@localhost ~]# vi /etc/sysconfig/iptables 5. [root@localhost ~]# grep 80 /etc/sysconfig/iptables 6. -a rh-firewall-1-input -p tcp -m tcp --dport 80 -j accept #增加此行 7. [root@localhost ~]# /etc/init.d/iptables restart 8. flushing firewall rules: [ ok ] 9. setting chains to policy accept: filter nat [ ok ] 10. unloading iptables modules: [ ok ] 11. applying iptables firewall rules: [ ok ] 12. loading additional iptables modules: ip_conntrack_netbios_n[ ok ] 13. [root@localhost ~]# chkconfig httpd --list 14. httpd 0:off 1:off 2:off 3:off 4:off 5:off 6:off 15. [root@localhost ~]# chkconfig httpd on #设置httpd自动启动 16. [root@localhost ~]# chkconfig httpd --list 17. httpd 0:off 1:off 2:on 3:on 4:on 5:on 6:off 18. [root@localhost ~]# netstat -ant |grep 80 19. tcp 0 0 :::80 :::* listen 3、启动mysql数据库:[plain] 1. [root@localhost ~]# /etc/init.d/mysqld start 2. initializing mysql database: installing mysql system tables... 3. ok 4. filling help tables... 5. ok 6. 7. to start mysqld at boot time you have to copy 8. support-files/mysql.server to the right place for your system 9. 10. please remember to set a password for the mysql root user ! 11. to do so, start the server, then issue the following commands: 12. /usr/bin/mysqladmin -u root password 'new-password' 13. /usr/bin/mysqladmin -u root -h localhost.localdomain password 'new-password' 14. 15. alternatively you can run: 16. /usr/bin/mysql_secure_installation 17. 18. see the manual for more instructions. 19. 20. you can start the mysql daemon with: 21. cd /usr ; /usr/bin/mysqld_safe & 22. 23. you can test the mysql daemon with mysql-test-run.pl 24. cd mysql-test ; perl mysql-test-run.pl 25. 26. please report any problems with the /usr/bin/mysqlbug script! 27. 28. the latest information about mysql is available on the web at 29. http://www.mysql.com 30. support mysql by buying support/licenses at http://shop.mysql.com 31. [ ok ] 32. starting mysqld: [ ok ] 4、设置数据库密码;[plain] 1. [root@localhost ~]# mysqladmin -u root password 'leekwen' 5、安装freeradius2相关包[plain] 1. [root@localhost ~]# yum install -y freeradius2 freeradius2-mysql freeradius2-utils 6、启动radius进程,调试模式:[plain] 1. [root@localhost ~]# radiusd -x 2. freeradius version 2.1.12, for host i386-redhat-linux-gnu, built on jan 9 2013 at 05:02:57 3. copyright (c) 1999-2009 the freeradius server project and contributors. 4. ... adding new socket proxy address * port 51738 5. listening on authentication address * port 1812 6. listening on accounting address * port 1813 7. listening on command file /var/run/radiusd/radiusd.sock 8. listening on authentication address 127.0.0.1 port 18120 as server inner-tunnel 9. listening on proxy address * port 1814 10. ready to process requests.
7、开启另外一个终端进行测试,如图:
8、如果结果与上图不同,请临时关闭防火墙后,临时关闭防火墙命令如下:
[plain] 1. [root@localhost ~]# iptables -f 重新运行测试命令:[plain] 1. [root@localhost ~]# radtest steve testing localhost 1812 testing123 ############### !!error !! ###############failed binding to authentication address * port 1812: address already in use/etc/raddb/radiusd.conf[240]: error binding to port for 0.0.0.0 port 1812
请先用 lsof 命令查看,再用 killall -9 radiusd命令结束后,重新开启服务后,在进行测试!
二、下载ppp源码文件,集成ppp client:
1、下载源码:
[plain] 1. [root@localhost ~]# wget ftp://ftp.samba.org/pub/ppp/ppp-2.4.4.tar.gz 2. --2013-07-01 18:33:36-- ftp://ftp.samba.org/pub/ppp/ppp-2.4.4.tar.gz 3. => `ppp-2.4.4.tar.gz' 4. resolving ftp.samba.org... 216.83.154.106, 2001:470:1f05:1a07::1 5. connecting to ftp.samba.org|216.83.154.106|:21... connected. 6. logging in as anonymous ... logged in! 7. ==> syst ... done. ==> pwd ... done. 8. ==> type i ... done. ==> cwd /pub/ppp ... done. 9. ==> size ppp-2.4.4.tar.gz ... 688763 10. ==> pasv ... done. ==> retr ppp-2.4.4.tar.gz ... done. 11. length: 688763 (673k) 12. 13. 100%[===========================================>] 688,763 135k/s in 5.3s 14. 15. 2013-07-01 18:33:45 (127 kb/s) - `ppp-2.4.4.tar.gz' saved [688763] 2、解压并做相关配置[plain] 1. [root@localhost ~]# tar zxf ppp-2.4.4.tar.gz 2. [root@localhost ~]# cp -r ppp-2.4.4/pppd/plugins/radius/etc/ /etc/radiusclient 3. [root@localhost ~]# cp /etc/radiusclient/radiusclient.conf /etc/radiusclient/radiusclient.conf.bak 4. [root@localhost ~]# vi /etc/radiusclient/radiusclient.conf 5. 行号 修改前的配置文件 修改后的配置文件 6. 25 issue /usr/local/etc/radiusclient/issue 修改为:issue /etc/radiusclient/issue 7. 46 servers /usr/local/etc/radiusclient/servers 修改为:servers /etc/radiusclient/servers 8. 50 dictionary /usr/local/etc/radiusclient/dictionary 修改为:dictionary /etc/radiusclient/dictionary 9. 61 mapfile /usr/local/etc/radiusclient/port-id-map 修改为:mapfile /etc/radiusclient/port-id-map 说明:修改相关配置文件的路径,确保radiusclient.conf这个文件中radiusclient相关的路径都是“/etc/radiusclient”开头的.3、配置字典文件:[plain] 1. [root@localhost ~]# ls -l /etc/radiusclient/dictionary* 2. -rw-r--r-- 1 root root 7656 jul 1 18:34 /etc/radiusclient/dictionary 3. -rw-r--r-- 1 root root 12295 jul 1 18:34 /etc/radiusclient/dictionary.ascend 4. -rw-r--r-- 1 root root 1395 jul 1 18:34 /etc/radiusclient/dictionary.compat 5. -rw-r--r-- 1 root root 599 jul 1 18:34 /etc/radiusclient/dictionary.merit 6. -rw-r--r-- 1 root root 2649 jul 1 18:34 /etc/radiusclient/dictionary.microsoft 7. [root@localhost ~]# vi /etc/radiusclient/dictionary 8. 行号 文件内容 9. 253 include /etc/radiusclient/dictionary.microsoft 10. 254 include /etc/radiusclient/dictionary.merit #增加此行 11. 255 include /etc/radiusclient/dictionary.ascend #增加此行 12. 256 include /etc/radiusclient/dictionary.compat #增加此行
4、在pptpd服务中添加freeradius插件:
[plain] 1. [root@localhost ~]# vi /etc/ppp/options.pptpd 2. 行号 文件内容 3. 128 # put plugins here 4. 129 # (putting them higher up may cause them to sent messages to the pty) 5. 130 plugin /usr/lib/pppd/2.4.4/radius.so #增加此行 6. 131 plugin /usr/lib/pppd/2.4.4/radattr.so #增加此行 7. 132 radius-config-file /etc/radiusclient/radiusclient.conf #增加此行 8. [root@localhost ~]# tail -n 3 /etc/ppp/options.pptpd 9. plugin /usr/lib/pppd/2.4.4/radius.so 10. plugin /usr/lib/pppd/2.4.4/radattr.so 11. radius-config-file /etc/radiusclient/radiusclient.conf
三、建立radius数据库及导入相应的数据库表:
可采用命令或使用navicat for mysql工具来完成:
1、radius中提供了mysql的导入文件:[plain] 1. [root@localhost ~]# ls /etc/raddb/sql/mysql/*.sql -l 2. -rw-r----- 1 root radiusd 661 jan 9 02:04 /etc/raddb/sql/mysql/admin.sql 3. -rw-r----- 1 root radiusd 452 jan 9 02:04 /etc/raddb/sql/mysql/cui.sql 4. -rw-r----- 1 root radiusd 761 jan 9 02:04 /etc/raddb/sql/mysql/ippool.sql 5. -rw-r----- 1 root radiusd 399 jan 9 02:04 /etc/raddb/sql/mysql/nas.sql 6. -rw-r----- 1 root radiusd 4318 jan 9 02:04 /etc/raddb/sql/mysql/schema.sql 7. -rw-r----- 1 root radiusd 407 jan 9 02:04 /etc/raddb/sql/mysql/wimax.sql
2、这里采用了命令方式,首先建立radius数据库:
为了方便以后使用navicat for mysql工具管理mysql数据库,所以做了权限等方便的修改:
3、具体操作可复制代码:
[plain] 1. [root@localhost ~]# mysql -uroot -p 2. enter password: 3. welcome to the mysql monitor. commands end with ; or /g. 4. your mysql connection id is 4 5. server version: 5.0.95 source distribution 6. 7. copyright (c) 2000, 2011, oracle and/or its affiliates. all rights reserved. 8. 9. oracle is a registered trademark of oracle corporation and/or its 10. affiliates. other names may be trademarks of their respective 11. owners. 12. 13. type 'help;' or '/h' for help. type '/c' to clear the current input statement. 14. 15. mysql> show databases; 16. +--------------------+ 17. | database | 18. +--------------------+ 19. | information_schema | 20. | mysql | 21. | test | 22. +--------------------+ 23. 3 rows in set (0.00 sec) 24. 25. mysql> create database radius default character set utf8 collate utf8_general_ci; 26. query ok, 1 row affected (0.00 sec) 27. 28. mysql> grant all privileges on *.* to 'root'@'%' identified by 'leekwen' with grant option; 29. query ok, 0 rows affected (0.00 sec) 30. 31. mysql> flush privileges; 32. query ok, 0 rows affected (0.00 sec) 33. 34. mysql> /q; 35. bye 36. [root@localhost ~]# mysql -uroot -p radius < /etc/raddb/sql/mysql/admin.sql 37. enter password: 38. [root@localhost ~]# mysql -uroot -p radius < /etc/raddb/sql/mysql/cui.sql 39. enter password: 40. [root@localhost ~]# mysql -uroot -p radius < /etc/raddb/sql/mysql/ippool.sql 41. enter password: 42. [root@localhost ~]# mysql -uroot -p radius < /etc/raddb/sql/mysql/nas.sql 43. enter password: 44. [root@localhost ~]# mysql -uroot -p radius < /etc/raddb/sql/mysql/schema.sql 45. enter password: 46. [root@localhost ~]# mysql -uroot -p radius < /etc/raddb/sql/mysql/wimax.sql 47. enter password: 4、防火墙中关于数据库相关的设置:[plain] 1. [root@localhost ~]# grep 3306 /etc/sysconfig/iptables 2. [root@localhost ~]# vi /etc/sysconfig/iptables 3. [root@localhost ~]# /etc/init.d/iptables restart 4. flushing firewall rules: [ ok ] 5. setting chains to policy accept: filter nat [ ok ] 6. unloading iptables modules: [ ok ] 7. applying iptables firewall rules: [ ok ] 8. loading additional iptables modules: ip_conntrack_netbios_n[ ok ] 9. [root@localhost ~]# grep 3306 /etc/sysconfig/iptables 10. -a rh-firewall-1-input -p tcp -m tcp --dport 3306 -j accept
四、修改radius的相关配置文件:
[plain] 1. [root@localhost ~]# cp /etc/raddb/radiusd.conf /etc/raddb/radiusd.conf.bak 2. [root@localhost ~]# vi /etc/raddb/radiusd.conf 3. 行号 | 修改后配置 | 未修改的配置 4. 700 | $include sql.conf | # $include sql.conf <------去掉注释# 5. 712 | $include sql/mysql/counter.conf| # $include sql/mysql/counter.conf <------去掉注释# 6. 7. [root@localhost ~]# cp /etc/raddb/sql.conf /etc/raddb/sql.conf.bak 8. [root@localhost ~]# vi /etc/raddb/sql.conf 9. 行号 | 修改后配置 | 未修改的配置 10. 38 | login = root | login = radius <------修改连接mysql的用户名 11. 39 | password = leekwen | password = radpass<------修改连接mysql的密码 12. 100 | readclients = yes | #readclients = yes <------去掉注释#
说明:如果在运行radiusd -x 时会加载配置文件;
如果看到加载的配置文件时,出现下面的错误:
!!! error !!!
duplicate virtual server inner-tunnel in file /etc/raddb/sites-enabled/inner-tunnel:11
and file /etc/raddb/sites-enabled/inner-tunnel.bak:11
请将/etc/raddb/sites-enabled/inner-tunnel.bak 与 /etc/raddb/sites-enabled/default.bak全部删除,
这也是为什么下面在编辑前没有备份这两个文件的原因:
[plain] 1. [root@localhost ~]# vi /etc/raddb/sites-enabled/default 2. 行号 | 修改后配置 | 未修改的配置 3. 170 # files | files <------增加注释# 4. 177 sql | # sql <------去掉注释# 5. 372 # files | files <------增加注释# 6. 406 sql | # sql <------去掉注释# 7. 454 sql | # sql <------去掉注释# 8. 475 sql | # sql <------去掉注释# 9. 10. [root@localhost ~]# vi /etc/raddb/sites-enabled/inner-tunnel 11. 行号 | 修改后配置 | 未修改的配置 12. 124 # files | files <------增加注释# 13. 131 sql | # sql <------去掉注释# 14. 255 sql | # sql <------去掉注释# 15. 277 sql | # sql <------去掉注释#
2、启动radiusd服务,并在数据库总插入测试账号,并查看测试结果!
3、测试通过后,修改默认密钥密码:
[plain] 1. [root@localhost ~]# cp /etc/raddb/clients.conf /etc/raddb/clients.conf.bak 2. [root@localhost ~]# vi /etc/raddb/clients.conf 3. 4. 行号 | 修改后配置 | 未修改的配置 5. 101 secret = leekwen | secret = testing123
4、重新启动相关服务后,进行数据库用户测试!
5、此测试通过后,进行客户端的拨号连接,并在服务端查看客户端的拨号日志:
6、到此,已经完成了pptpd + freeradius2 + mysql 三者之间的整合.
bitscn.com
其它类似信息

推荐信息