Re: Run a script when a connection is created?



On Fri, 2011-01-07 at 20:10 +1300, Simon Geard wrote:
> On Thu, 2011-01-06 at 11:03 -0500, Paul Smith wrote:
> > Ah that's good info, thanks.  I was hoping that I'd get more details on
> > the connection in addition to the device name, such as the DNS details
> > (search domain(s) and server(s)).  Nothing like that available I
> > suppose?
> 
> Read the NetworkManager man page for details on what's available...

Ah, thanks for that.  That's exactly what I was looking/hoping for.

Unfortunately, after testing it doesn't seem to work :-/.  I created a
script 22showenv containing just:

#!/bin/sh
exec > "/tmp/nm-$1-$2.log"
echo "Args: $*"
echo "Env:"
env | sort
exit 0

and added it to /etc/NetworkManager/dispatcher.d.  I connect via wire to
my local lan on eth0 which uses the 172.31.1.0/24 subnet with a domain
of "localnet", using DHCP to obtain info.

Next I brought up my VPN with Network Manager's openconnect support, I
got a file "/tmp/nm-tun0-vpn-up.log" with $1 set to tun0 and $2 set to
"vpn-up", and all the environment variables listed in the man page
existed there, BUT they all contained the settings for my local eth0
network, not the settings for my VPN network.

For example, I see in that nm-tun0-vpn-up.log file:

IP4_ADDRESS_0=172.31.1.105/24 172.31.1.1
IP4_DOMAINS=localnet
IP4_NAMESERVERS=172.31.1.1
IP4_NUM_ADDRESSES=1
IP4_NUM_ROUTES=0

which is the correct information for my eth0 connection, but totally
wrong for my tun0 connect, which obviously uses a completely different
subnet, uses different nameservers, adds 15 routes to my routing table,
etc.

To be clear, that was the only /tmp/nm-* file existing.

I will file a bug on this.



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