2014年5月14日星期三

Centos 6.4 Linux 搭建pptp

In this article we show you how to install and properly configure a PPTP VPN server in RHEL/CentOS linux. With this VPN you’ll have access to transfering your data encrypted and using a ethernet interface that uses your Server IP address. This tunneling technology is compatible with several devices like desktop operating systems, mobile phones and tablets.
First need enable tun module (tunelling kernel module):
  1. # echo 'modprobe tun' >> /etc/rc.modules
  2. # chmod +x /etc/rc.modules
At next boot will be loaded tun module in kernel
Make sure you begin with a clean install by removing any previously installed packages:
  1. yum remove -y pptpd ppp
  2. iptables --flush POSTROUTING --table nat
  3. iptables --flush FORWARD
  4. rm -rf /etc/pptpd.conf
  5. rm -rf /etc/ppp

Installation procedure

First, install the poptop package from sourceforge:
  1. rpm -Uhv http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm
  2. yum -y install make libpcap iptables gcc-c++ logrotate tar cpio perl pam tcp_wrappers dkms kernel_ppp_mppe ppp pptpd
Now, we need to enable IP forwading, set internal IP addresses and point the DNS Servers that will be used by the pptp server:
  1. mknod /dev/ppp c 108 0
  2. echo 1 > /proc/sys/net/ipv4/ip_forward
  3. echo "mknod /dev/ppp c 108 0" >> /etc/rc.local
  4. echo "echo 1 > /proc/sys/net/ipv4/ip_forward" >> /etc/rc.local
  5. echo "localip      " >> /etc/pptpd.conf
  6. echo "remoteip 153.121.37.2-254" >> /etc/pptpd.conf
  7. echo "ms-dns 8.8.8.8" >> /etc/ppp/options.pptpd
  8. echo "ms-dns 8.8.4.4" >> /etc/ppp/options.pptpd

    1.  /etc/ppp/chap-secrets

Then, create your users credentials for the PPTP server. This credentials will be used to log in to the PPTP server on every client/device you connect from:
  1. nano /etc/ppp/chap-secrets
Your chap-secrets file should look like this:
  1. # Secrets for authentication using CHAP
  2. # client server secret IP addresses
  3. yourusername pptpd yourpassword *
Save and close the file.
Next, you need to add the following iptables rules in order to open the correct ports and properly forward the data packets:
  1. # VPN rules (pptpd)
  2. iptables -A INPUT -i eth0 -p tcp --dport 1723 -j ACCEPT
  3. iptables -A INPUT -i eth0 -p gre -j ACCEPT
  4. iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
  5. iptables -A FORWARD -p tcp -153.121.37.0/24 -j TCPMSS --syn --set-mss 1356
  6. iptables -A INPUT -p gre -j ACCEPT
Save and restart your iptables firewall:
  1. service iptables save
  2. service iptables restart
Make sure you load your iptables after every reboot:
  1. chkconfig iptables on
  2. chkconfig pptpd on
And finally, restart iptables and pptpd services:
  1. 1service iptables start
  2.  2 service pptpd start

That is it.
service pptpd restart



备注:必须重启cent os

没有评论:

发表评论

标签

上周的网页浏览次数