Fedora Linux Support Community & Resources Center

Go Back   FedoraForum.org > Fedora 17/18 > Servers & Networking
FedoraForum Search

Forgot Password? Join Us!

Servers & Networking Discuss any Fedora server problems and Networking issues such as dhcp, IP numbers, wlan, modems, etc.

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 22nd August 2009, 10:55 PM
trueblue Offline
Registered User
 
Join Date: Nov 2004
Location: France
Age: 26
Posts: 81
linuxfedorafirefox
Configure NetworkManager to drop connections when VPN fails

Hi all,

I am using a VPN proxy service for privacy reasons. I have configured NetworkManager and it's PTPP VPN plug-in successfully.

I would like to configure NetworkManager to drop connections when the VPN fails so that I do not suffer 'privacy leaks' when it happens.

Any ideas on how to do this ?
Reply With Quote
  #2  
Old 24th August 2009, 02:55 AM
trueblue Offline
Registered User
 
Join Date: Nov 2004
Location: France
Age: 26
Posts: 81
linuxfedorafirefox
Well, I guess there are no configuration options so I think I will catch dbus notifications that signal the VPN failure and then kill my torrent client so that my traffic doesnt get shaped by my ISP.

Here is a (rudimentary but working) piece of python code that does that:
Code:
#!/usr/bin/env python

#
# licensed under GNU General Public License version 2
#

import sys
import traceback

import gobject

import dbus
import dbus.decorators
import dbus.mainloop.glib

import os

def catchall_signal_handler(*args, **kwargs):
    print ("Caught signal (in catchall handler) "
           + kwargs['member'])
    if args[0] >= 6: #vpn disconnect (6) or failure (7)
        print ("killing bittorrent client")
        os.system('killall -9 transmission')

if __name__ == '__main__':
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

    bus = dbus.SystemBus()

    #lets make a catchall
    bus.add_signal_receiver(catchall_signal_handler, signal_name='VpnStateChanged', interface_keyword='dbus_interface', member_keyword='member')

    loop = gobject.MainLoop()
    loop.run()
A possible improvement would be to send a dbus signal to close existing internet connections instead of killing only specific apps. I'll do that later when I have some free time
Reply With Quote
  #3  
Old 3rd June 2012, 12:40 PM
Seeked Offline
Registered User
 
Join Date: Jun 2012
Location: Sweden
Posts: 1
linuxfirefox
Re: Configure NetworkManager to drop connections when VPN fails

I have made some modifications so this will drop the internet connection by disabling the network adapter. This is being used on Debian.

Enjoy!

Code:
#!/usr/bin/env python

#
# licensed under GNU General Public License version 2
#

import sys
import traceback

import gobject

import dbus
import dbus.decorators
import dbus.mainloop.glib

import os

def catchall_signal_handler(*args, **kwargs):
    print ("Caught signal: "
           + kwargs['member'])
    if args[0] >= 6: #vpn disconnect (6) or failure (7)
        print ("Killing internet connection...")
	#set eth0 to your network adapter
        os.system('ifconfig eth0 down')
	#if you are using python 3 no raw_input() exists so use input()
	raw_input("Press Enter to enable your network adapter...")
	#set eth0 to your network adapter
	os.system('ifconfig eth0 up')
	print ("Your network adapter has been enabled.")	

if __name__ == '__main__':
    dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
    print ("Monitoring your VPN connection...")
    bus = dbus.SystemBus()

    #lets make a catchall
    bus.add_signal_receiver(catchall_signal_handler, signal_name='VpnStateChanged', interface_keyword='dbus_interface', member_keyword='member')
	
    loop = gobject.MainLoop()
    loop.run()
Reply With Quote
  #4  
Old 19th October 2012, 05:15 PM
jonjadot Offline
Registered User
 
Join Date: Oct 2012
Location: earth
Posts: 1
linuxfirefox
Re: Configure NetworkManager to drop connections when VPN fails

Very helpful, being the paranoid freak I am about privacy, I've taken the 2 ideas and put them together. Have it kill all net enabled programs as well as the network interface. Thanks Guys!
Reply With Quote
Reply

Tags
configure, connections, drop, fails, networkmanager, vpn

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to force connections to appear in NetworkManager PompeyBlue Hardware & Laptops 4 16th July 2009 06:01 AM
NetworkManager + WEP + static IP--no worky? (how to get 'Edit Connections' working?) fwelland Servers & Networking 5 14th July 2008 09:29 PM
Configure multiple network connections on single wifi interface clivelong Servers & Networking 2 14th July 2006 03:58 PM
Configure NetworkManager chmac Servers & Networking 5 3rd July 2006 12:15 PM


Current GMT-time: 06:01 (Wednesday, 19-06-2013)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat