Re: Interface UP Scripting



On Tue, 2009-03-03 at 06:58 +0200, Graham Beneke wrote:
> I have various scripts that I need to trigger when my interfaces come 
> up. These are for things like setting IPv6 tunnels, Dynamic DNS updates, 
> etc.
> 
> The scripts change depending on which connection I am using depending on 
> native IPv6 connectivity and NATing.
> 
> 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").  The manpage of 0.7.1rc1 or rc2 is the best place to
get information about that (it's in git as well if you don't mind the
formatting).  NM will pass the connection's UUID in the scripts
environment and thus you can tie a script to a specific connection.

NetworkManager doesn't provide pre-up and pre-down events at this time,
for a number of reasons.  First, the connection can drop at any time,
thus pre-down isn't extremely useful as you'd *always* need a post-down
anyway.  In most cases, pre-down wouldn't even get run because the
connection was already down and your IP addresses and routes would be
flushed.

The other problem with pre-up and pre-down is timing; the experience is
a lot better when there's lower connection latency, and running
arbitrary scripts before connecting and before disconnecting increases
latency.  NM would have to bound total script runtime in any case to
some acceptable value, say 3 seconds, thus any scripts after that time
wouldn't get run, and any script running when the timer fired would get
killed.  Not nice to the scripts, but you simply cannot have potentially
unbounded script runtime when connecting or disconnect to a network.

Dan





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