工作,学习,生活,这里将会有一些记录. 备用域名:http://meisw.51099.com 注册 | 登陆
浏览模式: 标准 | 列表分类:应用服务

wordpress wp-admin 302循环重定向

 控制台页面无法打开,循环重定向,查询很多方法无效。后来在dockerhub上的wordpress页面发现nginx需要添加一个选项,按照说明添加后就可以正常访问了。下面就是添加的内容。

 
proxy_set_header X-Forwarded-Proto https;
 
vi wp-includes/pluggable.php
setcookie($auth_cookie_name, $auth_cookie, $expire, SITECOOKIEPATH, COOKIE_DOMAIN, $secure, true);

开源直播与监控系统

 优秀开源项目之一:视频监控系统iSpy

http://blog.csdn.net/kdlipm/article/details/62423123
 
优秀开源项目之二:流媒体直播系统Open Broadcaster Software
 
http://blog.csdn.net/kdlipm/article/details/62423283

dns 知识点扩展

1,bind 保存区域文件都是用文本文档来保存的,当数据量大的时候很容易造成操作错误。当数据量大的时候可以考虑数据库的模式。bind+mysql 数据库,有两种方式Bind DLZ 和 Mysql-bind

http://hi.baidu.com/wzypunk/item/45ca82fc25f76051c9f3374e  使用Mysql-bind实现mysql管理bind配置

http://www.vpsa.net/?post=59 bind-dlz+mysql搭建智能dns

(发现最近没时间了,就不捣鼓实验了,)

2,named.conf 配置文件详解

Named.conf是bind9的最先读取的一个文件,named支持如下语句:
Acl
Controls
Include
Key
Logging
Lwres
Options
Server
Trusted-keys
View
Zone

其中主要的是acl,controls,include,logging,key,options,view,zone其他的很少用到我们就来详细的对这些进行解释一下
—————-

Acl用来对bind的访问进行限制,是一个全局的设置,前面配置的acl在整个bind中都适用,和路由器里面的access-list有同工之处,语法是
acl acl-name {
address_match_list
};
其中的address match list是一个地址列表,如”192.168.0.0/24;”,记住最后一定得有分号,有多个的话中间用分号格开,如192.168.0.0/32;192.168.1.0/24;
bind内置了4个acl分别是:
any(不是all)        对应所有的,也就是0.0.0.0/0.
none        对应为空.
localhost        对应本地机器.
localnets        对应本地网络.
—————-

Controls主要用于对bind进行控制,如:
key “rndc-key” {
algorithm hmac-md5;
secret “VkMaNHXfOiPQqcMVYJRyjQ==”;
};
controls {
inet 127.0.0.1 port 953
allow { 127.0.0.1; } keys { “rndc-key”; };
};
设置rndc控制的端口以及端口,keys用来设置控制的密钥.
—————-

include是一个非常有用的选项,作用是包含一个文件进来,如果需要写程序来读写bind的配置文件,这个将会用到,因为bind的配置文件很不规则,但是用了include后,就可以变的很规则,就和数据库一样了J,功用和c语言里面的include一样.
—————-

