How to kill OpenVPN connection using Perl?

Is there a way to kill the OpenVPN user connection using the Linux or Perl command?

+3
source share
5 answers

To disconnect a connected user:

/usr/bin/openvpn-sudo-user kill \"username\"

but first you have to disconnect the user.

+2
source

to invoke the tcpkill program .

+1
source

tcpkill ip host 192.168.1.2

+1

openvpn perl Proc:: Background, Proc:: Background:

#!/usr/bin/perl

use strict;
use warnings;
use Proc::Background;

my $command = 'openvpn --config /etc/openvpn/client.conf';
my $proc = Proc::Background->new($command); $proc->alive;
print "started\n";
sleep (30);
if ($proc->alive == 1) { $proc->die; print "stopped\n";}
+1

OpenVPN , :

service openvpn stop

( perl)

/etc/init.d/openvpn stop

You can kill it directly, like another sentence, but using the provided method to stop the service, any cleaning of additives that OpenVPN requires (for example, cleaning lock files, launching pid files, etc.) will be performed.

Killing AFIAK OpenVPN will be fine in the current version, but who knows for a future version.

0
source

Source: https://habr.com/ru/post/1758944/


All Articles