CentOS 6.x Radius

一、   实现环境:
1.系统:CentOS  release  6.6 (Final)
2.需要软件包:
1) freeradius-2.1.12-6.e16.x86_64
  freeradius-mysql-2.1.12-6.e16.x86_64
2) ppp-2.4.5-5.e16.x86_64
3) rp-pppoe-3.10-11.e16.x86_64
4) mysql-5.1.73-3.e16_5.x86_64
  mysql-devel-5.1.73-3.e16_5.x86_64
5) openssl-1.0.1e-30.e16_6.5.x86_64
二、服务器实际部署环境和简单原理分析:
           Radius是Remote Access Dial In User Service的简称。Radius主要用来提供认证(Authentication)机制,用来辨认使用者的身份与密码,确认通过之后,经由授权(Authorization)使用者登入网域使用相关资源并可提供计费(Accounting)机制,保存使用者的网络记录。Freeradius是一款OpenSource软件,基于radius协议,实现RADIUS AAA(Authentication、Authorization、Accounting)功能。
如下拓扑图所示,为该radius服务器实际运行环境和功能。
Radius服务器和接入服务器配合使用实现用户宽带账号计费拨号获取权限连接Internet网络。
三、Radius服务器搭建:
      1.安装CentOS系统配置好网络之后使用命令:#yum update 更新系统。
      2.查看各个软件包是否安装:#rpm –q ppp rp-pppoe freeradius mysql-* openssl
如果没有安装则使用命令:#yum install ppp rp-pppoe freeradius-* mysql-* openssl
进行安装,一般openssl在系统更新之后就已经安装好了。安装好各个软件之后,使用命令:
#wget ftp://ftp.samba.org/pub/ppp/ppp-2.4.5.tar.gz 下载ppp源代码包到创建的/etc/ppp/radius目录下。(#mkdir /etc/ppp/radius //创建目录)
下面就对各服务进行配置:
1. 配置 /etc/ppp/options文件:
lock
crtscts
nobsdcomp
nodeflate
nopcomp
      2. 配置/etc/ppp/pppoe-server-options文件,内容为:
