Total Pageviews

Friday, 25 November 2011

在CentOS vps下,搭建pptpd VPN服务

1. 查看VPS是否开通tun和ppp功能(tun为安装openvpn所必须,ppp为安装pptp vpn服务所必须).
#cat /dev/net/tun
返回以下信息,表示tun开启,可以安装openvpn服务:
cat: /dev/net/tun: File descriptor in bad state
然后查看PPP权限是否开通
#cat /dev/ppp
返回以下结果表面ppp正常:
cat: /dev/ppp: No such device or address
如果返回结果不是上面的情况,请与网页下方的QQ客服联系,开通PPP权限。
2. 下载CentOS VPN一键安装脚本
wget http://www.hi-vps.com/shell/vpn_centos.sh
bash vpn_centos.sh
运行脚本后,有三个提示:
1. 安装VPN服务
2. 修复VPN服务
3. 添加VPN用户
一般首次安装使用第一个选项,即“安装VPN服务”,输入1后回车,等一会安装完毕后系统会生成一个默认用户名为“vpn”,密码为随机的用户名。
3. 添加用户
您的VPN服务可能像提供给更多人使用,可以添加用户:
bash vpn_centos.sh
输入3后回车,然后输入需要添加的用户名和密码即可。
4. 修复VPN服务
可能有时候VPN服务损坏无法开启,选择2可以修复VPN服务。
-------------------------------------------------------------------------

CentOS vps下,搭建pptpd VPN服务全程实录

1. 查看VPS是否开通tun和ppp功能(tun为安装openvpn所必须,ppp为安装pptpd vpn服务所必须).

#cat /dev/net/tun

返回以下信息,表示tun开启,可以安装openvpn服务:

cat: /dev/net/tun: File descriptor in bad state

然后查看PPP权限是否开通

#cat /dev/ppp

返回以下结果表面ppp正常:

cat: /dev/ppp: No such device or address

如果返回结果不是上面的情况,请与VPS提供方客服联系,开通PPP权限。

2. 下载CentOS VPN一键安装脚本

这里我用了HI-VPS的这个脚本

依次运行:
wget http://www.hi-vps.com/shell/vpn_centos.sh

bash vpn_centos.sh

由于我开始没有UPDATE系统。安装的时候需要点时间。更新了一些软件。
有点耐心等就好了。看网络和服务器情况的。

运行脚本后,有三个提示:
1. 安装VPN服务
2. 修复VPN服务
3. 添加VPN用户

一般首次安装使用第一个选项,即“安装VPN服务”,输入1后回车,等一会安装完毕后系统会生成一个默认用户名为“vpn”,密码为随机的用户名。

3. 添加用户

您的VPN服务可能像提供给更多人使用,可以添加用户:

bash vpn_centos.sh

输入3后回车,然后输入需要添加的用户名和密码即可。

4. 修复VPN服务

可能有时候VPN服务损坏无法开启,选择2可以修复VPN服务。
以下为安装全程实录:

[root@vps /]# cat /dev/net/tun
cat: /dev/net/tun: File descriptor in bad state
[root@vps /]# cat /dev/ppp
cat: /dev/ppp: No such device or address
[root@vps /]# wget http://www.hi-vps.com/shell/vpn_centos.sh
–2011-10-21 23:45:53–  http://www.hi-vps.com/shell/vpn_centos.sh
Resolving www.hi-vps.com… 76.164.216.195
Connecting to www.hi-vps.com|76.164.216.195|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 2350 (2.3K) [application/octet-stream]
Saving to: `vpn_centos.sh’

100%[=========================================================================>] 2,350       –.-K/s   in 0s    

2011-10-21 23:45:54 (149 MB/s) – `vpn_centos.sh’ saved [2350/2350]

[root@vps /]# bash vpn_centos.sh
which do you want to?input the number.
1. install VPN service
2. repaire VPN service
3. add VPN user
1
begin to install VPN services
Loaded plugins: fastestmirror
Setting up Remove Process
No Match for argument: pptpd
Determining fastest mirrors
 * base: mirror.san.fastserv.com
 * extras: mirrors.kernel.org
 * updates: centosz4.centos.org