Options是用于设置bind的一些选项,我们将重点介绍,BING9支持的选项如下:
options {
blackhole { <address_match_element>;; … };
coresize <size>;;
datasize <size>;;
deallocate-on-exit <boolean>;; // obsolete
directory <quoted_string>;;
dump-file <quoted_string>;;
fake-iquery <boolean>;; // obsolete
files <size>;;
has-old-clients <boolean>;; // obsolete
heartbeat-interval <integer>;;
host-statistics <boolean>;; // not implemented
interface-interval <integer>;;
listen-on [ port <integer>; ] { <address_match_element>;; … };
listen-on-v6 [ port <integer>; ] { <address_match_element>;; … };
match-mapped-addresses <boolean>;;
memstatistics-file <quoted_string>;; // not implemented
multiple-cnames <boolean>;; // obsolete
named-xfer <quoted_string>;; // obsolete
pid-file <quoted_string>;;
port <integer>;;
random-device <quoted_string>;;
recursive-clients <integer>;;
rrset-order { [ class <string>; ] [ type <string>; ] [ name
<quoted_string>; ] <string>; <string>;; … }; // not implemented
serial-queries <integer>;; // obsolete
serial-query-rate <integer>;;
stacksize <size>;;
statistics-file <quoted_string>;;
statistics-interval <integer>;; // not yet implemented
tcp-clients <integer>;;
tkey-dhkey <quoted_string>; <integer>;;
tkey-gssapi-credential <quoted_string>;;
tkey-domain <quoted_string>;;
transfers-per-ns <integer>;;
transfers-in <integer>;;
transfers-out <integer>;;
treat-cr-as-space <boolean>;; // obsolete
use-id-pool <boolean>;; // obsolete
use-ixfr <boolean>;;
version <quoted_string>;;
allow-recursion { <address_match_element>;; … };
allow-v6-synthesis { <address_match_element>;; … };
sortlist { <address_match_element>;; … };
topology { <address_match_element>;; … }; // not implemented
auth-nxdomain <boolean>;; // default changed
minimal-responses <boolean>;;
recursion <boolean>;;
provide-ixfr <boolean>;;
request-ixfr <boolean>;;
fetch-glue <boolean>;; // obsolete
rfc2308-type1 <boolean>;; // not yet implemented
additional-from-auth <boolean>;;
additional-from-cache <boolean>;;
query-source <querysource4>;;
query-source-v6 <querysource6>;;
cleaning-interval <integer>;;
min-roots <integer>;; // not implemented
lame-ttl <integer>;;
max-ncache-ttl <integer>;;
max-cache-ttl <integer>;;
transfer-format ( many-answers | one-answer );
max-cache-size <size_no_default>;;
check-names <string>; <string>;; // not implemented
cache-file <quoted_string>;;
allow-query { <address_match_element>;; … };
allow-transfer { <address_match_element>;; … };
allow-update-forwarding { <address_match_element>;; … };
allow-notify { <address_match_element>;; … };
notify <notifytype>;;
notify-source ( <ipv4_address>; | * ) [ port ( <integer>; | * ) ];
notify-source-v6 ( <ipv6_address>; | * ) [ port ( <integer>; | * ) ];
also-notify [ port <integer>; ] { ( <ipv4_address>; | <ipv6_address>;
) [ port <integer>; ]; … };
dialup <dialuptype>;;
forward ( first | only );
forwarders [ port <integer>; ] { ( <ipv4_address>; | <ipv6_address>; )
[ port <integer>; ]; … };
maintain-ixfr-base <boolean>;; // obsolete
max-ixfr-log-size <size>;; // obsolete
transfer-source ( <ipv4_address>; | * ) [ port ( <integer>; | * ) ];
transfer-source-v6 ( <ipv6_address>; | * ) [ port ( <integer>; | * ) ];
max-transfer-time-in <integer>;;
max-transfer-time-out <integer>;;
max-transfer-idle-in <integer>;;
max-transfer-idle-out <integer>;;
max-retry-time <integer>;;
min-retry-time <integer>;;
max-refresh-time <integer>;;
min-refresh-time <integer>;;
sig-validity-interval <integer>;;
zone-statistics <boolean>;;
};
obsolete是已经过时的选项,这里不用考虑, not yet implemented是尚未完成的选项,这里也不用考虑,下面详细介绍这里面的有用选项注意,前面打”*”的为选项)

blockhole 定义服务器不对查询进行反应的地址列表,也就是”黑名单”,比如说3721的ip段:218.244.44.0/24,当设置了黑名单后,对于这个段的请求查询,服务器将不会作出反应.

directory 设置bind的数据文件的存放位置:如 directory “/var/named”

dump-file 设置当执行rndc dumpdb命令后的导出文件存放绝对路径,如果没有指定的话,缺省文件为named_dump.db,放在directory指定的目录下面.

pid-file 设置bind的进程号pid文件.

interface-interval 设置bind检查网卡变化的周期.

forward 值有first和only两项, first则首先转发到”forwarders”中的服务器,然后自己查询,only则仅转发到 “转发服务器列表”中的服务器,不再自己查询

forwarders设置转发服务器地址列表,语法同acl中的语法.

listen-on 设置bind的绑定ip和端口,如listen-on 53 {192.168.0.1;};

max-cache-size 设置最大缓存的大小,如max-cache-size 5M

