pptpd

18. pptp Server Administration

This section covers a few tricks on pptp server management. It is far from a complete guide. Any suggestions are welcome.

The packages psacct and SysVinit are required for the utilities used in here. They should be installed by default. If they are not, please install them through yum.

[[email protected] ~]# yum install psacct SysVinit 


18.1 Who is Online?

To check who is online, the "last" command is used:

[[email protected] ~]# last | grep ppp | grep still
James    ppp3         202.xx.xxx.xxx   Sat Nov 19 17:38   still logged in   Andrew   ppp1         220.xxx.xxx.xx   Sat Nov 19 17:23   still logged in   Mary     ppp2         1.2.3.4          Sat Nov 19 16:59   still logged in   Sue      ppp0         202.xx.xxx.xxx   Sat Nov 19 16:43   still logged in   Mark     ppp7         203.xxx.xxx.xxx  Sat Nov 19 14:59   still logged in

last is from SysVinit. It reads the information from /var/log/wtmp.

Note: for last to work properly, the logwtmp option in the /etc/pptpd.conf must be enabled. If you are sure there are pptp connections but see no output from the above mentioned command, check the logwtmp option in the pptpd.conf file is enabled.



18.2 Accounting

The "ac" utility from package psacct will provide a report on the connection time.

[[email protected] ~]# ac -d -p
        Amy                                  3.77
        George                               0.08
        Mark                                 1.78
        Richard                              0.35
        Lee                                  3.66
        Simon                                5.78
        Nicole                               1.05
Nov  1  total       16.46
        Amy                                  2.43
        Nicole                               8.61
        Richard                              4.77
        Mark                                 0.90
        Lee                                  4.68
        Keith                                1.84
Nov  2  total       23.23

The ac command reads the information from /var/log/wtmp. It has a lot of options. Read the man page for details.

Note:
1.
If you want the statistics from older version of wtmp, use the -f parameter in "ac" to specify the file.
2. If users use shell to log in the server as well, the ac will return the connection time of both pptp and shell connections.



18.3 Disconnect a User

To disconnect an active connection, you will have to kill the pppd process associate with it. Firstly, run the command in section 16.1 to find out the remote ip address of the user. Say you want to disconnect Mary, her ip address in the above example is 1.2.3.4. Then, find the PID of the pppd process.

[[email protected] /]# ps -ef | grep 1.2.3.4 | grep pppd
root   8672  8671  0 16:59 ?      00:00:00 /usr/sbin/pppd local file /etc/ppp/options.pptpd 115200
                                               10.0.0.10:10.0.0.124 ipparam 1.2.3.4.
                                               plugin /usr/lib/pptpd/pptpd-logwtmp.so
                                               pptpd-original-ip 1.2.3.4

The second field of the output, 8672 in our example, is the PID of the pppd process. Kill the process will disconnect the user.

[[email protected] /]# kill 8672


18.4 Allow Only One Connection per User

By default, a user can make multiple connections to the pptpd server. To restrict one connection per user, create two script files in the /etc/ppp directory. When the same user logs in twice, the first connection will be disconnected. This is actually done on the ppp level, not with the pptpd.