base                                                                                                       | 1.1 kB     00:00   
base/primary                                                                                               | 961 kB     00:00   
base                                                                                                                    2705/2705
extras                                                                                                     | 2.1 kB     00:00   
extras/primary_db                                                                                          | 154 kB     00:00   
updates                                                                                                    | 1.9 kB     00:00   
updates/primary_db                                                                                         | 232 kB     00:00   
vz-base                                                                                                    |  951 B     00:00   
vz-base/primary                                                                                            | 1.7 kB     00:00   
vz-base                                                                                                                       5/5
vz-updates                                                                                                 |  951 B     00:00   
vz-updates/primary                                                                                         | 1.0 kB     00:00   
vz-updates                                                                                                                    3/3
No Match for argument: ppp
Package(s) ppp available, but not installed.
No Packages marked for removal
–2011-10-21 23:49:35–  http://www.hi-vps.com/downloads/dkms-2.0.17.5-1.noarch.rpm
Resolving www.hi-vps.com… 76.164.216.195
Connecting to www.hi-vps.com|76.164.216.195|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 91440 (89K) [application/x-redhat-package-manager]
Saving to: `dkms-2.0.17.5-1.noarch.rpm’

100%[========================================================================================>] 91,440       523K/s   in 0.2s  

2011-10-21 23:49:36 (523 KB/s) – `dkms-2.0.17.5-1.noarch.rpm’ saved [91440/91440]

–2011-10-21 23:49:36–  http://www.hi-vps.com/downloads/kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm
Resolving www.hi-vps.com… 76.164.216.195
Connecting to www.hi-vps.com|76.164.216.195|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 105346 (103K) [application/x-redhat-package-manager]
Saving to: `kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm’

100%[========================================================================================>] 105,346     –.-K/s   in 0.07s 

2011-10-21 23:49:36 (1.41 MB/s) – `kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm’ saved [105346/105346]

–2011-10-21 23:49:36–  http://www.hi-vps.com/downloads/pptpd-1.3.4-1.rhel5.1.i386.rpm
Resolving www.hi-vps.com… 76.164.216.195
Connecting to www.hi-vps.com|76.164.216.195|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 81566 (80K) [application/x-redhat-package-manager]
Saving to: `pptpd-1.3.4-1.rhel5.1.i386.rpm’

100%[========================================================================================>] 81,566      –.-K/s   in 0.07s 

2011-10-21 23:49:36 (1.13 MB/s) – `pptpd-1.3.4-1.rhel5.1.i386.rpm’ saved [81566/81566]

–2011-10-21 23:49:36–  http://www.hi-vps.com/downloads/ppp-2.4.4-9.0.rhel5.i386.rpm
Resolving www.hi-vps.com… 76.164.216.195
Connecting to www.hi-vps.com|76.164.216.195|:80… connected.
HTTP request sent, awaiting response… 200 OK
Length: 359397 (351K) [application/x-redhat-package-manager]
Saving to: `ppp-2.4.4-9.0.rhel5.i386.rpm’

100%[========================================================================================>] 359,397     –.-K/s   in 0.1s  

2011-10-21 23:49:36 (2.63 MB/s) – `ppp-2.4.4-9.0.rhel5.i386.rpm’ saved [359397/359397]

Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.san.fastserv.com
 * extras: mirrors.kernel.org
 * updates: centosz4.centos.org
Setting up Install Process
Package 1:make-3.81-3.el5.i386 already installed and latest version
Package iptables-1.3.5-5.3.el5_4.1.i386 already installed and latest version
Package 2:tar-1.15.1-30.el5.i386 already installed and latest version
Package cpio-2.6-23.el5_4.1.i386 already installed and latest version
Package 4:perl-5.8.8-32.el5_6.3.i386 already installed and latest version
Package pam-0.99.6.2-6.el5_5.2.i386 already installed and latest version
Package tcp_wrappers-7.6-40.7.el5.i386 already installed and latest version
Resolving Dependencies
–> Running transaction check
—> Package gcc-c++.i386 0:4.1.2-51.el5 set to be updated
–> Processing Dependency: gcc = 4.1.2-51.el5 for package: gcc-c++
–> Processing Dependency: libstdc++-devel = 4.1.2-51.el5 for package: gcc-c++
–> Processing Dependency: libstdc++ = 4.1.2-51.el5 for package: gcc-c++
—> Package libpcap.i386 14:0.9.4-15.el5 set to be updated
—> Package logrotate.i386 0:3.7.4-12 set to be updated
–> Running transaction check
—> Package gcc.i386 0:4.1.2-51.el5 set to be updated
–> Processing Dependency: cpp = 4.1.2-51.el5 for package: gcc
–> Processing Dependency: libgomp >= 4.1.2-51.el5 for package: gcc
–> Processing Dependency: glibc-devel >= 2.2.90-12 for package: gcc
–> Processing Dependency: libgcc >= 4.1.2-51.el5 for package: gcc
—> Package libstdc++.i386 0:4.1.2-51.el5 set to be updated
—> Package libstdc++-devel.i386 0:4.1.2-51.el5 set to be updated
base/filelists                                                                                             | 2.9 MB     00:00   
extras/filelists_db                                                                                        | 174 kB     00:00   
updates/filelists_db                                                                                       | 1.1 MB     00:00   
vz-base/filelists                                                                                          |  979 B     00:00   
vz-updates/filelists                                                                                       |  360 B     00:00   
–> Running transaction check
—> Package cpp.i386 0:4.1.2-51.el5 set to be updated
—> Package glibc-devel.i386 0:2.5-65 set to be updated
–> Processing Dependency: glibc-headers = 2.5-65 for package: glibc-devel
–> Processing Dependency: glibc = 2.5-65 for package: glibc-devel
–> Processing Dependency: glibc-headers for package: glibc-devel
—> Package libgcc.i386 0:4.1.2-51.el5 set to be updated
—> Package libgomp.i386 0:4.4.4-13.el5 set to be updated
–> Running transaction check
–> Processing Dependency: glibc = 2.5-58.el5_6.4 for package: nscd
—> Package glibc.i686 0:2.5-65 set to be updated
–> Processing Dependency: glibc-common = 2.5-65 for package: glibc
—> Package glibc-headers.i386 0:2.5-65 set to be updated
–> Processing Dependency: kernel-headers >= 2.2.1 for package: glibc-headers
–> Processing Dependency: kernel-headers for package: glibc-headers
–> Running transaction check
—> Package glibc-common.i386 0:2.5-65 set to be updated
—> Package kernel-headers.i386 0:2.6.18-274.7.1.el5 set to be updated
—> Package nscd.i386 0:2.5-65 set to be updated
–> Finished Dependency Resolution