version 设置客户查询DNS版本好的返回信息,如果不想让客户探测到当前的版本好,就用这个好了,如version mydns1.0;
auth-nxdomain 是否做为权威服务器回答域不存在(Auth-nxdomain)
如果设置为’yes’,则允许服务器以权威性(authoritatively)的方式返回NXDOMAIN(该域不存在)的回答,否则就不会作权威性的回答,缺省值为”是”.
notify 在主服务器更新时是否通知辅助服务器(notify)
如果设置为”yes”,则在主服务器区域数据发生变化时,就会向在域的”域名服务器“中列出的服务器和“亦通知”中列出的服务器发送更新通知。这些服务器接受到更新通知后,就会向主服务器发送请求传输的消息,然后区域文件得以更新。

recursion 是否允许递规查询(recursion)
如果设置为”yes”,则允许服务器采用递归的方式进行查询,也就是当要查询的地址不在服务器的数据库列表中时,服务器将一级一级的查询,直到查到为止。(一般对局域网都打开)
设置为”no”,并不意味着服务器对于请求的递归查询不给予回答,而是对于请求的递归查询,不再向上级服务器请求,也不缓存,如果不对请求的递归查询回答,可以清空缓存,然后设置为“NO”.

allow-query 允许普通查询的地址列表(allow-query):
设置允许进行普通查询的ip地址列表,在域中的设置将覆盖全局设置,默认情况下是允许所有的地址进行普通查询.

allow-recursion允许递归查询的地址列表(allow-recursion):
设置允许进行递归查询的ip地址列表,缺省值是允许所有地址进行查询,需要注意的是当设置了不允许递归查询后,如果仍然能够查询部分外部的域名,那是因为dns的缓存在起作用,将缓存清除以后就可以了.

allow-transfer允许服务器进行区域传输的地址列表(Allow-transfer):
(注意的是视区和域中的设置将覆盖全局设置).

allow-notify 允许更新通知的地址列表(allow-notify)
当服务器作为辅助服务器的时候,设置这个可以对收到的更新通知进行判断,只是接收该列表的更新通知.默认情况下,只是接收来自主服务器的更新通知。对于其他服务器的更新通知,会忽略掉.

also-notify 更新时亦通知下列地址(also-notify):
设置发送更新通知的时候,不仅是域名服务器中列出的地址,亦通知此地址列表中的地址。

利用DRBD+heartbeat实现NFS文件共享服务高可用

一.目的:二台NFS服务器互为冗余(系统切换时间约为2x ms左右),保证NFS文件共享服务的可用

二.系统为CentOS 5.3
    二个节点 主节点node1(192.168.10.111) 备用节点node2(192.168.10.112) 虚拟IP:192.168.10.113对外提供服务
node1 /etc/hosts如下
[root@node1 ha.d]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
192.168.10.111          node1
192.168.10.112          node2
127.0.0.1               node1 localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6

