localip: pptpd server 所在服务器IP地址,可以设置为服务器上绑定的任意一个IP地址 remoteip:设置客户端连接到pptpd server后可供分配的IP地址范围
添加测试用户: [root@vm2 ~]# vim /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client server secret IP addresses
hy pptpd westos *
[root@vm2 ~]# /etc/init.d/pptpd start Starting pptpd: [ OK ] [root@vm2 ~]# netstat -antlp Active Internet connections (servers and established) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:1723 0.0.0.0:* LISTEN 1219/pptpd 接下来我们进行测试了
支持 mysql [root@vm2 raddb]# vim radiusd.conf $INCLUDE sql.conf #去掉注释 [root@vm2 raddb]# vim sites-available/default
authorize {
#files
sql
....
}
accounting {
#radutmp
sql
....
}
session{
#radutmp
sql
}
post-auth {
sql
}
[root@vm2 raddb]# vim sql.conf
sql {
database = “mysql“
driver = "rlm_sql_mysql"
server = "localhost"
login = "radius"
password = "radpass"
radius_db = "radius"
....
}
[root@vm2 raddb]# vim sql/mysql/dialup.conf 去掉如下行的注释: simul_count_query = "SELECT COUNT(*) / FROM ${acct_table1} / WHERE username = '%{SQL-User-Name}' / AND acctstoptime IS NULL"
安装和配置mysql [root@vm2 raddb]# yum install mysql mysql-server -y [root@vm2 raddb]# /etc/init.d/mysqld start [root@vm2 raddb]# cd /etc/raddb/sql/mysql/ [root@vm2 mysql]# mysqladmin create radius [root@vm2 mysql]# mysql radius < schema.sql [root@vm2 mysql]# mysql radius < admin.sql [root@vm2 mysql]# mysql mysql> use radius; mysql> insert into radgroupreply (groupname,attribute,op,value) values('user','Auth-Type',':=','Local'); mysql> insert into radgroupreply (groupname,attribute,op,value) values ('user','Service-Type',':=','Framed-User'); mysql> insert into radgroupreply (groupname,attribute,op,value) values('user','Framed-IP-Address',':=','255.255.255.254'); mysql> insert into radgroupreply (groupname,attribute,op,value) values ('user','Framed-IP-Netmask',':=','255.255.255.0'); mysql>insert into radgroupcheck (groupname,attribute,op,value) values('user','Simultaneous-Use',':=','1'); (限制一个帐号只能拨一次,可选) 添加用户: mysql> insert into radcheck (username,attribute,op,value) values ('hy','User-Password',':=','westos'); mysql> insert into radusergroup (username,groupname) values ('test','user');
以后添加帐户只需要进行以下两步操作即可: mysql> insert into radcheck (username,attribute,op,value) values ('test','User-Password',':=','test'); (添加帐户 test,密码 test) mysql> insert into radusergroup (username,groupname) values ('test','user');
[root@vm2 mysql]# /etc/init.d/radiusd start Starting radiusd: [ OK ] [root@vm2 mysql]# /etc/init.d/pptpd stop Shutting down pptpd: [ OK ] [root@vm2 mysql]# /etc/init.d/pptpd start Starting pptpd: [ OK ] 但是我在测试的时候出现了报错如下:
解决办法如下: [root@vm2 radiusclient]# vim /etc/hosts 添加一条将自己的IP解析出来 192.168.1.10 vm2.example.com 下面是我们的测试结果:
这时我们看到rad_recv: Access-Reject packet from host 127.0.0.1 port 1812, id=242, length=20,意思是访问被拒绝, 这时查看日志文件发现如下错误: