配置如下:
需要以下幾個軟件包:
(運行 #modprobe ppp-compress-18 && echo ok,如果顯示OK,那就不會用到以下兩個RPM包了)
dkms-2.0.6-1.noarch.rpm
kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
(這兩個是compile kernel,讓2.4.*的kernel支持mppe的加密).
pptpd-1.3.0.tar.gz (在pppd撥號的基礎上增加PPTPD的支持)
ppp-2.4.3.tar.gz (ppp撥號服務器)
radius可作為ppp的驗證外掛模块
freeradius-1.1.0.tar.gz
軟件包可以在下邊的連接上拿到
http://www.freeradius.org
用rpm -qa |grep mysql 如果顯示有mysql-devel的話,就不需要安裝下邊的RPM包
mysql-devel-3.23.54a-11.i386.rpm
1. 升级内核支持mppe(運行 #modprobe ppp-compress-18 && echo ok,如果顯示OK,直接跳到下一步)
#rpm -ivh dkms-2.0.6-1.noarch.rpm
#rpm -ivh kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
如果沒有error
#reboot
現在等機子啓動就可以進行下一步了.
2.安裝ppp
http://www.samba.org/ppp
這裡安裝的是 ppp-2.4.3.tar.gz
#tar -xvzf ppp-2.4.3.tar.gz
#cd ppp-2.4.3
#./configure
#make
#make install
3.安裝pptpd
http://poptop.sourceforge.net/
這裡安裝的是pptpd-1.3.0.tar.gz
#tar -xvzf pptpd-1.3.0.tar.gz
#cd pptpd-1.3.0
#./configure
#make
#make install
4.配置ppp和pptpd
#cp /pathofsource/pptpd-1.3.0/samples/pptpd.conf /etc/
#vi /etc/pptpd.conf
確認以下的配置是否存在:
ppp /usr/local/sbin/pppd (讓pptpd知道pppd所在的位置)
option /etc/ppp/options.pptpd (讓pptpd知道ppp的配置文件)
localip 172.16.2.74 (localip是pptpd服務器的外部ip,也就是用戶需要撥號的ip
remoteip 10.10.110.1-100 (服務器分配的ip範圍)
#vi /etc/ppp/option.pptpd
打開debug和dump功能,該功能可以在測試完成後去掉。
(注意:debug和dump功能會在/var/log/message里寫入關於用戶登入的過程)
這裡要注意一點:
要想支持windows98的用戶,
在配置option.pptpd時要把“require-mppe-128”或者“require-mppe”都去掉
因為windows98是不支持mppe加密壓縮的。
而且不用mppe加密,windows2000以上在建立pptpd vpn連接的時候,
不能使用“不加密斷開連接”這個選項.
5. 添加用戶和測試pptpd
#vi /etc/ppp/chap-secrets
加入一個用戶:
# Secrets for authentication using CHAP
# client server secret IP addresses
ouyangxin pptpd test *
第一個是用戶名, pptpd表示和/etc/ppp/options.pptpd中的name 部分pptpd要匹配,一般不用修改,第三個用戶密碼,*表示任意的ip
運行pptpd
#pptpd
或
#/usr/local/sbin/pptpd
使用windows98指向這個ip建立一個vpn連接。
好這裡完成pptpd的配置
radius部分:
安裝radius前先確認是否安裝了mysql-devel.i386
要是沒有可以安裝mysql-devel-3.23.54a-11.i386.rpm
#rpm -ivh mysql-devel-3.23.54a-11.i386.rpm
1.安裝freeradius
在http://www.freeradius.org
下載freeradius-1.1.0.tar.gz
#tar -xvzf freeradius-1.1.0.tar.gz
#cd freeradius-1.1.0
#./configure --prefix=/usr/local/freeradius-1.1.0
#make
#make install
2.配置ppp支持radius
从ppp的源代碼目錄下複製/etc/radiusclient/
#cp -R ppp-2.4.3/pppd/plugins/radius/etc /etc/radiusclient/
修改pptpd.option
加入 plugin /usr/lib/pppd/2.4.3/radius.so
配置 /etc/radiusclient中的servers和radiusclient.conf
#cd /etc/radiusclient
#vi servers
加入
localhost test
這裡localhost表示你的radiusd就是本機,並且訪問的密碼是 test
#vi radiusclient.conf
確認
authserver localhost:1812
acctserver localhost:1813
确认上面也是本地的,默认就是本地,所以一般不需要修改。
同时确保这个文件中radiusclient相关的路径所有的路径都是 /etc/radiusclient 开头的。
3.配置freeradius
cd /usr/local/freeradius-1.1.0/etc/raddb
raddb这个目录就是所有的freeradius配置文件所在了
3.1 修改clients.conf
这里说明一下,所有的nas都是radiusd的client,nas就是那个pptpd,所以这个文件就是配置pptpd的登陆权限的。
secret = test
shortname = test1234
nastype = other
}
3.2 在users文件的最上面加入一个用户
Service-Type = Framed-User,
Framed-Protocol = PPP,
Framed-IP-Address = 255.255.255.254,
Framed-IP-Netmask = 255.255.255.0
auth-type是验证的类型
第二个ww是密码
Simultaneous-Use是允许这个用户名同时登陆的个数
所有这些都是check属性,要写在第一行
然后第二行开始用tab开头,是服务器返回给radius客户端的(也就是返回给pptpd)时reply属性。
其中ip地址设置为255.255.255.254表示ip地址的分配是由radius客户端决定的,也就是由pptpd决定。
最后一个是子网掩码。
5.3用debug模式运行radiusd
Using deprecated naslist file. Support for this will go away soon.
Module: Loaded exec
rlm_exec: Wait=yes but no output defined. Did you mean output=none?
Module: Instantiated exec (exec)
Module: Loaded expr
Module: Instantiated expr (expr)
Module: Loaded PAP
Module: Instantiated pap (pap)
Module: Loaded CHAP
Module: Instantiated chap (chap)
Module: Loaded MS-CHAP
Module: Instantiated mschap (mschap)
Module: Loaded eap
rlm_eap: Loaded and initialized type md5
rlm_eap: Loaded and initialized type leap
rlm_eap: Loaded and initialized type gtc
rlm_eap: Loaded and initialized type mschapv2
Module: Instantiated eap (eap)
Module: Loaded preprocess
Module: Instantiated preprocess (preprocess)
Module: Loaded files
Module: Instantiated files (files)
Module: Loaded Acct-Unique-Session-Id
Module: Instantiated acct_unique (acct_unique)
Module: Loaded realm
Module: Instantiated realm (suffix)
Module: Loaded detail
Module: Instantiated detail (detail)
Module: Loaded radutmp
Module: Instantiated radutmp (radutmp)
Initializing the thread pool...
Listening on authentication *:1812
Listening on accounting *:1813
Ready to process requests.
建立一个新的vpn连接
用户名ww密码ww
然后拨号
成功的话,会看到。
Service-Type = Framed-User
Framed-Protocol = PPP
User-Name = "ww"
MS-CHAP-Challenge = 0x729e2492953298b498a766e778defe74
MS-CHAP2-Response = 0xfc00475dd294431a52ee1187d13127c3bf49
000000000000000043aad8bb5c
d6f5ece16ddae9d20c63d857836053b2197144
Calling-Station-Id = "192.168.8.53"
NAS-IP-Address = 127.0.0.1
NAS-Port = 0
Sending Access-Accept of id 214 to 127.0.0.1 port 32768
Service-Type = Framed-User
Framed-Protocol = PPP
Framed-IP-Address = 255.255.255.254
Framed-IP-Netmask = 255.255.255.0
MS-CHAP2-Success = 0xfc533d3130363732303745303738424443
313833344130353643433743304437304
6363942414446343039
MS-MPPE-Recv-Key = 0x0211fcb6f599479e8ee0a7d8a16a3252
MS-MPPE-Send-Key = 0x91242cedc84a2dc69355c56951119065
MS-MPPE-Encryption-Policy = 0x00000002
MS-MPPE-Encryption-Types = 0x00000004
rad_recv: Accounting-Request packet from host 127.0.0.1:32768, id=215, length=108
Acct-Session-Id = "43EBFF39048300"
User-Name = "ww"
Acct-Status-Type = Start
Service-Type = Framed-User
Framed-Protocol = PPP
Calling-Station-Id = "192.168.8.53"
Acct-Authentic = RADIUS
NAS-Port-Type = Async
Framed-IP-Address = 10.10.110.1
NAS-IP-Address = 127.0.0.1
NAS-Port = 0
Acct-Delay-Time = 0
Sending Accounting-Response of id 215 to 127.0.0.1 port 32768
用ctrl+c退出radius
配置mysql:
1.需要软件,什么都不需要。
你只要给各mysql的库就好了,库结构在
freeradius源码目录下的/src/modules/rlm_sql/drivers/rlm_sql_mysql/db_mysql.sql
你建立一个数据库就好了,我在我自己的机器上建立了一个名字为radius的数据库
并且导入了这个数据库的结构。
2。配置sql.conf
先回到刚才的freeradius的配置文件目录
修改连接信息
server = "172.16.2.74"
login = "radius"
password = "radius"
# Database table configuration
radius_db = "radius"
打开sql的用户同时连接数测试的语句
simul_count_query = "SELECT COUNT(*) FROM ${acct_table1} WHERE UserName='%{SQL-User-Name}' AND AcctStopTime = 0"
注释掉 authorize {
的files
去掉sql前的注释
注释掉 preacct {
的files
注释掉 accounting {
的radutmp
去掉sql前面的#
注释掉 session{
的radutmp
去掉sql前面的#
去掉 post-auth {
sql前的#
总之就是去掉files模块,开启sql模块
4。在数据库中添加用户
在usergroup中添加一个test用户,组名为vpn
在radgroupcheck中添加一个vpn组,
attribute为Simultaneous-Use
op为:=
value为1
的纪录
在radcheck中添加
username为test
attribute为 User-Password
op为==
value为test
这样就添加了一个用户为test,组为vpn,密码为test
并且所有的组用户的都只能1个用户名登陆一次
5.测试
用debug模式启动radiusd
会看到
Starting - reading configuration files ...
Using deprecated naslist file. Support for this will go away soon.
Module: Loaded exec
rlm_exec: Wait=yes but no output defined. Did you mean output=none?
Module: Instantiated exec (exec)
Module: Loaded expr
Module: Instantiated expr (expr)
Module: Loaded PAP
Module: Instantiated pap (pap)
Module: Loaded CHAP
Module: Instantiated chap (chap)
Module: Loaded MS-CHAP
Module: Instantiated mschap (mschap)
Module: Loaded eap
rlm_eap: Loaded and initialized type md5
rlm_eap: Loaded and initialized type leap
rlm_eap: Loaded and initialized type gtc
rlm_eap: Loaded and initialized type mschapv2
Module: Instantiated eap (eap)
Module: Loaded preprocess
Module: Instantiated preprocess (preprocess)
Module: Loaded SQL
rlm_sql (sql): Driver rlm_sql_mysql (module rlm_sql_mysql) loaded and linked
rlm_sql (sql): Attempting to connect to radius@192.168.8.53:/radius
rlm_sql (sql): starting 0
rlm_sql (sql): Attempting to connect rlm_sql_mysql #0
rlm_sql_mysql: Starting connect to MySQL server for #0
rlm_sql (sql): Connected new DB handle, #0
rlm_sql (sql): starting 1
rlm_sql (sql): Attempting to connect rlm_sql_mysql #1
rlm_sql_mysql: Starting connect to MySQL server for #1
rlm_sql (sql): Connected new DB handle, #1
rlm_sql (sql): starting 2
rlm_sql (sql): Attempting to connect rlm_sql_mysql #2
rlm_sql_mysql: Starting connect to MySQL server for #2
rlm_sql (sql): Connected new DB handle, #2
rlm_sql (sql): starting 3
rlm_sql (sql): Attempting to connect rlm_sql_mysql #3
rlm_sql_mysql: Starting connect to MySQL server for #3
rlm_sql (sql): Connected new DB handle, #3
rlm_sql (sql): starting 4
rlm_sql (sql): Attempting to connect rlm_sql_mysql #4
rlm_sql_mysql: Starting connect to MySQL server for #4
rlm_sql (sql): Connected new DB handle, #4
Module: Instantiated sql (sql)
Module: Loaded Acct-Unique-Session-Id
Module: Instantiated acct_unique (acct_unique)
Module: Loaded realm
Module: Instantiated realm (suffix)
Module: Loaded detail
Module: Instantiated detail (detail)
Initializing the thread pool...
Listening on authentication *:1812
Listening on accounting *:1813
Ready to process requests.
会看到
Service-Type = Framed-User
Framed-Protocol = PPP
User-Name = "test"
MS-CHAP-Challenge = 0xb6a9e94b94c3c386875043efd5144e17
MS-CHAP2-Response = 0x38006d78036bb5e40ddeca0ce96b944619e
000000000000000007b887b8762be38eb
111a94a4b581925b85e07453a38a070f
Calling-Station-Id = "192.168.8.53"
NAS-IP-Address = 127.0.0.1
NAS-Port = 0
rlm_sql (sql): Reserving sql socket id: 4
rlm_sql (sql): Released sql socket id: 4
rlm_sql (sql): Reserving sql socket id: 3
rlm_sql (sql): Released sql socket id: 3
rlm_sql (sql): Processing sql_postauth
rlm_sql (sql): Reserving sql socket id: 2
rlm_sql (sql): Released sql socket id: 2
Sending Access-Accept of id 222 to 127.0.0.1 port 32768
MS-CHAP2-Success = 0x38533d33453434464142394
232444230413143464539453832444536453
534373331383833454238414536
MS-MPPE-Recv-Key = 0x53a3812a0fd5b6f7b1cf4f6f6796f26b
MS-MPPE-Send-Key = 0xb8be60559cbc46fd4da277516d6584f3
MS-MPPE-Encryption-Policy = 0x00000002
MS-MPPE-Encryption-Types = 0x00000004
rad_recv: Accounting-Request packet from host 127.0.0.1:32768, id=223, length=110
Acct-Session-Id = "43EC0822056A00"
User-Name = "test"
Acct-Status-Type = Start
Service-Type = Framed-User
Framed-Protocol = PPP
Calling-Station-Id = "192.168.8.53"
Acct-Authentic = RADIUS
NAS-Port-Type = Async
Framed-IP-Address = 10.10.110.1
NAS-IP-Address = 127.0.0.1
NAS-Port = 0
Acct-Delay-Time = 0
rlm_sql (sql): Reserving sql socket id: 1
rlm_sql (sql): Released sql socket id: 1
Sending Accounting-Response of id 223 to 127.0.0.1 port 32768
会看到
Service-Type = Framed-User
Framed-Protocol = PPP
User-Name = "test"
MS-CHAP-Challenge = 0x2295d4d65913cbc0a7836e986fe4a998
MS-CHAP2-Response = 0x34001739a3331c1a1a938eed99cda89b691f
0000000000000000a8a9e9ae2eadaa6b1acb93e3
68113dc4ed47dac0a20b1ed8
Calling-Station-Id = "192.168.8.53"
NAS-IP-Address = 127.0.0.1
NAS-Port = 0
rlm_sql (sql): Reserving sql socket id: 4
rlm_sql (sql): Released sql socket id: 4
rlm_sql (sql): Reserving sql socket id: 3
rlm_sql (sql): Released sql socket id: 3
rad_recv: Access-Request packet from host 127.0.0.1:32768, id=225, length=146
Sending Access-Reject of id 225 to 127.0.0.1 port 32768
Reply-Message := "\r\nYou are already logged in - access denied\r\n\n"
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://cisd-ftp.swfc.edu.cn/~wx672/course_materials/unix-linux/linux_history/figs/stallman.jpg');}" onmousewheel="return imgzoom(this);" border="0">
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://cisd-ftp.swfc.edu.cn/~wx672/course_materials/unix-linux/linux_history/figs/linusnow2.jpg');}" onmousewheel="return imgzoom(this);" border="0">
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://cisd-ftp.swfc.edu.cn/~wx672/course_materials/unix-linux/linux_history/figs/laptop.jpg');}" onmousewheel="return imgzoom(this);" border="0">
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://cisd-ftp.swfc.edu.cn/~wx672/course_materials/unix-linux/linux_history/figs/Linus_Torvalds.jpg');}" onmousewheel="return imgzoom(this);" border="0">
screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onmouseover="if(this.width>screen.width*0.7) {this.resized=true; this.width=screen.width*0.7; this.style.cursor='hand'; this.alt='Click here to open new window\nCTRL+Mouse wheel to zoom in/out';}" onclick="if(!this.resized) {return true;} else {window.open('http://cisd-ftp.swfc.edu.cn/~wx672/course_materials/unix-linux/linux_history/figs/family.jpg');}" onmousewheel="return imgzoom(this);" border="0">