Dependencies Resolved

==================================================================================================================================
 Package                           Arch                   Version                                 Repository                 Size
==================================================================================================================================
Installing:
 gcc-c++                           i386                   4.1.2-51.el5                            base                      3.4 M
 libpcap                           i386                   14:0.9.4-15.el5                         base                      108 k
Updating:
 logrotate                         i386                   3.7.4-12                                base                       42 k
Installing for dependencies:
 cpp                               i386                   4.1.2-51.el5                            base                      2.7 M
 gcc                               i386                   4.1.2-51.el5                            base                      5.2 M
 glibc-devel                       i386                   2.5-65                                  base                      2.0 M
 glibc-headers                     i386                   2.5-65                                  base                      604 k
 kernel-headers                    i386                   2.6.18-274.7.1.el5                      updates                   1.2 M
 libgomp                           i386                   4.4.4-13.el5                            base                       72 k
 libstdc++-devel                   i386                   4.1.2-51.el5                            base                      2.8 M
Updating for dependencies:
 glibc                             i686                   2.5-65                                  base                      5.3 M
 glibc-common                      i386                   2.5-65                                  base                       16 M
 libgcc                            i386                   4.1.2-51.el5                            base                       96 k
 libstdc++                         i386                   4.1.2-51.el5                            base                      362 k
 nscd                              i386                   2.5-65                                  base                      169 k

Transaction Summary
==================================================================================================================================
Install       9 Package(s)
Upgrade       6 Package(s)