node2 /etc/hosts如下
[root@node2 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
192.168.10.111          node1
192.168.10.112          node2
127.0.0.1               node2 localhost.localdomain localhost
::1             localhost6.localdomain6 localhost6

二台机将/dev/hda5互为镜相
二台机/etc/export相同
cat /etc/exports
/u1 192.168.10.0/255.255.255.0(rw,no_root_squash,no_all_squash,sync)
确定二台机的portmap服务为启动状态

三.所需软件:使用DRBD作为网络磁盘镜相,Heartbeart为管理由提供NFS服务及服务失效节点转移
安装所需的软件DRBD及Heartbeat均从http://mirror.centos.org/centos/5.3/extras/i386/RPMS 此目录下载,省去安装过程
drbd需要手动加载内核模块,安装好rpm执行如下指令
insmod /lib/modules/2.6.9-78.ELsmp/extra/drbd.ko
modprobe drbd

四.配置过程
1.DRBD配置 配置文件只有一个/etc/drbd.conf 二个内容都是一样 global { usage-count yes; }

common { syncer { rate 10M; } }

resource r0 {

        protocol C;

        startup {

 

        }

        disk {

                on-io-error   detach;

        }

        net {

        }

        on node1 {

                device    /dev/drbd0;

                disk      /dev/hda5;

                address   192.168.10.111:7789;

                meta-disk internal;

        }

        on node2 {

                device    /dev/drbd0;

                disk      /dev/hda5;

                address   192.168.10.112:7789;

                meta-disk internal;

        }

}
复制代码在二台机执行
drbdadm create-md r0 #创建ro的资源
/etc/init.d/drbd start #启动drbd
cat /proc/drbd #查看状态正常显示为
version: 8.0.13 (api:86/proto:86)
GIT-hash: ee3ad77563d2e87171a3da17cc002ddfd1677dbe build by buildsvn@c5-i386-build, 2008-10-02 13:31:44
0: cs:Connected st:Secondary/Primary ds:UpToDate/UpToDate C r---
    ns:1848 nr:14357752 dw:14359600 dr:653 al:6 bm:901 lo:0 pe:0 ua:0 ap:0
        resync: used:0/61 hits:928654 misses:1079 starving:0 dirty:0 changed:1079
        act_log: used:0/127 hits:456 misses:6 starving:0 dirty:0 changed:6
在主服务器上执行
drbdsetup /dev/drbd0 primary -o #定义为主节点
mkfs.ext3 /dev/drbd0           #格式化
mount /dev/drbd0 /u1           #挂载
cat /proc/drbd #此时查看状态正常显示为
[root@node1 ha.d]# cat /proc/drbd
version: 8.0.13 (api:86/proto:86)
GIT-hash: ee3ad77563d2e87171a3da17cc002ddfd1677dbe build by buildsvn@c5-i386-build, 2008-10-02 13:31:44
0: cs:Connected strimary/Secondary ds:UpToDate/UpToDate C r---
    ns:14357752 nr:1848 dw:361872 dr:13998555 al:264 bm:3581 lo:0 pe:0 ua:0 ap:0
        resync: used:0/61 hits:928654 misses:1079 starving:0 dirty:0 changed:1079
        act_log: used:0/127 hits:89742 misses:268 starving:0 dirty:4 changed:264

2.Heartbeat配置共涉及4个文件
/etc/ha.d/ha.cf
/etc/ha.d/haresources
/etc/ha.d/authkeys
/etc/ha.d/resource.d/killnfsd
二个节的配置的配置文件都是一样,文件内容如下
[root@node1 ha.d]# cat /etc/ha.d/ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility     local0
keepalive 2
deadtime 20
bcast eth0
auto_failback off
node    node1 node2
[root@node1 ha.d]# cat /etc/ha.d/haresources
node1 IPaddr::192.168.10.113/24/eth0 drbddisk::r0 Filesystem::/dev/drbd0::/u1::ext3 killnfsd
[root@node1 ha.d]# cat /etc/ha.d/authkeys
auth 1
1 crc
#2 sha1 HI!
#3 md5 Hello!
[root@node1 ha.d]# cat /etc/ha.d/resource.d/killnfsd
killall -9 nfsd ; /etc/init.d/nfs restart ; exit 0

需要将 /etc/ha.d/authkeys设为600的权限 将cat /etc/ha.d/resource.d/killnfsd设为755的权限
chmod 600 /etc/ha.d/authkeys
chmod 755 /etc/ha.d/resource.d/killnfsd

为什么要使用这个killnfsd的原因,使用/etc/inin.d/nfs stop 不能停掉nfsd,所有我使用了killall -9 nfsd再加了一个/etc/inin.d/nfs restart确保万一
在二个节点启动Heartbeat即可,先在主节点启动
/etc/init.d/heartbeat start

五.测试
将192.168.10.113:/u1挂到本地/mnt
mount 192.168.10.113:/u1 /mnt
创建测试shell,二秒一个
cat /mnt/test.sh
while true
do
  echo     ---\> trying touch x : `date`
  touch x
  echo     \<----- done touch x : `date`
  echo
  sleep 2

done

将主节点的heartbeat服务停止,则备节点node2接管服务
/etc/init.d/heartbeat stop

测试脚本终端显示如下
---> trying touch x : ?t 6?? 30 15:17:16 CST 2009
<----- done touch x : ?t 6?? 30 15:17:16 CST 2009

---> trying touch x : ?t 6?? 30 15:17:19 CST 2009
<----- done touch x : ?t 6?? 30 15:17:19 CST 2009

---> trying touch x : ?t 6?? 30 15:17:21 CST 2009
<----- done touch x : ?t 6?? 30 15:17:21 CST 2009

---> trying touch x : ?t 6?? 30 15:17:23 CST 2009
<----- done touch x : ?t 6?? 30 15:17:23 CST 2009

---> trying touch x : ?t 6?? 30 15:17:25 CST 2009
<----- done touch x : ?t 6?? 30 15:17:25 CST 2009

---> trying touch x : ?t 6?? 30 15:17:27 CST 2009
touch: cannot touch ??x?ˉ: Stale NFS file handle
<----- done touch x : ?t 6?? 30 15:17:42 CST 2009

---> trying touch x : ?t 6?? 30 15:17:44 CST 2009
touch: cannot touch ??x?ˉ: Stale NFS file handle
<----- done touch x : ?t 6?? 30 15:17:44 CST 2009

---> trying touch x : ?t 6?? 30 15:17:46 CST 2009
touch: cannot touch ??x?ˉ: Stale NFS file handle
<----- done touch x : ?t 6?? 30 15:17:46 CST 2009

---> trying touch x : ?t 6?? 30 15:18:03 CST 2009
<----- done touch x : ?t 6?? 30 15:18:03 CST 2009

---> trying touch x : ?t 6?? 30 15:18:05 CST 2009
<----- done touch x : ?t 6?? 30 15:18:05 CST 2009

至此,测试已实现所需的功能

六.参考文档
Setup of High-Availability NFS servers (HA-NFS)  http://www.linux-ha.org/HaNFS
DRBD Heartbeat and NFS on Debian HowTo http://www.linux-ha.org/DRBD/NFS

Dns信息收集工具集合

dnswalk, dnstracer,dnsenum
DNSwalk是DNS debugger. 用于域的转换和查询数据库
命令行中的域名必须以.结尾,你可有使用普通域名例如:dnswalk example.com. 或者反域名例如: dnswalk 3.2.1.in-addr.arpa

命令举例:
#./dnswalk www.g.cn.

下载地址:http://sourceforge.net/projects/dnswalk/
-------------------
dnstracer,向指定域名服务器发送非递归域名请求。
非递归请求的意思是,如果域名服务器知道,那么它会返回请求数据。
如果域名服务器不知道,它会返回授权域的域名服务器或返回根域名服务器的地址。
命令举例:
dnstracer www.mavetju.org

下载地址:http://www.mavetju.org/download/dnstracer-1.9.tar.gz
-------------
dnsenum的目的是尽可能收集一个域的信息。1) 主机地址信息,(A record).
2) 域名服务器 (threaded).
3) MX record (threaded).
4) 在域名服务器上执行axfr请求.
5)通过google脚本得到扩展域名或子域名信息(google query = “allinurl: -www site:domain”).
6) 提取子域名并查询.
7) 计算C类地址,并执行whois查询.
8) 执行反向查询.
9) 把地址段写入文件domain_ips.txt.

