大网数据广告活动
服务器运维问答

OpenVPN force maximum session length

· 52CE 我爱测

Server: OpenVPN 2.3.8 on Ubuntu 14.04 How do I force a session to disconnect after a set time? I want VPN sessions to last no longer than 24 hours. Currently, clients appear to be able to stay connected indefinitely. I've looked …

问题原文

原帖链接 · JDS · CC BY-SA 3.0

Server: OpenVPN 2.3.8 on Ubuntu 14.04

How do I force a session to disconnect after a set time?

I want VPN sessions to last no longer than 24 hours. Currently, clients appear to be able to stay connected indefinitely.

I've looked at the --inactive param and that is pretty close to what I want, but I also want to force disconnect after 24 hours. i.e. VPN sessions should never last longer than 24 hours.

Edit OpenVPN Kill Script

I created a script to do this; it runs in an hourly cron job. I've posted it on Github here: https://github.com/poolpog/kill-openvpn-clients

已采纳解答

原帖链接 · Diamond · CC BY-SA 3.0

For Openvpn community edition, there is no such option available, and you can only achieve this by writing custom script that uses the OpenVPN Management Interface and kill command.

COMMAND -- kill

In server mode, kill a particlar client instance.

Command examples:

kill Test-Client -- kill the client instance having a common name of "Test-Client".
kill 1.2.3.4:4000 -- kill the client instance having a source address and port of 1.2.3.4:4000

Use the "status" command to see which clients are connected.

For Openvpn Access Server there is such a default option available:

live session expiration -- if a client stays connected, the token will expire after 1 day by default. This value can be modified using the vpn.server.session_expire key.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-01-13)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。