MGJ的地盘

爱拼才会赢!

CentOS搭建VPN服务器及radius后台完整教程 201

作者为 发表

首先卸载CentOS自带的pptpd,我使用的CentOS 6.2,

配置iptables如果有需要,先清空

iptables -F
iptables -X
iptables save

如果确认自己不需清空请追加

iptables --flush POSTROUTING --table nat
iptables --flush FORWARD
iptables save


下载的pptpd 1.3.4
安装依赖库并安装pptpd, 6.2上面已经是pptp了,不会用就自己下了1.3.4的pptpd

yum remove -y pptp
arch=`uname -m`
wget http://poptop.sourceforge.net/yum/stable/packages/pptpd-1.3.4-2.el6.$arch.rpm
yum -y install make libpcap iptables gcc-c++ logrotate tar cpio perl pam tcp_wrappers dkms kernel_ppp_mppe ppp
rpm -Uvh pptpd-1.3.4-2.el6.$arch.rpm

8.8.8.8和8.8.4.4是google提供的免费DNS可以改成自己的DNS
localip和remoteip是VPN的网关和分配给别人的ip地址

mknod /dev/ppp c 108 0
echo 1 > /proc/sys/net/ipv4/ip_forward
echo "mknod /dev/ppp c 108 0" >> /etc/rc.local
echo "echo 1 > /proc/sys/net/ipv4/ip_forward" >> /etc/rc.local
echo "localip 172.16.36.1" >> /etc/pptpd.conf
echo "remoteip 172.16.36.2-254" >> /etc/pptpd.conf
echo "ms-dns 8.8.8.8" >> /etc/ppp/options.pptpd
echo "ms-dns 8.8.4.4" >> /etc/ppp/options.pptpd

设置test账号的密码

pass=`openssl rand 6 -base64`
echo "test pptpd ${pass} *" >> /etc/ppp/chap-secrets

设置VPN的iptables规则

iptables -t nat -A POSTROUTING -s 172.16.36.0/24 -j SNAT --to-source `ifconfig | grep 'inet addr:'| grep -v '127.0.0.1' | cut -d: -f2 | awk 'NR==1 { print $1}'`
iptables -A FORWARD -p tcp --syn -s 172.16.36.0/24 -j TCPMSS --set-mss 1356
service iptables save

设置开机启动服务并启动pptp服务

chkconfig iptables on
chkconfig pptpd on
service iptables start
service pptpd start

至此CentOS的pptp应该是可以工作了,如果用test账号无法连接vpn请检查以上步骤哪里出错可以在/var/log/message中查看日志

接下来安装freeradius和管理后台来控制你的vpn账号

如果没有yum源请先安装rpmforge,如果没有安装mysql请安装

wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.2-2.el6.rf.i686.rpm
rpm --import http://apt.sw.be/RPM-GPG-KEY.dag.txt
rpm -i rpmforge-release-0.5.2-2.el6.rf.i686.rpm
yum install freeradius freeradius-mysql radiusclient-ng radiusclient-ng-utils freeradius-utils mysql mysql-devel mysql-server
ln -s /etc/radiusclient-ng /etc/radiusclient

修改/etc/radiusclient-ng/servers 其中testing123在raddb中配置,后面会提到

#Server Name or Client/Server pair Key
#---------------- ---------------
#portmaster.elemental.net hardlyasecret
#portmaster2.elemental.net donttellanyone
你的外网地址 testing123

在/usr/share/radiusclient-ng/中添加dictionary.microsoft

VENDOR Microsoft 311 Microsoft