命令举例:
./dnsenum.pl cnn.com

常用参数命令举例:
./dnsenum.pl --enum -f dns.txt --update a -r remote
下载地址:http://code.google.com/p/dnsenum/

 

LVS状态迁移,主从结构

原理,http://zh.linuxvirtualserver.org/node/70

http://www.linuxvirtualserver.org/docs/sync.html

 

打开和关闭主从调度器的状态同步比较简单,只需要

ipvsadm --start-daemon=master
ipvsadm --stop-daemon=master
ipvsadm --start-daemon=backup
ipvsadm --stop-daemon=backup

svn

SVN是一个版本控制软件,类似CVS,但是SVN的的有点是开源的,而且SVN的版本控制能力比CVS还要强多。

下载:http://subversion.tigris.org

当前稳定版本 http://subversion.tigris.org/downloads/subversion-1.4.6.tar.bz2

安装
tar -zxvf ...
./configure;make;make install

需要安装
http://apache.mirror.phpchina.com/apr/apr-1.2.12.tar.gz
http://apache.mirror.phpchina.com/apr/apr-util-1.2.12.tar.gz

svnserve -d
svnserve -d -r /etc/svn/pro_name //以独立方式启动


建立版本库
svnadmin create pro_name
//存储类型
--fs-type fsfs
--fs-type bdb
配置
修改pro_name/conf/svnserve.conf
anon-access = read
auth-access = write
password-db = passwd

