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

WBOY
풀어 주다: 2016-06-01 13:32:23
원래의
1608명이 탐색했습니다.

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、开启另外一个终端进行测试,如图:

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

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
로그인 후 복사

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

请先用 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插件:

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

[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数据库,所以做了权限等方便的修改:

CentOS 5.4 pptp + freeradius2 +mysql +daloradius完美整合(图_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 &#39;help;&#39; or &#39;/h&#39; for help. Type &#39;/c&#39; 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 &#39;root&#39;@&#39;%&#39; IDENTIFIED BY &#39;leekwen&#39; 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 时会加载配置文件;

如果看到加载的配置文件时,出现下面的错误:

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

!!! 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服务,并在数据库总插入测试账号,并查看测试结果!

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

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、重新启动相关服务后,进行数据库用户测试!

 

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

 

5、此测试通过后,进行客户端的拨号连接,并在服务端查看客户端的拨号日志:

 

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

 

6、到此,已经完成了pptpd + freeradius2 + mysql 三者之间的整合.

bitsCN.com
관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿
회사 소개 부인 성명 Sitemap
PHP 중국어 웹사이트:공공복지 온라인 PHP 교육,PHP 학습자의 빠른 성장을 도와주세요!