首页 > 代码库 > PPTPD安装笔记

PPTPD安装笔记

一、PPTPD安装完后服务无法开启但是端口状态是监听状态如下:

root@li738-82:~# netstat -nptl查询端口状态时1723是被PPTPD使用中的
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      2390/sshd       
tcp        0      0 0.0.0.0:1723            0.0.0.0:*               LISTEN      6151/pptpd      
tcp6       0      0 :::22                   :::*                    LISTEN      2390/sshd     

root@li738-82:~# service pptpd status查询服务状态时提示

  * /usr/sbin/pptpd is not running 


二、卸载已安装的PPTPD,应为我是管理员账号所以就不用sudo了

apt-get  remove pptpd

三、更新源

1、为了以防万一先备份系统自带的源

cp /etc/apt/sources.list etc-backup/etc-apt-source.list

2、编辑vim /etc/apt/sources.list添加下列某个源地址然后apt-get update

#台湾源

  1. deb http://tw.archive.ubuntu.com/ubuntu/ precise main universe restricted multiverse

  2. deb-src http://tw.archive.ubuntu.com/ubuntu/ precise main universe restricted multiverse

  3. deb http://tw.archive.ubuntu.com/ubuntu/ precise-security universe main multiverse restricted

  4. deb-src http://tw.archive.ubuntu.com/ubuntu/ precise-security universe main multiverse restricted

  5. deb http://tw.archive.ubuntu.com/ubuntu/ precise-updates universe main multiverse restricted

  6. deb-src http://tw.archive.ubuntu.com/ubuntu/ precise-updates universe main multiverse restricted



#网易 Ubuntu 源(速度很快)


  1. deb http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse

  2. deb-src http://mirrors.163.com/ubuntu/ precise main universe restricted multiverse

  3. deb http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted

  4. deb-src http://mirrors.163.com/ubuntu/ precise-security universe main multiverse restricted

  5. deb http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted

  6. deb http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted

  7. deb-src http://mirrors.163.com/ubuntu/ precise-proposed universe main multiverse restricted

  8. deb http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted

  9. deb-src http://mirrors.163.com/ubuntu/ precise-backports universe main multiverse restricted

  10. deb-src http://mirrors.163.com/ubuntu/ precise-updates universe main multiverse restricted


#骨头源,骨头源是bones7456架设的一个Ubuntu源 ,提供ubuntu,deepin

  1. deb http://ubuntu.srt.cn/ubuntu/ precise main universe restricted multiverse

  2. deb-src http://ubuntu.srt.cn/ubuntu/ precise main universe restricted multiverse

  3. deb http://ubuntu.srt.cn/ubuntu/ precise-security universe main multiverse restricted

  4. deb-src http://ubuntu.srt.cn/ubuntu/ precise-security universe main multiverse restricted

  5. deb http://ubuntu.srt.cn/ubuntu/ precise-updates universe main multiverse restricted

  6. deb http://ubuntu.srt.cn/ubuntu/ precise-proposed universe main multiverse restricted

  7. deb-src http://ubuntu.srt.cn/ubuntu/ precise-proposed universe main multiverse restricted

  8. deb http://ubuntu.srt.cn/ubuntu/ precise-backports universe main multiverse restricted

  9. deb-src http://ubuntu.srt.cn/ubuntu/ precise-backports universe main multiverse restricted

  10. deb-src http://ubuntu.srt.cn/ubuntu/ precise-updates universe main multiverse restricted


#mirror.lupaworld.com的源,速度很快

  1. deb http://mirror.lupaworld.com/ubuntu/archive/ precise main restricted universe multiverse

  2. deb http://mirror.lupaworld.com/ubuntu/archive/ precise-security main restricted universe multiverse

  3. deb http://mirror.lupaworld.com/ubuntu/archive/ precise-updates main restricted universe multiverse

  4. deb http://mirror.lupaworld.com/ubuntu/archive/ precise-backports main restricted universe multiverse

  5. deb http://mirror.lupaworld.com/ubuntu/ubuntu-cn/ precise main restricted universe multiverse



#ubuntu.cn99.com源(推荐):


  1. deb http://ubuntu.cn99.com/ubuntu/ precise main restricted universe multiverse

  2. deb http://ubuntu.cn99.com/ubuntu/ precise-updates main restricted universe multiverse

  3. deb http://ubuntu.cn99.com/ubuntu/ precise-security main restricted universe multiverse

  4. deb http://ubuntu.cn99.com/ubuntu/ precise-backports main restricted universe multiverse

  5. deb http://ubuntu.cn99.com/ubuntu-cn/ precise main restricted universe multiverse



#电子科技大学


  1. deb http://ubuntu.uestc.edu.cn/ubuntu/ precise main restricted universe multiverse

  2. deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse

  3. deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse

  4. deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-security main restricted universe multiverse

  5. deb http://ubuntu.uestc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse

  6. deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise main restricted universe multiverse

  7. deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse

  8. deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse

  9. deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-security main restricted universe multiverse

  10. deb-src http://ubuntu.uestc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse


#中国科技大学

  1. deb http://debian.ustc.edu.cn/ubuntu/ precise main restricted universe multiverse

  2. deb http://debian.ustc.edu.cn/ubuntu/ precise-backports restricted universe multiverse

  3. deb http://debian.ustc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse

  4. deb http://debian.ustc.edu.cn/ubuntu/ precise-security main restricted universe multiverse

  5. deb http://debian.ustc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse

  6. deb-src http://debian.ustc.edu.cn/ubuntu/ precise main restricted universe multiverse

  7. deb-src http://debian.ustc.edu.cn/ubuntu/ precise-backports main restricted universe multiverse

  8. deb-src http://debian.ustc.edu.cn/ubuntu/ precise-proposed main restricted universe multiverse

  9. deb-src http://debian.ustc.edu.cn/ubuntu/ precise-security main restricted universe multiverse

  10. deb-src http://debian.ustc.edu.cn/ubuntu/ precise-updates main restricted universe multiverse


#北京理工大学

  1. deb http://mirror.bjtu.edu.cn/ubuntu/ precise main multiverse restricted universe

  2. deb http://mirror.bjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe

  3. deb http://mirror.bjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe

  4. deb http://mirror.bjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe

  5. deb http://mirror.bjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe

  6. deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise main multiverse restricted universe

  7. deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe

  8. deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe

  9. deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe

  10. deb-src http://mirror.bjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe


#兰州大学

  1. deb ftp://mirror.lzu.edu.cn/ubuntu/ precise main multiverse restricted universe

  2. deb ftp://mirror.lzu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe

  3. deb ftp://mirror.lzu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe

  4. deb ftp://mirror.lzu.edu.cn/ubuntu/ precise-security main multiverse restricted universe

  5. deb ftp://mirror.lzu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe

  6. deb ftp://mirror.lzu.edu.cn/ubuntu-cn/ precise main multiverse restricted universe


#上海交通大学

  1. deb http://ftp.sjtu.edu.cn/ubuntu/ precise main multiverse restricted universe

  2. deb http://ftp.sjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe

  3. deb http://ftp.sjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe

  4. deb http://ftp.sjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe

  5. deb http://ftp.sjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe

  6. deb http://ftp.sjtu.edu.cn/ubuntu-cn/ precise main multiverse restricted universe

  7. deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise main multiverse restricted universe

  8. deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise-backports main multiverse restricted universe

  9. deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise-proposed main multiverse restricted universe

  10. deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise-security main multiverse restricted universe

  11. deb-src http://ftp.sjtu.edu.cn/ubuntu/ precise-updates main multiverse restricted universe 

四、下载安装pptpd 

1、apt-get install  pptpd 然后编辑 vim  /etc/pptpd.conf

去掉文件最末端的 localip 和 remoteip 两个参数的注释,并进行相应修改。这里,localip 是 VPN 连通后服务器的 ip 地址,而 remoteip 则是客户端的可分配 ip 地址,地址可以自由配置我选择的是默认地址。

2、编辑vim /etc/ppp/pptpd-options修改DNS服务器地址,找到ms-dns选项我修改为谷歌DNS服务器地址

ms-dns 8.8.8.8

ms-dns 8.8.4.4

3、编辑vim  /etc/ppp/chap-secrets  内容如下:

# Secrets for authentication using CHAP

# client             server                      secret                  IP addresses

用户名     服务类型(*代表自由识别)              密码                    IP地址可用*代替不做限制

4、全部搞定后,我们需要重启 pptpd 服务使新配置生效:

/etc/init.d/pptpd restart

找一台 Windows 电脑,新建个 VPN 链接,地址填服务器的 IP(或域名),用户名密码填刚才设置好的,域那项空着(如果你在 pptpd-options 中设置了,这里就保持一致),点连接就可以了。正常情况下您应该能够建立与服务器的 VPN 链接了。

建立连接之后,您会发现除了可以访问服务器的资源,其余内外和互联网的内容均无法访问。如果需要访问这些内容的话,我们还需要进一步设置:

首先,开启 ipv4 forward。方法是,修改 /etc/sysctl.conf,找到类似下面的行并取消它们的注释:

net.ipv4.ip_forward=1

然后使新配置生效:

sysctl -p

有些时候,经过这样设置,客户端机器就可以上网了(我在虚拟机上这样操作后就可以了)。但我在实验室的服务器上这样操作后仍然无法访问网络,这样我们就需要建立一个 NAT。这里我们使用强大的 iptables 来建立 NAT。首先,先安装 iptables:

apt-get intall iptables

装好后,我们向 nat 表中加入一条规则:

iptables -t nat -A POSTROUTING -s 192.168.0.1/24 -o eth0 -j MASQUERADE

这样操作后,客户端机器应该就可以上网了。

但是,只是这样,iptables 的规则会在下次重启时被清除,所以我们还需要把它保存下来,方法是使用 iptables-save 命令:

sudo iptables-save > /etc/iptables-rules

然后修改 /etc/network/interfaces 文件,找到 eth0 那一节,在对 eth0 的设置最末尾加上下面这句:

pre-up iptables-restore < /etc/iptables-rules

这样当网卡 eth0 被加载的时候就会自动载入我们预先用 iptables-save 保存下的配置。


本文出自 “睡到打饱嗝” 博客,请务必保留此出处http://huajian0816.blog.51cto.com/8834145/1588936

PPTPD安装笔记