用户密码文件
pro_name/conf/passwd

权限控制
conf/authz

导入
svn import /www/web file:///etc/svn/pro_name
查看
svn list file:///etc/svn/

checkout
svn co file:///etc/svn /www/web
hooks/post-commit
svn update /www/web

客户端安装
http://tortoisesvn.tigris.org
http://tortoisesvn.net/downloads
下载 http://downloads.sourceforge.net/tortoisesvn/TortoiseSVN-1.4.8.12137-win32-svn-1.4.6.msi?download
setup安装即可
中文语言包 http://www.subversion.org.cn/index.php?option=com_weblinks&catid=63&Itemid=99


FAQ
Q:configure: WARNING: APR not found
需安装apr and apr-util

Q:does not appear to be a URL


Subversion控制中文目录的访问权限

方法很简单,就是将权限控制文件(authz)的格式转换为UTF-8格式,
svn对于非英文文件名和目录名使用utf-8格式编码处理,要对中文目录进行正确控制,应该使用无BOM的utf-8格式

将权限文件改成UTF-8格式的办法:使用UltraEdit的菜单"ASCII to UTF-8 (Unicode Editing)"。

关于UTF-8的问题如下:
1 svn不支持微软格式的UTF-8文件,不支持unicode,仅支持标准UTF-8,就是头部有一个 FF FE的文件
2 用微软自带的“记事本”编辑出来的任何unicode格式文件,svn均不认识
3 只要使用了svn 支持的标准UTF-8文件,svn 就可以很好地实现对中文的支持,包括中文用户名、中文目录、中文组名

---------------------------

中文手册 http://svndoc.iusesvn.com/

导入 svn import -m --force-log /www/web/test file:///etc/svn/test

checkout svn co file:///etc/svn/test /www/web/test

修改后 svn update /patch
自动更新
vi post-commit
#!/bin/sh
svn update /www/web/test

 

游戏代理VPN

游戏代理VPN

软件:pptp+radius+mysql
平台:linux,可以是各发行版,内核最好是2.6以上的
我的测试平台是RHEL5 beta1,内核 2.6.18-1.2747.el5xen
这个版本有个好处,就是内核已支持MPPE,不用再安装

首先要确定内核是否支持mppe
方法: modprobe ppp-compress-18 && echo ok
如果显示ok,即表示内核已具备了mppe支持

如不支持,需要升级内核以支持mppe
软件下载 http://sourceforge.net/project/showfiles.php?group_id=44827
下载2个rpm包。
dkms-2.0.10-1.noarch.rpm
kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
dkms是一个新的软件,能让你在不编译内核的基础上,外挂一些内核的模块。
kernel_ppp_mppe就是mppe支持的内核模块
OK后最好重起下你的系统

安装pppd
也可以在上面的地址下载,但只可以下载RPM包,最高版本为 ppp-2.4.3-5.rhel4.i386.rpm,也有FC的
源码下载可以到 http://samba.org/ppp/download.html,最新版本为 ppp-2.4.4b1.tar.gz
最新版已支持 mppe,不用再打补丁
如不支持,可以到此下载 http://mppe-mppc.alphacron.de/#AEN56,包括ppp和内核补丁
检查pppd是否支持mppe
[root@localhost]# strings `which pppd`|grep -i mppe|wc --lines
42
结果大于36,即表示支持
解压安装
tar -zxvf ...
configure,make,make install
用 make install-etcppp 来安装范例配置文件

安装pptpd
下载 http://sourceforge.net/project/showfiles.php?group_id=44827
最新版本,源码包的是 pptpd-1.3.4.tar.gz
RPM包的是 pptpd-1.3.3-1.rhel4.i386.rpm,FC6
解压安装 tar -zxvf ...
configure,make,make install

配置
pppd 的配置文件 /etc/ppp
pptpd 的配置文件 /etc/pptpd.conf
在pptpd.conf
localip 10.10.10.1
remoteip 10.10.110.2-100
localip是pptpd的对外服务的ip,也就是客户端需要拨号的ip
remoteip是拨号服务器分配给拨号用户的ip ,可以用-表示ip范围