ATTRIBUTE MS-CHAP-Response 1 string Microsoft
ATTRIBUTE MS-CHAP-Error 2 string Microsoft
ATTRIBUTE MS-CHAP-CPW-1 3 string Microsoft
ATTRIBUTE MS-CHAP-CPW-2 4 string Microsoft
ATTRIBUTE MS-CHAP-LM-Enc-PW 5 string Microsoft
ATTRIBUTE MS-CHAP-NT-Enc-PW 6 string Microsoft
ATTRIBUTE MS-MPPE-Encryption-Policy 7 string Microsoft
ATTRIBUTE MS-MPPE-Encryption-Type 8 string Microsoft
ATTRIBUTE MS-MPPE-Encryption-Types 8 string Microsoft
ATTRIBUTE MS-RAS-Vendor 9 integer Microsoft
ATTRIBUTE MS-CHAP-Domain 10 string Microsoft
ATTRIBUTE MS-CHAP-Challenge 11 string Microsoft
ATTRIBUTE MS-CHAP-MPPE-Keys 12 string Microsoft
ATTRIBUTE MS-BAP-Usage 13 integer Microsoft
ATTRIBUTE MS-Link-Utilization-Threshold 14 integer Microsoft
ATTRIBUTE MS-Link-Drop-Time-Limit 15 integer Microsoft
ATTRIBUTE MS-MPPE-Send-Key 16 string Microsoft
ATTRIBUTE MS-MPPE-Recv-Key 17 string Microsoft
ATTRIBUTE MS-RAS-Version 18 string Microsoft
ATTRIBUTE MS-Old-ARAP-Password 19 string Microsoft
ATTRIBUTE MS-New-ARAP-Password 20 string Microsoft
ATTRIBUTE MS-ARAP-PW-Change-Reason 21 integer Microsoft
ATTRIBUTE MS-Filter 22 string Microsoft
ATTRIBUTE MS-Acct-Auth-Type 23 integer Microsoft
ATTRIBUTE MS-Acct-EAP-Type 24 integer Microsoft
ATTRIBUTE MS-CHAP2-Response 25 string Microsoft
ATTRIBUTE MS-CHAP2-Success 26 string Microsoft
ATTRIBUTE MS-CHAP2-CPW 27 string Microsoft
ATTRIBUTE MS-Primary-DNS-Server 28 ipaddr Microsoft
ATTRIBUTE MS-Secondary-DNS-Server 29 ipaddr Microsoft
ATTRIBUTE MS-Primary-NBNS-Server 30 ipaddr Microsoft
ATTRIBUTE MS-Secondary-NBNS-Server 31 ipaddr Microsoft
VALUE MS-BAP-Usage Not-Allowed 0
VALUE MS-BAP-Usage Allowed 1
VALUE MS-BAP-Usage Required 2
VALUE MS-ARAP-PW-Change-Reason Just-Change-Password 1
VALUE MS-ARAP-PW-Change-Reason Expired-Password 2
VALUE MS-ARAP-PW-Change-Reason Admin-Requires-Password-Change 3
VALUE MS-ARAP-PW-Change-Reason Password-Too-Short 4
VALUE MS-Acct-Auth-Type PAP 1
VALUE MS-Acct-Auth-Type CHAP 2
VALUE MS-Acct-Auth-Type MS-CHAP-1 3
VALUE MS-Acct-Auth-Type MS-CHAP-2 4
VALUE MS-Acct-Auth-Type EAP 5
VALUE MS-Acct-EAP-Type MD5 4
VALUE MS-Acct-EAP-Type OTP 5
VALUE MS-Acct-EAP-Type Generic-Token-Card 6
VALUE MS-Acct-EAP-Type TLS 13

复制dictionary并编辑radiusclient.conf添加dictionary

cp /usr/share/radiusclient-ng/diction* /etc/radiusclient-ng/

vim /etc/radiusclient-ng/radiusclient.conf 添加

dictionary /etc/radiusclient-ng/dictionary

vim /etc/radiusclient-ng/dictionary 添加

INCLUDE /etc/radiusclient-ng/dictionary.microsoft
INCLUDE /etc/radiusclient-ng/dictionary.merit

编辑/etc/raddb/clients.conf

client localhost {
secret = testing123
shortname = localhost
nastype = other
ipaddr = 你的外网地址
}

编辑/etc/raddb/radiusd.conf 把监听的ip改为你自己的ip
编辑/etc/raddb/sql.conf,配置login(用户名),password(密码),radius_db(数据库名)等字段,并找到readclients一行,设为yes并去掉注释符号#。
编辑/etc/raddb/sites-enabled/default,根据下面的说明注释或取消注释相应的行:

authorize段,关掉files,打开sql,也可以把unix关掉
preacct段,关掉files
accounting段,打开sql,也可以把unix关掉
session段,打开sql
post-auth段,打开sql
pre-proxy段,关掉files

到这里radius配置好了,数据库还没导入默认数据,因为我用daloradius后台了,他有sql可以全部导入
下载并安装daloradius

wget http://sourceforge.net/projects/daloradius/files/daloradius/daloradius0.9-9/daloradius0.9-9.tar.gz
pear install DB
tar zxvf daloradius0.9-9.tar.gz

注意,这里需要安装pear,如果bash提示找不到命令,那么请自行搜索安装方法
mysql新建一个表create database radius并导入数据库,使得普通user每月流量限制2G,超级用户无限制

mysql -uroot -p radius < daloRadius/contrib/db/fr2-mysql-daloradius-and-freeradius.sql

插入相应数据

mysql> select * from radgroupreply;
+----+-----------+-------------------+----+-----------------+
| id | groupname | attribute | op | value |
+----+-----------+-------------------+----+-----------------+
| 7 | user | Service-Type | := | Framed-User |
| 8 | user | Framed-IP-Address | := | 255.255.255.255 |
| 9 | user | Framed-IP-Netmask | := | 255.255.255.0 |
| 10 | user | Framed-Protocol | := | PPP |
| 11 | superuser | Service-Type | = | Framed-User |
| 12 | superuser | Framed-IP-Address | = | 255.255.255.255 |
| 13 | superuser | Framed-IP-Netmask | = | 255.255.255.0 |
| 14 | superuser | Framed-Protocol | = | PPP |
+----+-----------+-------------------+----+-----------------+
8 rows in set (0.00 sec)

