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.

[root@pptp ~]# yum install psacct SysVinit 

18.1 Who is Online?

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

[root@pptp ~]# 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.

[root@pptp ~]# 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.

[root@pptp /]# 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.

[root@pptp /]# 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

pptpd的更多相关文章

  1. CentOS 6.5 PPTPD VPN服务器安装,解决807等问题。

    需要两个组件: ppp pptpd 需要配置的地方有三处: /etc/pptpd.conf /etc/ppp/options.pptpd /etc/ppp/chap-secrets 需要开启IP转发: ...

  2. CentOS 一键搭建pptpd

    rpm -Uvh http://poptop.sourceforge.net/yum/stable/rhel6/pptp-release-current.noarch.rpm yum -y insta ...

  3. Linux_VPN—pptpd构架方法

    以下是由本人测试可用的pptpd构架方法 按步骤: 运行环境Centeros 6 *首先运行如下命令: cat /dev/net/tun 返回的必须是: cat: /dev/net/tun: File ...

  4. linux pptpd账号同时登录的问题

    最近搞了个云主机搭建个VPN服务器给自己用, 特别是在公共场所的wifi上网时, 很多APP, 或者网站是没有https的, 所以为了保证信息(主要是账号密码)的安全, 搭个私有vpn还是很有必要的. ...

  5. ArchLinux 下架设PPTPD VPN服务

    直接上命令吧: 安装: pacman -Sy pacman -S pptpd 配置: vim /etc/pptpd.conf option /etc/ppp/options.pptpd stimeou ...

  6. [Ubuntu] Ubuntu搭建VPN服务器pptpd

    在 Ubuntu 上搭建 VPN 服务器的方法非常多,比较著名的有 PPTP, L2TP/IPSec 和 OpenVPN. 这三种方式中后两者的安全性比较好,但配置较麻烦.其中 OpenVPN 在 W ...

  7. CENTOS6 安装配置 pptpd 心得

    1.你所需要的软件 pppd    ppp拨号服务器pptpd   在pppd拨号的基础上增加pptpd的支持 2.确定你的内核是否支持mppe modprobe ppp-compress-18 &a ...

  8. Linux ---pptpd部署

    PPTP 全称为 Point to Point Tunneling Protocol -- 点到点隧道协议,是VPN协议中的一种. 一.CentOS 6.2 下 PPTP VPN 服务器安装 1.安装 ...

  9. ubuntun pptpd

    apt-get install pptpd 3.编辑pptpd.conf文件 vi /etc/pptpd.conf 取消注释下面内容 option /etc/ppp/pptpd-options loc ...

随机推荐

  1. openfire安装

    服务器第一次能够开启,但不久就断开,再连接就会闪退,命令行更改Java路径后即可 http://www.jianshu.com/p/5d88fe201c71 开启服务器后,导入数据库脚本,创建几个测试 ...

  2. J2ObjC 1.0 发布,将 Java 转换为 Objective-C

    J2ObjC 是一个Google开发的开源工具,用于将Java代码转换为Objective-C代码.其目的是为了能在iOS平台上重用Android平台.web服务器端的Java代码.服务器端代码的转换 ...

  3. Objective-C Mojo和Django 对接

    最近在做资料类app需要一个好的资源管理工具,excel在这方面非常好,不过能第一非常low,第二数据量一大查询就是个问题. 因此,我使用django做了个资源管理小工具.好处还是很明显的 (1)可以 ...

  4. 从零自学Hadoop(01):认识Hadoop

    本文版权归mephisto和博客园共有,欢迎转载,但须保留此段声明,并给出原文链接,谢谢合作. 文章是哥(mephisto)写的,SourceLink 阅读目录 序 Hadoop 项目起源 优点 核心 ...

  5. Python正则表达式:最短匹配

    最短匹配应用于:假如有一段文本,你只想匹配最短的可能,而不是最长. 例子 比如有一段html片段,'\this is first label\\the second label\',如何匹配出每个a标 ...

  6. Asp.Net MVC+BootStrap+EF6.0实现简单的用户角色权限管理9

    前两天因有事就没来得及写.今天刚刚好空了.这次写的是对角色和管理员对页面按钮之间的控制.先看页面效果 说明:先根据角色设置好角色的权限,然后管理员在对应的角色下的权限去设置其权限. 在设置角色权限的时 ...

  7. jQuery 3.0的buildFragment

    在 jQuery3.0中,buildFragment 是一个私有函数,用来构建一个包含子节点 fragment 对象.这个 fragment 在 DOM1 中就已经有了,所有浏览器都支持.当频繁操作( ...

  8. Java 容器(list, set, map)

    java容器类库的简化图: (虚线框表示接口, 实线框表示普通的类, 空心箭头表示特定的类实现了接口, 实心箭头表示某个类可以生成箭头所指的类对象) 继承Collection的主要有Set 和 Lis ...

  9. MalformedByteSequenceException: Invalid byte 1 of 1-byte

    修改了线上程序的xml配置文件,重启后报如下错误: MalformedByteSequenceException: Invalid byte 1 of 1-byte 百度了下大体的意思是说文件的编码错 ...

  10. openstack学习(三)创建虚拟机

    1 , 用图形管理界面创建虚拟机 #virt-manager    //打开图形管理界面 配置文件一般存放于/etc/libvirt/qemu 然后按照提示一步步安装即可,网络连接方式改为桥接 导出创 ...