localip 222.201.139.156 # 本地机器物理IP地址,可以通过ifconfig获取 remoteip 192.168.0.234-238,192.168.0.245 # 分配给远程连接过来的机器分配的IP地址空间 |
# Secrets for authentication using CHAP # client server secret IP addresses #username pptpd password * ethanshan pptpd 111111 * |
ms-dns 222.201.130.30 ms-dns 222.201.130.33 |
# Kernel sysctl configuration file # # For binary values, 0 is disabled, 1 is enabled. See sysctl(8) and # sysctl.conf(5) for more details. # Controls IP packet forwarding # Default this conf is 0, I use pptpd, so edit it to 1 net.ipv4.ip_forward = 1 # Controls source route verification net.ipv4.conf.default.rp_filter = 1 # 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 # Controls whether core dumps will append the PID to the core filename. # Useful for debugging multi-threaded applications. kernel.core_uses_pid = 1 # Disable netfilter on bridges. net.bridge.bridge-nf-call-ip6tables = 0 net.bridge.bridge-nf-call-iptables = 0 net.bridge.bridge-nf-call-arptables = 0 |
sysctl -p |
ifconfig $1 mtu 1400 |
iptables -A INPUT -i eth0 -p tcp --dport 1723 -j ACCEPT iptables -A INPUT -i eth0 -p gre -j ACCEPT iptables -A FORWARD -i ppp+ -o p3p1 -j ACCEPT iptables -A FORWARD -i eth0 -o ppp+ -j ACCEPT iptables -A OUTPUT -p tcp --dport 1723 -j ACCEPT iptables -A OUTPUT -p gre -j ACCEPT iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE |
pptpd -f |


linux系统上提供的pptp vpn服务默认采用的是chap认证方式。这种认证方式比较简单,只要用户名和密码正确即可进行连接,不能对一个账户的连接数目,流量,速度进行限制。如 果要实现这众多的限制,可以采用freeradius认证方式。但是我个人感觉配置freeradius可不是一般的繁琐啊,花了某个晚上的几个小时后我 最终放弃了… 不过如果仅仅只是对同一个账户的连接数目进行限制,倒是有一个简单的办法。这里提供的方法改自某个英文网站。当用中文搜索不到自己想要的东西时,用英文搜下说不定能有新发现呢。 实现方法很简单。只要在/etc/ppp文件夹下面建立一个名为auth-up的文件。在里面写入如下内容即可: Click to closeBASH CODE#!/bin/sh # get the username/ppp line number from the parameters REALDEVICE=$1 USER=$2 # create the directory to keep pid files per user mkdir -p /var/run/pptpd-users # if there is a session already for this user, terminate the old one if [ -f /var/run/pptpd-users/$USER ]; then kill -HUP `cat /var/run/pptpd-users/$USER` fi # copy the pid file of current user to /var/run/pptpd-users cp "/var/run/$REALDEVICE.pid" /var/run/pptpd-users/$USER 这样只要一个帐号进行了连接,就在/var/run/pptpd-users目录下记录下来了。而一旦这个帐号在他处再次登录,旧有的连接就被杀掉了。所以后面的连接具有优先权。 |
精彩评论