Re: Interface UP Scripting



On Tue, 2009-03-03 at 10:29 -0500, Dan Williams wrote:
> On Tue, 2009-03-03 at 06:58 +0200, Graham Beneke wrote:
> > Is there a way to attach a bash script to each connection 'under the 
> > hood' of NM? First requirement would be a post-up script but for 
> > completeness I would think we need pre-up, pre-down and post-down as well.
> 
> NetworkManager will execute scripts in /etc/NetworkManager/dispatcher.d
> in response to a few network events, which include post-up ("up") and
> post-down ("down").

So, with this as background, I'm trying to solve a thorny problem that
has come up because of NM 0.7's new policy of maintaining multiple
simultaneous connections, and I'm hoping someone here can help me figure
out the right way to solve them.

So, I can't figure out any way to determine which connection NM has
blessed as "preferred", or how to be notified when the "preferred"
connection changes.  I have a script on my laptop that set up different
routing/VPN/ssh access rules based on which network I'm connected to.
These used to be (in NM .6) very simple dhclient-exit-hook scripts,
which simply looked at what domain I was handed by the dhcp server, and
did the appropriate thing, assuming that there was only one NIC active
at a time.

I've been able to convert it into a dispatcher script, for the most
part, but the whole scheme falls apart whenever NM opens up simultaneous
connections on different networks.  Say, for example, that my wired
connection is a direct connection to the destination network, but my
wireless connection requires a VPN to get to the destination network.
How do I know when to set up the VPN, and when to take it down?  I'm
currently working around this by manually forcing NM to re-connect to my
"preferred" network whenever I have multiple connections, but that's a
terrible kludge.

-- 
Brett Johnson <brett hp com>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]