添加测试用户 /etc/ppp/chap-secrets
# Secrets for authentication using CHAP
# client        server  secret                  IP addresses
test pptpd test *

认证方式设置 /etc/ppp/options.pp
默认就可以用,如果不mppe,或是不用加密,可以在此文件设置


为方便测试,请打开debug和dump调试,并查看/var/log/messages 文件

启动pptpd后,就可以在XP建立连接测试了

以上一个简单的VPN就完成了.

 

结合radius

软件下载 http://www.freeradius.org
当前最新版本为 freeradius-server-2.0.4.tar.bz2
但与1.X的配置方式上,有比较大的区别.
我开始是用2.X测试的,但没成功,最后用了1.X的.有空再研究2.X的.

解压安装
tar -zxvf ...,configure,make,make install

配置
从pppd的源码目录把下面这个目录复制到/etc/radiusclient/
cp -R ppp-2.4.4b1/pppd/plugins/radius/etc  /etc/radiusclient/

修改 options.pptpd
在最后加入
plugin /usr/local/lib/pppd/2.4.4b1/radius.so

配置 /etc/radiusclient中的servers和radiusclient.conf
在servers中,你需要增加一个radiusd的地址和密码
localhost       vpn
这里localhost表示你的radiusd就在本机,并且访问的密码是vpn

在radiusclient.conf中 加入
authserver      localhost:1812
acctserver      localhost:1813
确认上面也是本地的,默认就是本地,所以一般不需要修改。
同时确保这个文件中radiusclient相关的路径所有的路径都是 /etc/radiusclient 开头的。

配置freeradius
在 freeradius/etc/raddb 下
修改clients.conf
这里说明一下,所有的nas都是radiusd的client,nas就是那个pptpd,所以这个文件就是配置pptpd的登陆权限的。
client 127.0.0.1      {
                        secret = vpn
                        shortname = mm
                        nastype     = other
                        }

修改127.0.0.1部分为上面的样子。secret就是我们刚才在/etc/radiusclient中servers里设置的那个。这两个要一致

在users文件的最上面加入一个用户
ww Auth-Type:= MS-CHAP, User-Password=="ww", Simultaneous-Use:=1
          Service-Type = Framed-User,
          Framed-Protocol = PPP,
          Framed-IP-Address = 255.255.255.254,
          Framed-IP-Netmask = 255.255.255.0

说明一下 ww是用户名
auth-type是验证的类型
第二个ww是密码
Simultaneous-Use是允许这个用户名同时登陆的个数

所有这些都是check属性,要写在第一行
然后第二行开始用tab开头,是服务器返回给radius客户端的(也就是返回给pptpd)时reply属性。
其中ip地址设置为255.255

用debug模式运行radiusd
sbin/radiusd -x

测试,在XP建个VPN连接,用户密码均为 ww

 

结合mysql
mysql安装略过.
建立一个radius数据库,把结构导入即可
库结构文件在 freeradius16/share/doc/freeradius/examples/mysql.sql
配置sql.conf 在安装目录下的etc/raddb
修改sql.conf的连接信息
        # Connect info
        server = "192.168.8.53"
        login = "radius"
        password = "radius"

        # Database table configuration
        radius_db = "radius"

去掉下面的simul。。。。前面的#
打开sql的用户同时连接数测试的语句
        # Uncomment simul_count_query to enable simultaneous use checking
         simul_count_query = "SELECT COUNT(*) FROM ${acct_table1} WHERE UserName='%{SQL-User-Name}' AND AcctStopTime = 0"


配置radiusd.conf

注释掉 authorize {
的files
去掉sql前的注释

注释掉 preacct {
的files

注释掉 accounting {
的radutmp
去掉sql前面的#

注释掉 session{
的radutmp
去掉sql前面的#

去掉 post-auth {
sql前的#

总之就是去掉files模块,开启sql模块


在数据库中添加用户
在usergroup中添加一个test用户,组名为vpn
在radgroupcheck中添加一个vpn组,
attribute为Simultaneous-Use
op为:=
value为1
的纪录

在radcheck中添加
username为test
attribute为 User-Password
op为==
value为test

这样就添加了一个用户为test,组为vpn,密码为test
并且所有的组用户的都只能1个用户名登陆一次

测试
用debug模式启动radiusd

Records:17123