Ubuntu VPN架设 (PPTPD and FreeRadius)

来源:互联网 发布:网络名誉权侵权案例 编辑:程序博客网 时间:2024/04/27 17:19

 

奥运网络安保开发任务结束了。自我修整一下,随便弄点东西,自我娱乐一下~

 

1、安装PPTPD
apt-get install pptpd
配置chap-secrets
增加一个用户(用户名为test,密码为test,密钥和IP地址不指定)
test * test *

在XP下新建一个VPN连接,访问Ubuntu主机的VPN,用户名test密码test 成功连接

2、安装FreeRadius
apt-get install freeradius
配置client.conf文件
client 127.0.0.1 {
 secret  = ubuntu
 shortname = localhost
 nastype     = other
}
意思是联入主机127.0.0.1,密钥为ubuntu
如果想让别的主机联入可以加入别的主机IP(例如我的DELL2300)

配置users文件
增加一个用户
inter Cleartext-Password := "12345"
 Service-Type = Framed-User,
 Framed-Protocol = PPP,
 Framed-IP-Address = 192.168.42.123,
 Framed-IP-Netmask = 255.255.255.0,
 Framed-Routing = Broadcast-Listen,
 Framed-Filter-Id = "std.ppp",
 Framed-MTU = 1500,
 Framed-Compression = Van-Jacobsen-TCP-IP

重启freeradius
测试一下 radtest inter 12345 127.0.0.1 0 ubuntu
Access-Accept成功

3、安装radiusclient
apt-get install radiusclient1
发现/etc/radiusclient下啥都没有,郁闷一下
下载ppp的源码包(ppp-2.4.3.tar.tar)
将pppd/plugins/radius/etc下的配置文件拷到/etc/radiusclient下面

配置servers文件
添加一个radius主机127.0.0.1和一个Key: ubuntu

配置radiusclient.conf文件
将servers, dictionary, mapfile路径改为/etc/radiusclient
将login_radius改为/usr/sbin/login.radius

配置/etc/ppp/pptpd-options文件
最后一行增加
plugin /usr/lib/pppd/2.4.4/radius.so (需要确认radius.so位置)
radius-config-file /etc/radiusclient/radiusclient.conf (需要确认radiusclient.conf位置)

重启PPTPD
在XP下新建一个VPN连接,访问Ubuntu主机的VPN,用户名inter 密码12345 成功连接,分配IP:192.168.42.123

 

4、安装MySQL
apt-get install mysql-server
将建立一个叫radius的数据库,然后将表结构导入到radius中
mysql -uroot -p12345 < radius.sql
在数据库中插入如下数据

组配置数据:
INSERT INTO `radgroupreply` (`id`, `GroupName`, `Attribute`, `op`, `Value`) VALUES
(7, 'user', 'Framed-Compression', ':=', 'Van-Jacobsen-TCP-IP'),
(6, 'user', 'Service-Type', ':=', 'Framed-User'),
(5, 'user', 'Framed-Protocol', ':=', 'PPP'),
(8, 'user', 'Framed-MTU', '=', '1500'),
(9, 'user', 'Framed-IP-Netmask', '=', '255.255.255.0'),
(10, 'user', 'Framed-Routing', '=', 'Broadcast-Listen');

组认证方式:
INSERT INTO `radgroupcheck` (`id`, `GroupName`, `Attribute`, `op`, `Value`) VALUES
(1, 'user', 'Auth-Type', ':=', 'MS-CHAP');
(这里搞了很久,按照很多文章配Local,但是会出问题,因此配成MS-CHAP)

建立一个用户:
INSERT INTO `radcheck` (`id`, `UserName`, `Attribute`, `op`, `Value`) VALUES
(1, 'test', 'User-Password', '==', 'hello');

将用户加入组:
INSERT INTO `usergroup` (`UserName`, `GroupName`, `priority`) VALUES
('test', 'user', 1);

如果想给用户一个IP:
INSERT INTO `radreply` (`id`, `UserName`, `Attribute`, `op`, `Value`) VALUES
(1, 'test', 'Framed-IP-Address', ':=', '192.168.53.133');

配置文件:
sql.conf

server = "localhost"
login = "root"
password = "12345"
radius_db = "radius"

radiusd.conf

在authorize,preacct,accounting,session,post-auth,pre-proxy里
把所有sql前的#都去除
在所有file前都加上#
还有在所有radutmp前加#

重启Radius
测试一下radtest test hello 127.0.0.1 0 ubuntu
Access-Accept成功

在XP下新建一个VPN连接,访问Ubuntu主机的VPN,用户名test 密码hello 成功连接,分配IP:192.168.53.133

OK! Finish!

原创粉丝点击