View previous topic :: View next topic |
Author |
Message |
herdentier n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 28 Nov 2006 Posts: 9
|
Posted: Tue Nov 13, 2007 11:14 am Post subject: [SOLVED] Get NetworkManager autostart a vpnc-Connection?! |
|
|
Hello there.
The Problem:
I am workling in different networks with my notebook.
At my university, i have to connect via a vpn-tunnel to get internet-access.
So i want NetworkManager to launch it's configured vpnc-connection after a successful connect with the network.
NetworkManager is working, so is the configured VPNC-Connection (via the vpnc-plugin) when manually clicking on it.
I use the NetworkManagerDispatcher (see wiki) to get a script launched when my notebook connects successfully to a wireless network.
This script checks if the essid matches the one used at my university.
all this works for now.
the only thing not (yet) working is to tell NetworkManager from within that script to start a specified vpn-connection.
the filter-script (/etc/NetworkManager/dispatcher.d/00-hsma_vpn):
Code: |
#!/bin/bash
interface="eth1"
uni_essid="CISCO_AIR"
if test "$2" == "up" -a "$1" == "${interface}" ; then
essid=`iwconfig eth1 | grep ESSID | cut -d '"' -f 2`
if test "${essid}" == "${uni_essid}" ; then
echo "Connected to CISCO_AIR on eth1. should start vpnc now" >> /test_nm
fi
fi
|
So how do i get NetworkManager to start the vpn-connection at the point where i currently echo to /test_nm?
Last edited by herdentier on Thu Nov 15, 2007 11:08 pm; edited 1 time in total |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
herdentier n00b
![n00b n00b](/images/ranks/rank_rect_0.gif)
Joined: 28 Nov 2006 Posts: 9
|
Posted: Thu Nov 15, 2007 11:07 pm Post subject: |
|
|
Found a working solution.
Sadly, the script can't work with the (in gnome-keyring) stored vpn-passwords, so they must be forwarded to NetworkManager from within the script.
<<Connection Name>> is the exact name of your configured VPN-Connection (in NetworkManager)
<<grp secret>> is the VPN Group Password
<<user password>> is the users password
Messy coding style, but works...
Some executable file in /etc/NetworkManager/dispatcher.d/:
Code: |
#!/bin/sh
log_file=/var/log/nm_dispatcher_hsma
wireless_iface="eth1"
datetime=`date +"%F, %T"`
case "$1" in
"${wireless_iface}")
case "$2" in
up)
essid_now="`iwconfig $IFACE 2>&1 | grep ESSID | sed -e's/.*ESSID:"\(.*\)"/\1/' -e's/ //g'`"
echo "${datetime}: Wireless Interface ${wireless_iface} connected to ESSID '${essid_now}'." >> ${log_file}
case "${essid_now}" in
"CISCO_AIR")
echo "${datetime}: Starting VPN-Connection '<<Connection Name>>'" >> ${log_file}
dbus-send --system --dest=org.freedesktop.NetworkManager /org/freedesktop/NetworkManager/VPNConnections org.freedesktop.NetworkManager.VPNConnections.activateVPNConnection string:"<<Connection Name>>" array:string:"<<grp secret>>","<<user password>>"
;;
esac
;;
down)
echo "${datetime}: Wireless Interface ${wireless_iface} lost connection." >> ${log_file}
echo "${datetime}: Terminating old VPN-Connections." >> ${log_file}
dbus-send --print-reply --system --dest=org.freedesktop.NetworkManager.vpnc /org/freedesktop/NetworkManager/vpnc org.freedesktop.NetworkManager.vpnc.stopConnection
vpnc-disconnect
;;
esac
;;
esac
exit 0
|
Greetings |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|