# PPP options for the PPPoE server
# LIC: GPL
auth
require-chap
default-mru
default-asyncmap
lcp-echo-interval 60
lcp-echo-failure 5
ms-dns 202.96.128.86
noipdefault
noipx
nodefaultroute
proxyarp
noktune
logfile /var/log/pppd.log
3.让pppoe服务使用freeradius服务器进行验证
1)首先更改/etc/ppp/pppoe-server-options,添加两行设置:
#PPP options for the PPPoE server
#LIC: GPL
auth
require-chap
default-mru
default-asyncmap
lcp-echo-interval 60
lcp-echo-failure 5
ms-dns 202.96.128.86
noipdefault
noipx
nodefaultroute
proxyarp
noktune
->plugin    /usr/lib/pppd/2.4.5/radius.so
->radius-config-file /etc/ppp/radiuds/radiusclient.conf
logfile /var/log/pppd.log
表示让pppoe-server在运行时加入pppd的radius查检,可以让pppoe服务通过freeradius来验证和记账。 添加此行之后,可以创建/etc/ppp/radiuds/目录,创建完之后,需要使用一下ppp的源代码。 解压ppp的源代码目录:
#tar -xzf ppp-2.4.5.tar.gz
#cd ppp-2.4.5
#cd pppd/plugins/radius/etc/
#cp  *  /etc/ppp/radiuds/
2) 这个目录下有需要的所有相关的配置文件,其中最重要的是/etc/ppp/radiuds/radiusclient.conf,先打开此文件配置,其内容为(已去掉注释):
auth_order  radius
login_tries 4
login_timeout 60
nologin  /etc/nologin
issue  /etc/ppp/radiuds/issue
authserver  localhost:1812
acctserver  localhost:1813
servers  /etc/ppp/radiuds/servers
dictionary  /etc/ppp/radiuds/dictionary
login_radius  /usr/local/sbin/login.radius
seqfile  /var/run/radius.seq
mapfile  /etc/ppp/radiuds/port-id-map
default_realm
radius_timeout  10
radius_retries  3
login_local  /bin/login
3) 另外,还需更改此目录下的servers文件,此文件用来指定读取的radius服务器的主机名称以及key值(需要在freeradius配置中指定)。
编辑 /etc/ppp/radius/servers ,设定radius 服务器的位置
localhost  testing123 //这里的testing123是密码
4) 编辑/etc/ppp/radius/dictionary ,修改一些路径设置,主要是最后一个dictionary.microsoft 的路径设置。
INCLUDE /etc/ppp/radiuds/dictionary.microsoft
5) 此时pppoe服务已经可以通过radius认证了。然后进行freeradius的配置。
其中freeradius-mysql包使用来让freeradius连接mysql数据库的,本部分还用不到。
首先打开/etc/raddb/clients.conf配置客户端访问控制,文件内容如下:
Client localhost {
Secret = testing123
Shortname = localhost
Nastype = other
}
表示客户端之允许从127.0.0.1的ip登录radius服务,并且需要验证的secret为testing123,就是在上面的servers文件中需要配置的信息。若要实现可以从别的机器访问,请参考注释获得帮助。
6)然后配置/etc/raddb/naslist文件,内容为:
# NAS Name  Short Name Type
#portmaster1.isp.com   pm1.NY
livingston
#portmaster2.isp.com  pm1.LA
livingston
localhost  local  portslave
此文件用来配置记录有哪些指定的nas服务器需要使用radius进行记账。现在指定的是localhost。
7)主控配置文件是radiusd.conf,此文件主要是用来指定freeradius服务器默认的验证和记账方式。我们目前使用本地的文件方式,就是/etc/raddb/users文件,在其中添加需要提供给pppoe服务认证的用户信息,内容如下(用户名前面一定不能有空格):
Aaa Auth-Type := Local, Simultaneous-Use := 1,User-Password:= "aaa"
[tab]Service-Type = Framed-User,
[tab]Framed-Protocol = PPP,
[tab]Framed-IP-Netmask = 255.255.255.255
其中Simultaneous-Use :=1字段用来设置每个用户同时登录的个数。
8) 为了让radius能正确地调用mysql,还要指定一下库的位置:
echo /usr/lib >> /etc/ld.so.conf
ldconfig
9) 都配置完毕后,可以通过radiusd -X命令以排错方式启动,此时再启动pppoe-server,用客户端拨号验证一下,检查pppoe服务是否成 功通过freeradius来验证用户。如果成功,这一部分完成。可通过service radius restart来正常启动radius服务。
Radiusd  -X
radtest  aaa  aaa  localhost  0  testing123
看到 Access-Accept 之类的字样就表示成功了。这时可以正式启动radiusd。
5. 配置freeradius从mysql数据库读取用户信息
      1.#mysql –u root –p 123  //登录mysql
      2.>create database radius;  //创建数据库
      3.>exit  //退出数据库
      4.#cd /etc/raddb/sql/mysql
      5.#mysql –u root –p radius < schema.sql   //把表导入到数据库中,到数据库中查看是否导入7张表
      6.修改/etc/raddb/sites-enabled/default文件,把authorize{}、accounting{}中的sql的注释#去掉,并把authorize{}中的files的注释#加上。如下所示:
Authorize{
Chap
Mschap
Suffix
Eap
#files
Sql
Pap
}
Accounting{
Detail
Unix
Redutmp
sql
}
      7.修改mysql数据库连接的配置文件/etc/raddb/sql.conf
      Server = “localhost”
      Login = “root”
      Password = “123”
      Radius_db  = “radius”  //数据库名称
      8.修改/etc/raddb/radius.conf文件:
      将$INCLUDE  sql.conf的注释#去掉即可。
      9.在数据库中加入测试账号:
      #mysql –u root –p 123
      >use radius;
建立组信息:
      >insert into radgroupreply (groupname,attribute,op,value) values (’user’,’Auth-Type’,’:=’,’Local’);
      > insert into radgroupreply (groupname,attribute,op,value) values (’user’,’Service-Type’,’:=’,’Framed-User’);
      > insert into radgroupreply (groupname,attribute,op,value) values (’user’,’Feamed-IP-Address’,’:=’,’255.255.255.255’);
      > insert into radgroupreply (groupname,attribute,op,value) values (’user’,’Framed-IP-Netmask’,’:=’,’255.255.255.0’);
建立用户信息:
      > insert into radcheck (username,attribute,op,value) values (’test’,’User-Password’,’:=’,’110’);
将用户加入组中:
      > insert into radusergroup (username,groupname) values (’test’,’user’);
      >exit;  //退出数据库
四、测试radius:
1.#radius –X //以检错方式启动radius服务
2.开另一个终端使用命令:
#radtest  test  110  localhost  10  testing123  进行测试。
如果显示Access-Accept则表示安装成功。   

CentOS 6.x Radius的更多相关文章

  1. CentOS安装配置radius服务器

    1.安装 Yum install -y freeradius freeradius-mysql freeradius-utils 2.配置 1)修改 clients.conf # vi /usr/lo ...

  2. List of CentOS Mirrors

    From:https://www.centos.org/download/mirrors/ CentOS welcomes new mirror sites. If you are consideri ...

  3. [原创]CentOS下Radius服务器搭建

    一.   实现环境: 1.系统:CentOS  release  6.6 (Final) 2.需要软件包: 1) freeradius-2.1.12-6.e16.x86_64 freeradius-m ...

  4. Linux(Centos)之安装Redis及注意事项

    1.redis简单说明 a.在前面我简单的说过redis封装成共用类的实现,地址如下:http://www.cnblogs.com/hanyinglong/p/Redis.html. b.redis是 ...

  5. CentOS 7 中firewall-cmd命令

    在 CentOS 7 暂时开放 ftp 服务# firewall-cmd --add-service=ftp 永久开放 ftp 服务# firewall-cmd --add-service=ftp - ...

  6. Jumpserver之安装在CentOS主机步骤

    环境 系统CentOS7.5 IP:172.16.90.248 关闭防火墙设置selinux systemctl stop firewalld setenforce 0 sed -i "s/ ...

  7. CentOS7用hostapd做radius服务器为WiFi提供802.1X企业认证

    CentOS7用hostapd做radius服务器为WiFi提供802.1X企业认证 来源: https://www.cnblogs.com/osnosn/p/10593297.html 来自osno ...

  8. Linux 系统 pptpd+radius+mysql 安装攻略

    分类: 原文地址:Linux 系统 pptpd+radius+mysql 安装攻略 作者:wfeng .你所需要的软件 内核最好能升级到2.6 如果你是centos的用户,可以通过yum update ...

  9. CentOS 7.0如何安装配置iptables和seLinux以及firewalld

    一.配置防火墙,开启80端口.3306端口 CentOS .0默认使用的是firewall作为防火墙,这里改为iptables防火墙. .关闭firewall: systemctl stop fire ...

随机推荐

  1. (转载)RedHat Enterprise Linux 5 安装GCC

    注:在RedHat Enterprise Linux 5使用gcc编译第一个程序时,发现其gcc并未安装.在网上搜索看到这篇帖子.遂转到此处进行学习.感谢博客园中的“风尘孤客”的分享.@风尘孤客 Ab ...

  2. windows定时执行python脚本

    from:http://blog.csdn.net/Gpwner/article/details/77882131

  3. Web前端技术体系大全搜索

    一.前端技术框架 1.Vue.js 官网:https://cn.vuejs.org/ Vue CLI:https://cli.vuejs.org/ 菜鸟教程:http://www.runoob.com ...

  4. ios NSRange

    Objective-C中判断字符串是否包含其他字符串 -(BOOL) hasPrefix:(NSString *) astring;检查字符串是否以astring开头:-(BOOL) hasSuffi ...

  5. Shell替换数组元素之间的间隔符号

    Shell中的数组是这样表示的: arr=(1,2,3,4,5) 它们数组元素的间隔符号为逗号,如果我相把逗号替换为加号: echo ${arr//,/+} 输出: 1+2+3+4+5 这个表达式是我 ...

  6. (4) openssl rsa/pkey(查看私钥、从私钥中提取公钥、查看公钥)

    openssl  rsa      是RSA对称密钥的处理工具 openssl  pkey   是通用非对称密钥处理工具,它们用法基本一致,所以只举例说明openssl rsa. 它们的用法很简单,基 ...

  7. alt、title和label

    alt是html标签的属性,而title既是html标签,又是html属性. title标签这个不用多说,网页的标题就是写在<title></title>这对标签之内的. ti ...

  8. Ubuntu配置TFTP服务器

    TFTP(Trivial File Transfer Protocol,简单文件传输协议)是TCP/IP协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂.开销不大的文件传输服务 ...

  9. 前端基础之CSS_1

    摘要 CSS(层叠样式表)的三种设置方法 基本选择器 组合选择器 属性选择器 分组与嵌套 伪类选择器 伪元素选择器 选择器的优先级 一些样式的设置(字体.文本.背景.边框) display属性设置 0 ...

  10. Python中的函数(5)

    一.向函数中传递任意数量的实参 有时候,你预先不知道函数需要接受多少个实参,Python中函数可以收集任意数量的实参. 栗子:来看一个打印好友列表功能的函数,它需要接收任意数量的好友名.如下: def ...