mysql> select * from radgroupcheck;
+----+---------------------------+---------------------+----+--------+
| id | groupname | attribute | op | value |
+----+---------------------------+---------------------+----+--------+
| 1 | daloRADIUS-Disabled-Users | Auth-Type | := | Reject |
| 4 | user | Simultaneous-Use | := | 1 |
| 5 | user | Max-Monthly-Session | := | 2048 |
| 6 | superuser | Simultaneous-Use | := | 1 |
+----+---------------------------+---------------------+----+--------+
4 rows in set (0.00 sec)

编辑daloRadius/library/daloradius.conf.php,修改daloRADIUS的配置文件。首先是MySQL登录信息:

$configValues['CONFIG_DB_HOST'] = 'localhost';
$configValues['CONFIG_DB_USER'] = 'root'; //根据自己实际情况填写
$configValues['CONFIG_DB_PASS'] = '你的密码'; // 设为自己的密码
$configValues['CONFIG_DB_NAME'] = 'radius';
service httpd restart
service mysqld restart

在配置文件/etc/ppp/options.pptpd加上3行:

plugin radius.so
plugin radattr.so
radius-config-file /etc/radiusclient/radiusclient.conf

启动服务

service radiusd start
chkconfig radiusd on

现在可以进入你的daloradius网站后台管理你的vpn了

Macbook Pro 安装Ubuntu11.10的Wireless驱动 199

作者为 发表

几经折腾终于搞定了mbp的无线驱动

参考http://www.ubuntubuzz.com/2011/10/macbook-pro-wireless-broadcom-bcm4331.html

按照步骤一步步来,不过都是英文的,所以再翻译一下

苹果本本的无线网卡居然是bcm4331,在ubuntu中第一次遇到。。。直接不识别硬件

当时是心里的一块疙瘩啊,虽然还有mac os x和windows用,但切换到ubuntu后始终是不爽

百度一下基本不管用,买苹果的有几个折腾linux的。。。

google一下,终于找到了了驱动

需要的软件和补丁包如下

compat-wireless-2011-08-27.tar.bz2

patch_bcm4331.tar.bz2

b43-fwcutter-015.tar.bz2

broadcom-wl-5.100.138.tar.bz2

 
首先解压驱动和补丁

# tar xf compat-wireless-2011-08-27.tar.bz2
# tar xf patch_bcm4331.tar.bz2
# cd compat-wireless-2011-08-27/
# patch -p1 < ../bcm4331-1.patch
# patch -p1 < ../bcm4331-2.patch
# patch -p1 < ../bcm4331-3.patch

启用驱动

# scripts/driver-select b43

找到 config.mk 第 276 行去掉 `#`启用如下配置

CONFIG_B43_PHY_HT=y

编译并安装驱动

# make
# sudo make install

解压编译 b43-fwcutter:

# tar xf b43-fwcutter-015.tar.bz2
# cd b43-fwcutter-015
# make

解压firmware

# tar xf ../broadcom-wl-5.100.138.tar.bz2
# export FIRMWARE_INSTALL_DIR="/lib/firmware"
# sudo ./b43-fwcutter -w "$FIRMWARE_INSTALL_DIR"  broadcom-wl-5.100.138/linux/wl_apsta.o

卸载无线驱动

# cd compat-wireless-2011-08-27
# sudo make wlunload

重启系统并加载b43模块

# sudo modprobe b43

把该模块添加到启动项

# cp /etc/modules /etc/modules.old
# echo "b43" | sudo tee -a /etc/modules

有时还需要修改config.d我没有改,没找到这个文件

# cp /etc/pm/config.d/default /etc/pm/config.d/default.old
# echo 'SUSPEND_MODULES="b43"' >> /etc/pm/config.d/default

祝君好运!

游戏demo 200

作者为 发表

WOG项目基于Android手机系统,平台使用Java语言进行开发,主要完成手机游戏《武侠世界》的设计与开发。
目前开发环境暂定于windows下Android SDK 2.1,eclipse3.5集成环境,实现完成一个完整的单机角色扮演类游戏——《武侠世界》设计思路:本游戏通过继承Android的SurfaceView类,来实现游戏的各种绘图,
通过继承Android的MediaPlayer类来实现音效,
通过Android系统自带的SQLite数据库来对游戏数据进行存储于以及更改操作。游戏功能及特色:由于数据库存储了绝大部分数据;大家可以通过
只修正数据库来修改游戏,这样实现不同剧情来完成多个系列的角色类游戏由于个人原因,已经停止开发。具有参考价值

当前功能如下
支持任意大小屏幕,横竖屏显示
当然屏幕太小无法容下界面
使用自定义Provider存储数据
通过SurfaceView绘图响应用户操作
测试人物角色实现上下左右行走及男女转换
我已将WOG框架的源码传至github
大家可以通过git客户端下载源码首先要有一个git客户端,linux下安装git git-core即可,windows下可以使用msysgit或者TortoiseGit
切换到你想要保存WOG项目的地方,然后
打开客户端后选着克隆选项输入git://github.com/wzl7222504/WOG.git
或者git终端命令行下输入:



 主题设计 • skyfrit.com  MGJ的地盘 | 保留所有权利

39 queries in 0.630 seconds.