在Linux下配置PPTP+MPPC+MPPC服務

來源:互聯網
上載者:User

Author : Kendiv
Date   : 2006.12.16

***********************************
    所使用的軟體
***********************************
1. linux-2.6.12.6.tar.bz2
2. linux-2.6.12-mppe-mppc-1.3.patch.gz
3. ppp-2.4.3.tar.gz
4. ppp-2.4.3-mppe-mppc-1.1.patch.gz
5. pptpd-1.3.3.tar.gz

***********************************
一、下載最新的Kernel原始碼
***********************************
:http://www.kernel.org/pub/linux/kernel/

http://pptpclient.sourceforge.net/
News: MPPE in Linux 2.6.15
Linux kernel 2.6.15 has been released and includes the PPP MPPE encryption module,
which implements the Microsoft Point-to-Point Encryption method as a PPP compressor/decompressor.
This is necessary for Linux clients and servers to interoperate with
Microsoft Point-to-Point Tunneling Protocol (PPTP) servers
(either Microsoft PPTP servers or the poptop project) which use MPPE to encrypt data when creating a VPN.

Now that Linux includes the module, the PPTP projects recommend upgrading to 2.6.15.

-- James Cameron

看來如果使用 Linux 2.6.15的話,就不需要打MPPC/MPPE補丁

/* PPTPD */
http://sourceforge.net/project/showfiles.php?group_id=44827&release_id=138437

/* MPPC/MPPE */
http://mppe-mppc.alphacron.de/

***********************************
二、打MPPC/MPPE補丁
***********************************
#cp linux-2.6.12.6.tar.bz2 /usr/src/kernels
#cd /usr/src/kernels
#tar xvjf linux-2.6.12.6.tar.bz2
#Patch Kernel files
#cd /usr/src/kernels
#ln -s /usr/src/kernels/linux-2.6.12.6/ linux-2.6.12
#patch -p0 -i linux-2.6.12-mppe-mppc-1.3.patch.gz

/**********************************************************/
patching file linux-2.6.12/drivers/net/Makefile
patching file linux-2.6.12/drivers/net/ppp_generic.c
create the file linux-2.6.12/drivers/net/ppp_mppe_mppc.c
patching file linux-2.6.12/include/linux/ppp-comp.h
/**********************************************************/

***********************************
三、定製核心
***********************************
#cd /usr/src/kernels/linux-2.6.12/
#make clean
#make menuconfig
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
ext2和ext3檔案系統配置為: (全部選擇)
File systems --->
  <*>Second extended fs support
      Ext2 extended attributes
      Ext2 POSIX Access Control Lists
      Ext2 Security Labels
  <*>Ext3 journalling file system support
      Ext3 extended attributes
      Ext3 POSIX Access Control Lists
      Ext3 Security Labels
  JBB (ext3) debugging support
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
選擇進入Device Drivers ->; Networking support ->;
<>; PPP BSD-Compress compression
<>; Microsoft PPP compression/encryption (MPPC/MPPE)
找到上面兩項,分別按下空格鍵,最前面的<>;就會變成<M>;,如下
<M>; PPP BSD-Compress compression
<M>; Microsoft PPP compression/encryption (MPPC/MPPE)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
在 Cryptographic options 內把SHA1 、ARC4等以模組的方式載入。
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=

***********************************
四、編譯核心及模組
***********************************
#make -jn (n代表同時編譯的進程,可以加快編譯速度,n由你的配置決定,我的配置用15-25)

注意: 此命令已完成make bzImage及make modules的工作, 產生的bzImage核心檔案在arch/i386/boot目錄中,你的CPU不同核心檔案存放位置也不同

注: 這一步比較耗時,根據機器配置,可能會消耗30分鐘或更長時間。

***********************************
五、編譯可載入模組和安裝新核心
***********************************
如果使用者在配置核心時設定了可載入模組,則需要對這些模組進行編譯,以便將來使用insmod命令進行載入。
# make modules_install (安裝核心模組到/lib/modules/2.x.x下)
# make install         (完成mkinitrd命令及核心(bzImage)和System.map的拷貝)

完成後,請查看/boot目錄,檔案名稱是有區別的,如是GRUB引導,make install命令已幫你自動修改了引導選項,對於LILO則要手工修改,重寫引導記錄。

***********************************
檢驗核心和PPP是否支援MPPE/MPPE
***********************************
#strings 'which pppd' | grep -i mppe | wc --lines
如果以上命令輸出為“0”則表示不支援;輸出為"30"或更大的數字就表示支援。

#strings 'which pppd' | grep -i mppc | wc --lines
如果以上命令輸出為“0”則表示不支援;輸出為"7"或更大的數字就表示支援。

#dmesg | grep MPPE
  MPPE/MPPC encryption/compression module registered

If you have compiled MPPE/MPPC as module, add to your /etc/modules.conf following line:

alias ppp-compress-18 ppp_mppe_mppc

編輯/etc/modules.conf設定檔,加入如下內容:
alias char-major-108 ppp_generic
alias tty-ldisc-3 ppp_async
alias tty-ldisc-14 ppp_synctty
alias ppp-compress-18 ppp_mppe_mppc # 我只增加了這一行
alias ppp-compress-21 bsd_comp
#alias ppp-compress-24 ppp_deflate
#alias ppp-compress-26 ppp_deflate
alias net-pf-47 ip_gre