Total download size: 41 M
Downloading Packages:
(1/15): logrotate-3.7.4-12.i386.rpm                                                                        |  42 kB     00:00   
(2/15): libgomp-4.4.4-13.el5.i386.rpm                                                                      |  72 kB     00:00   
(3/15): libgcc-4.1.2-51.el5.i386.rpm                                                                       |  96 kB     00:00   
(4/15): libpcap-0.9.4-15.el5.i386.rpm                                                                      | 108 kB     00:00   
(5/15): nscd-2.5-65.i386.rpm                                                                               | 169 kB     00:00   
(6/15): libstdc++-4.1.2-51.el5.i386.rpm                                                                    | 362 kB     00:00   
(7/15): glibc-headers-2.5-65.i386.rpm                                                                      | 604 kB     00:00   
(8/15): kernel-headers-2.6.18-274.7.1.el5.i386.rpm                                                         | 1.2 MB     00:00   
(9/15): glibc-devel-2.5-65.i386.rpm                                                                        | 2.0 MB     00:00   
(10/15): cpp-4.1.2-51.el5.i386.rpm                                                                         | 2.7 MB     00:00   
(11/15): libstdc++-devel-4.1.2-51.el5.i386.rpm                                                             | 2.8 MB     00:00   
(12/15): gcc-c++-4.1.2-51.el5.i386.rpm                                                                     | 3.4 MB     00:00   
(13/15): gcc-4.1.2-51.el5.i386.rpm                                                                         | 5.2 MB     00:01   
(14/15): glibc-2.5-65.i686.rpm                                                                             | 5.3 MB     00:01   
(15/15): glibc-common-2.5-65.i386.rpm                                                                      |  16 MB     00:03   
———————————————————————————————————————————-
Total                                                                                             3.5 MB/s |  41 MB     00:11   
warning: rpmts_HdrFromFdno: Header V3 DSA signature: NOKEY, key ID e8562897
base/gpgkey                                                                                                | 1.5 kB     00:00   
Importing GPG key 0xE8562897 “CentOS-5 Key (CentOS 5 Official Signing Key) <centos-5-key@centos.org>” from /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-5
Running rpm_check_debug
Running Transaction Test
Finished Transaction Test
Transaction Test Succeeded
Running Transaction
  Updating       : libgcc                                                                                                    1/21
  Updating       : glibc-common                                                                                              2/21
  Installing     : kernel-headers                                                                                            3/21
  Updating       : glibc                                                                                                     4/21
  Updating       : libstdc++                                                                                                 5/21
  Installing     : cpp                                                                                                       6/21
  Installing     : libgomp                                                                                                   7/21
  Updating       : logrotate                                                                                                 8/21
  Installing     : libpcap                                                                                                   9/21
  Updating       : nscd                                                                                                     10/21
  Installing     : libstdc++-devel                                                                                          11/21
  Installing     : glibc-headers                                                                                            12/21
  Installing     : glibc-devel                                                                                              13/21
  Installing     : gcc                                                                                                      14/21
  Installing     : gcc-c++                                                                                                  15/21
  Cleanup        : glibc                                                                                                    16/21
  Cleanup        : logrotate                                                                                                17/21
  Cleanup        : libgcc                                                                                                   18/21
  Cleanup        : libstdc++                                                                                                19/21
  Cleanup        : nscd                                                                                                     20/21
  Cleanup        : glibc-common                                                                                             21/21

Installed:
  gcc-c++.i386 0:4.1.2-51.el5                                     libpcap.i386 14:0.9.4-15.el5                                  

Dependency Installed:
  cpp.i386 0:4.1.2-51.el5                     gcc.i386 0:4.1.2-51.el5                          glibc-devel.i386 0:2.5-65        
  glibc-headers.i386 0:2.5-65                 kernel-headers.i386 0:2.6.18-274.7.1.el5         libgomp.i386 0:4.4.4-13.el5      
  libstdc++-devel.i386 0:4.1.2-51.el5      

Updated:
  logrotate.i386 0:3.7.4-12                                                                                                     

Dependency Updated:
  glibc.i686 0:2.5-65  glibc-common.i386 0:2.5-65  libgcc.i386 0:4.1.2-51.el5  libstdc++.i386 0:4.1.2-51.el5  nscd.i386 0:2.5-65

Complete!
warning: dkms-2.0.17.5-1.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 862acc42
Preparing…                ########################################### [100%]
   1:dkms                   ########################################### [100%]
warning: kernel_ppp_mppe-1.0.2-3dkms.noarch.rpm: Header V3 DSA signature: NOKEY, key ID 862acc42
Preparing…                ########################################### [100%]
   1:kernel_ppp_mppe        ########################################### [100%]

Creating symlink /var/lib/dkms/kernel_ppp_mppe/1.0.2/source ->
                 /usr/src/kernel_ppp_mppe-1.0.2

DKMS: add Completed.
Module build for the currently running kernel was skipped
since the kernel source for this kernel does not seem to be
installed.
kernel_ppp_mppe-1.0.2-3dkms
warning: ppp-2.4.4-9.0.rhel5.i386.rpm: Header V3 DSA signature: NOKEY, key ID 862acc42
Preparing…                ########################################### [100%]
   1:ppp                    ########################################### [100%]
warning: pptpd-1.3.4-1.rhel5.1.i386.rpm: Header V3 DSA signature: NOKEY, key ID 862acc42
Preparing…                ########################################### [100%]
   1:pptpd                  ########################################### [100%]
mknod: `/dev/ppp’: File exists
Saving firewall rules to /etc/sysconfig/iptables:          [  OK  ]
Flushing firewall rules:                                   [  OK  ]
Setting chains to policy ACCEPT: mangle filter nat         [  OK  ]
Unloading iptables modules:                                [  OK  ]
Applying iptables firewall rules:                          [  OK  ]
Starting pptpd:                                            [  OK  ]
VPN service is installed, your VPN username is vpn, VPN password is 这里是随机密码
[root@vps /]#

至此VPS上的需要的准备完成。你可以进入在自己机器设置VPN拨号连接。就可以畅游GFW外的世界了.

No comments:

Post a Comment