The first file is /etc/ppp/auth-up

  #!/bin/sh
  # get the username/ppp line number from the parameters
  PPPLINE=$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`
    rm /var/run/pptpd-users/$USER
  fi
  # write down the username in the ppp line file
  echo $USER > /var/run/pptpd-users/$PPPLINE.new

The second file is /etc/ppp/ip-up.local

  #!/bin/sh
  REALDEVICE=$1
  # Get the username from the ppp line record file
  USER=`cat /var/run/pptpd-users/$REALDEVICE.new`
  # Copy the ppp line pid
  cp "/var/run/$REALDEVICE.pid" /var/run/pptpd-users/$USER
  # remove the ppp line record file
  rm "/var/run/pptpd-users/$REALDEVICE.new"

The method presented here may not be the best one, but it works for me. (If you have a better way, please let me know.)



Next   Previous  Content

时间: 2024-10-13 01:40:11

pptpd的相关文章

CentOS:[6]安装VPN服务器pptpd

一.检查服务器是否有必要的支持.如果检查结果没有这些支持的话,是不能安装pptp的,执行指令: #modprobe ppp-compress-18 && echo ok 这条执行执行后,显示"ok"则表明通过.不过接下来还需要做另一个检查,输入指令: #cat /dev/net/tun 如果这条指令显示结果为下面的文本,则表明通过: cat: /dev/net/tun: File descriptor in bad state 上述两条均通过,才能安装pptp.否则就只

ubuntu下使用pptpd搭建vpn

安装pptpd软件 sudo apt-get install pptpd 配置服务端 1)[/etc/pptpd.conf] localip 192.168.100.1 #服务端地址 remoteip 192.168.100.20-250 #客户端地址池 connections 500 #可使用的连接数量 2)[/etc/ppp/pptpd-options] ms-dns 8.8.8.8 #配置dns ms-dns 8.8.4.4 建立用于登陆的用户名等信息 配置文件[/etc/ppp/chap

在centos 6.6 使用pptpd上构建VPN服务

原理:PPTP 使用 PPP 协议对用户数据进行封装,然后将 PPP 数据帧封装在 IP 数据包里,pptpd 更多是负责客户端到服务器的连接,ppp协议负责用户数据包的封装和转发,当客户端连接到服务器时pptpd服务就是创建一个虚拟网卡ppp0进行用户数据包的封装,和转发到物理网卡,进入以太网 1:验证内核是否加载MPPE模块 modprobe ppp-compress-18 && echo MPPE is ok #打印ok表示已加载 2:安装ppp软件 yum install ppp

CentOS VPS创建pptpd VPN服务

原文地址http://www.hi-vps.com/wiki/doku.php?id=xen_vps_centos6_install_pptpd CentOS VPS创建pptpd VPN服务 Xen虚拟化技术虚拟的VPS可以直接安装所有VPN服务,而不用询问是否开通了ppp或者tun权限. 本教程仅仅适用于Xen或KVM VPS,不适用于Openvz VPS,安装之前请确定自己是否是符合标准! 1. 下载vpn(CentOS6专用)一键安装包 该教程仅适用于32位Centos6系列,Cento

CENTOS6 安装配置 pptpd 心得

1.你所需要的软件 pppd    ppp拨号服务器pptpd   在pppd拨号的基础上增加pptpd的支持 2.确定你的内核是否支持mppe modprobe ppp-compress-18 && echo ok 如果显示ok,那么恭喜,你的内核已经具备了mppe支持.请到第4部分 3.升级内核支持mppe wget http://poptop.sourceforge.net/yum/stable/packages/dkms-2.0.17.5-1.noarch.rpmwget http

一步解决PPTPD VPN CTRL: PTY read or GRE write failed (pty,gre)=(6,7)错误

现象: 客户端卡在验证用户名密码,无法连接. var/log/message档案日志: GRE: read(fd=6,buffer=8059680,len=8196) from PTY failed: status = -1 error = Input/output error, usually caused by unexpected termination of pppd, check option syntax and pppd logs CTRL: PTY read or GRE wri

pptpd vpn 老是连接不上内网排错

通过开发同事老是提出连接上vpn确ping不通内网,经过日志排查 Dec 17 10:27:33 webserver pppd[11221]: LCP terminated by peer (U^_^^M-I^@<M-Mt^@^@^@^@) Dec 17 10:27:33 webserver pppd[11221]: Connect time 0.4 minutes. Dec 17 10:27:33 webserver pppd[11221]: Sent 0 bytes, received 50

CentOS6.8系统下安装VPN(pptpd)服务器

星期六休息,没事又开始折腾那台vps了,上周在上面安装了shadowsocks和vsftpd,一直开着就没动过了,ss代理需要单独安装客户端,只能寻找另一种方案代替了. PPTP点对点隧道协议(PPTP)是一种实现虚拟专用网络的方法. PPTP使用用于封装PPP数据包的TCP及GRE隧道控制通道PPTP可以应用到几乎所有的操作系统,无需安装任何软件. 部署环境:硬件平台:vps,基于kvm虚拟化,512MB MemoryOS:CentOS 6.8网络:eth0  45.76.210.222 验证

linux pptpd账号同时登录的问题

最近搞了个云主机搭建个VPN服务器给自己用, 特别是在公共场所的wifi上网时, 很多APP, 或者网站是没有https的, 所以为了保证信息(主要是账号密码)的安全, 搭个私有vpn还是很有必要的. 在google上搜索 "linux pptpd配置" 可以找到很多相关的文章, 这里不说怎么搭建了. 这篇文章里主要是讲下同一个账号怎么防止多个用户同时登录使用(因为pptpd默认是可以同时登录的). 至于这个场景, 就是我有时候分配给别人一个vpn账号时不希望在多台电脑上同时使用. 找

Linux下pptpd的安装与配置

简述: PPTP:点对点隧道协议 (PPTP: Point to Point Tunneling Protocol) 通过该协议,远程用户能够通过 Microsoft Windows NT 工作站.Windows 95 和 Windows 98 操作系统以及其它装有点对点协议的系统安全访问公司网络,并能拨号连入本地 ISP,通过 Internet 安全链接到公司网络. 一.检查 MPPE     modprobe ppp-compress-18 && echo "ok!"