If you want a script to be executed each time a Network connection is established there is a easy way to do so with Linux distributions which use the Network Manager (like Fedora, Suse, Ubuntu etc.). You simply have to copy the script to the directory /etc/NetworkManager/dispatcher.d and change the permissions to 755. (It is crucial to use 755, otherwise the script will be ignored.
chmod 755 /etc/NetworkManager/dispatcher.d/10-my-scirpt
The scipts in this directory are executed by the order of their name eg. 10-my-script will be executed before 20-my-script.