每次系統啟動時都需要載入模組才行,因此我們要在/etc/rc.d/rc.local裡面寫入一行:
/sbin/modprobe ppp_mppe_mppc

***********************************
安裝PPP
***********************************
#rpm -e --nodeps ppp  #卸載預設的ppp-2.4.2
#tar zxvf ppp-2.4.3.tar.gz
#patch –p0 –i ppp-2.4.3-mppe-mppc-1.1.patch.gz
#cd ppp-2.4.3
#./configure
#make
#make install

 預設會將pppd安裝到 /usr/local/lib/pppd 和 /usr/local/sbin/pppd

系統中原有的pppd安裝在 /usr/lib/pppd目錄下,如果前面已經 rpm -e --nodeps ppp.

就不用刪除/usr/lib/pppd目錄了。

***********************************
安裝PPTP
***********************************
#tar zxvf pptpd-1.3.3.tar.gz
#cd pptpd-1.3.3
#./configure
#make
#make install

***********************************
修改設定檔
***********************************
/etc/pptpd.conf              # Poptop設定檔
/etc/ppp/options.pptpd       # Poptop選項檔案(正確的options.pptpd是非常必要)
/etc/ppp/chap-secrets        # 帳號、密碼存放檔案

****************
/* pptpd.conf */
****************
#/etc/pptpd.conf
ppp /usr/local/sbin/pppd  # Specifiy your pppd
option /etc/ppp/options.pptpd
debug
Logwtmp
localip 192.168.1.100         # VPN Server IP
remoteip 192.168.1.5,192.168.1.6    # Clients Ip Pool

*******************
/* options.pptpd */
*******************
#/etc/ppp/options.pptpd
name Mimi.VPN                # VPN Server Name
lock
mtu 1450
mru 1450
proxyarp
auth
ipcp-accept-local
ipcp-accept-remote
lcp-echo-failure 3
lcp-echo-interval 5
deflate 0

# Handshake Auth Method
+chap
+mschap-v2 # mppe require client use mschap-v2

# Data Encryption Methods
mppe required

logfile /var/log/pptpd.log # path of logfiles

ms-wins 192.168.1.2        # wins ip
ms-dns 192.168.1.2         # dns ip

*******************
/* chap-secrets */
*******************
#/etc/ppp/chap-secrets

# client server secret IP addresses
 "Kendiv"  Mimi.VPN  "12345" *

上面第二行代碼的四項內容分別對應第一行中的四項。"abc1"是Client端的VPN使用者名稱;
"server"對應的是VPN伺服器的名字,該名字必須和/etc/ppp/options.pptpd檔案中指明的一樣,
或者設定成"*"號來表示自動識別伺服器;"secret"對應的是登入密碼;
"IP addresses"對應的是可以撥入的用戶端IP地址,如果不需要做特別限制,可以將其設定為"*"號。

***********************************
設定IP偽裝轉寄
***********************************
只有設定了IP偽裝轉寄,通過VPN串連上來的遠端電腦才能互相ping通,實現像區域網路那樣的共用。用下面的命令進行設定:
#echo 1 > /proc/sys/net/ipv4/ip_forward
可以將這條命令放到檔案/etc/rc.d/rc.local裡面,以實現每次開機時自動運行該命令。

***********************************
啟動pptpd
***********************************
# /usr/local/sbin/pptpd

***********************************
查看載入的Modules
***********************************
# depmod -a
# updatedb
# locate ppp|grep bi

我安裝完成後,發現/var/log/messages裡有如下內容:

Dec 16 14:53:26 MiMi kernel: PPP generic driver version 2.4.2 #不用管,只要制定真正的pppd所在路徑即可.
Dec 16 14:53:26 MiMi kernel: MPPE/MPPC encryption/compression module registered  # 表示MPPE/MPPC已經成功載入到Kernel

成功與VPN Server建立串連後,/var/log/messages裡會有如下內容:

Dec 16 15:57:56 MiMi pptpd[5225]: CTRL: Starting call (launching pppd, opening GRE)
Dec 16 15:57:56 MiMi pppd[5226]: pppd 2.4.3 started by root, uid 0
Dec 16 15:57:56 MiMi pppd[5226]: Using interface ppp0
Dec 16 15:57:56 MiMi pppd[5226]: Connect: ppp0 <--> /dev/pts/1
Dec 16 15:57:59 MiMi pptpd[5225]: CTRL: Ignored a SET LINK INFO packet with real ACCMs!
Dec 16 15:57:59 MiMi pppd[5226]: Warning - secret file /etc/ppp/chap-secrets has world and/or group access
Dec 16 15:57:59 MiMi pppd[5226]: MPPC/MPPE 128-bit stateful compression enabled
Dec 16 15:58:00 MiMi pppd[5226]: found interface eth0 for proxy arp
Dec 16 15:58:00 MiMi pppd[5226]: local  IP address 192.168.1.100
Dec 16 15:58:00 MiMi pppd[5226]: remote IP address 192.168.1.5
Dec 16 16:01:01 MiMi crond(pam_unix)[5244]: session opened for user root by (uid=0) 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.