Centos6配置PPTP連接VPS服務器

簡述:

PPTP:點對點隧道協議

(PPTP: Point to Point Tunneling Protocol)

通過該協議,遠程用戶能夠通過 Microsoft Windows NT 工作站、Windows 95 和 Windows

98 操作系統以及其它裝有點對點協議的系統安全訪問公司網絡,並能撥號連入本地 ISP,通過 Internet 安全鏈接到公司網絡。

一、安裝前準備

首先檢查你 VPS 的 PPP 和 TUN 有沒有啓用:

[root@yunwei_cq ~]# cat /dev/ppp
cat: /dev/ppp: No such device or address
[root@yunwei_cq ~]#
[root@yunwei_cq ~]#
[root@yunwei_cq ~]# cat /dev/net/tun
cat: /dev/net/tun: File descriptor in bad state

顯示結果爲:

cat: /dev/ppp: No such device or address
cat: /dev/net/tun: File descriptor in bad state

表明通過,上述兩條只要有一個沒通過都不行。如果沒有啓用,你可以給 VPS 提供商 Submit

一個 Ticket 請求開通:

Hello

Could you enabled TUN-TAP for me? I want run pptpon my VPS.

Thank you.

確認 PPP 和 TUN 啓用後,開始安裝 ppp 和 iptables

二、安裝 ppp 和 iptables

1.安裝前檢查是否已安裝(本機已安裝 iptables)

[root@yunwei_cq ~]# rpm -qa | grep ppp
[root@yunwei_cq ~]# rpm -qa | grep iptables
iptables-1.4.7-11.el6.x86_64
iptables-ipv6-1.4.7-11.el6.x86_64

2.安裝 ppp 協議

[root@yunwei_cq yum.repos.d]# yum install -y ppp 
    Loaded plugins: fastestmirror, security
Repository base is listed more than once in the configuration Loading mirror speeds from cached hostfile
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package ppp.x86_64 0:2.4.5-10.el6 will be installed --> Finished Dependency Resolution ...

三、安裝 pptpd 程序

1.如果提示沒有 pptpd 安裝包,需要自己下載安裝。

[root@yunwei_cq yum.repos.d]# yum install -y pptpd 
    Loaded plugins: fastestmirror, security
Repository base is listed more than once in the configuration Loading mirror speeds from cached hostfile Setting up Install Process
No package pptpd available.

附 rpm 安裝包安裝地址: https://down.51cto.com/data/2368471

2.安裝 pptpd 服務

[root@yunwei_cq packages]# rpm -ivh pptpd-1.3.4-2.el6.x86_64.rpm
warning: pptpd-1.3.4-2.el6.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 862acc42:
NOKEY
Preparing...
1:pptpd
########################################### [100%]
########################################### [100%]

四、修改配置文件

1.vim /etc/pptpd.conf

option /etc/ppp/options.pptpd   ##配置文件路徑
logwtmp ##日誌
localip xxxxxxxxx   ## 填寫遠程服務器的外網地址
remoteip 192.168.101.1-50   ## 給一個分配給連接的客戶機的 IP 地址範圍。

2、vim /etc/ppp/options.pptpd

name pptpd  ##設置名稱
refuse-pap
refuse-chap
refuse-mschap
require-mschap-v2
require-mppe-128
proxyarp
lock
nobsdcomp
novj
novjccomp
nologfd
ms-dns 114.114.114.114  ##修改 DNS 地址
ms-dns 8.8.8.8  ##備用地址

3、vim /etc/ppp/chap-secrets

# Secrets for authentication using CHAP
# client server secret IP addresses ## client 客戶端(用戶名)server(服務器主機名) secret 加密密碼(密碼) ip ## addresses (遠程主機設置固定 ip 地址)
"hongkun"   *   "test"  *

上面第二行代碼的四項內容分別對應第一行中的四項。“[email protected]”是 Client 端的連接的用戶名;“server”對應的是 VPS 服務器的名字,該名字必須和/etc/ppp/options.pptpd 文件中指明的一樣,或者設置成“”號來表示自動識別服務器;“secret”對應的是登錄密碼;“IP addresses”對應的是可以撥入的客戶端 IP 地址,如果不需要做特別限制,可以將其設置爲“”號。

4、vim /etc/sysctl.conf ##開啓 IP 轉發

#   Kernel sysctl configuration file for Red Hat Linux
#   For binary values, 0 is disabled, 1 is enabled.  See sysctl(8) and
#   sysctl.conf(5) for more details.
#   Controls IP packet forwarding
net.ipv4.ip_forward = 1 ## 將這個值改爲 1 其他的不動
#   Controls source route verification net.ipv4.conf.default.rp_filter = 0
#   Do not accept source routing net.ipv4.conf.default.accept_source_route = 0
#   Controls the System Request debugging functionality of the kernel kernel.sysrq = 0

5、sysctl -p (強制刷新)

net.ipv4.ip_forward = 1
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.default.accept_source_route = 0
kernel.sysrq = 0
kernel.core_uses_pid = 1
net.ipv4.tcp_syncookies = 1
net.bridge.bridge-nf-call-ip6tables = 0
net.bridge.bridge-nf-call-iptables = 0
net.bridge.bridge-nf-call-arptables = 0
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 68719476736
kernel.shmall = 4294967296

五、iptables

需要開啓 1723 端口

iptables -A INPUT -p tcp -m tcp --dport 1723 -j ACCEPT  (開啓 1723 端口)
/etc/init.d/iptables save   ##保存防火牆配置
/etc/init.d/iptables resart ##重啓防火牆
chkconfig iptables --level 345 on (開機自動啓動)
chkconfig pptpd --level 345 on
/etc/init.d/pptpd start (啓動 pptpd)
Starting pptpd:      [確定]

六、測試

Win10 系統設置 *PN 的方法:

1、要在 Win10 上設置 PN,請單擊左下角的“開始”按鈕,然後選擇“設置”選項。 然後單擊“網絡和 Internet”,然後單擊“PN”。下一步是單擊“添加 *PN 連接”,之後是時候添加所有必需的信息。

2、首先單擊“PN 提供商”下拉列表,然後選擇唯一可用的選項 - Windows(內置)。 在“連接名稱”字段中,鍵入您希望連接到 PN 時可以識別的選項名稱。

3、現在是時候添加一個“服務器名稱或地址”,選擇“*PN 類型”下的“自動”選項,然後選擇“登錄信息類型”選項之一。在大多數情況下,這將是默認值 - “用戶名和密碼”。

4、下一步是將您的輸入信息添加到“用戶名”和“密碼”字段,然後單擊“保存”按鈕完成該過程。

注:如果連接* PN 後本機不能連接上網,點擊如下設置:

Centos6配置PPTP連接VPS服務器

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章