You are not logged in.

#1 2017-01-14 12:06:16

stuff
Member
Registered: 2017-01-09
Posts: 14

VPN Killswitch [SOLVED]

Hey,

After setting up my VPN I wanted to install a killswitch, so i downloaded VPNDemon. It kills a process if the VPN is disconnected.
I would love to try it, but what process should i kill to kill the internet. I have no network manager, i set it up manually with a script.
Or maybe anyone has a better alternative.

Last edited by stuff (2017-01-14 19:35:47)

Offline

#2 2017-01-14 13:01:55

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: VPN Killswitch [SOLVED]

If you set it up manually with a script then you must know how to disconnect it, no?


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#3 2017-01-14 13:54:54

stuff
Member
Registered: 2017-01-09
Posts: 14

Re: VPN Killswitch [SOLVED]

I know how to disconnect it via the terminal, but not via process killiing.

Offline

#4 2017-01-14 15:44:51

brebs
Member
Registered: 2007-04-03
Posts: 3,742

Re: VPN Killswitch [SOLVED]

"Kill the Internet"? - these are bizarre requirements, it sounds like there's a much better solution, but first you'll need to describe the problem in more detail.

Offline

#5 2017-01-14 16:03:44

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 29,523
Website

Re: VPN Killswitch [SOLVED]

If you know how to disconnect via the terminal, what are you asking?  How would you disconnect via the terminal?  How do you connect in this script that you wrote that none of us yet know anything about?  How do you expect anyone to help you if you wont tell us anything about how/what you are running?

The only direct answer we could give you so far is systemd or pid 1.  Kill that, and your network connection will go down.  I doubt that's the answer you want, but if you want a better answer, ask a better question.


"UNIX is simple and coherent..." - Dennis Ritchie, "GNU's Not UNIX" -  Richard Stallman

Offline

#6 2017-01-14 17:24:34

x33a
Forum Fellow
Registered: 2009-08-15
Posts: 4,587

Re: VPN Killswitch [SOLVED]

Well, the easiest way would be to set the internet interface down, but as others have already mentioned, post your setup in detail.

Offline

#7 2017-01-14 17:40:40

Xyne
Administrator/PM
Registered: 2008-08-03
Posts: 6,963
Website

Re: VPN Killswitch [SOLVED]

stuff wrote:

I know how to disconnect it via the terminal, but not via process killiing.

Ok, your first post was unclear but I think I understand what you want to do now. You want to use the daemon to completely disconnect your computer if the VPN goes down, presumably to prevent leaking connections over the normal non-VPN process. Is that it? If so, tell us how you configure your connection. If you are using dhcpcd, then killing that process should cause you to lose your connection.

If all else fails, you could write a simple custom daemon that does nothing except wait for the kill signal and then disconnect your computer (or run a custom script).


edit
Here's a simple script to use as a starting point (it depends on Python (3)).

#!/usr/bin/env python3

import os
import signal
import subprocess
import sys

SIGNALS = (signal.SIGINT,)

print('PID: {}'.format(os.getpid()))
sig = signal.sigwait(SIGNALS)
cmd = sys.argv[1:]
if cmd:
  subprocess.run(cmd)

Save it as something like "run_on_exit" then invoke it with the command that you want to execute.

$ run_on_exit echo "Goodbye cruel world!"
PID: 3431

It will print its PID then wait for a SIGINT signal. You can test the signal from another terminal:

kill -n sigint 3431

Which results in

$ run_on_exit echo "Goodbye cruel world!"
PID: 3431
Goodbye cruel world!

Instead of the echo command, pass it the path to a script that will disconnect the internet.

Last edited by Xyne (2017-01-14 17:59:31)


My Arch Linux StuffForum EtiquetteCommunity Ethos - Arch is not for everyone

Offline

#8 2017-01-14 19:34:22

stuff
Member
Registered: 2017-01-09
Posts: 14

Re: VPN Killswitch [SOLVED]

Thank you xyne. Thats exactly what i meant and what i needed. Im sorry, that i was unclear, but from here on i can do it myself.

Offline

Board footer

Powered by FluxBB