How to run code when changing network connection in Mac OS X?

I need to run a script on my Mac when changing the network connection, i.e. when connecting or disconnecting a network cable / Wi-Fi. I do not want to use cronjob, and I would prefer to avoid modifying system files. Is there some kind of β€œnetwork shift” in mac os x that I could connect to?

thanks bob

+4
source share
2 answers

Try MarcoPolo , although if you are using Snow Leopard you will probably need to look at the bottom of this page for a link to the revised version.

+1
source

While not directly, what are you asking for, maybe columbus might be part of the solution? It uses ARP traffic to help deal with a machine that, for example, travels at school / home / work, etc. And it must have the appropriate settings for /etc/resolv.conf or firewall, etc.

From the README file:

columbus: automatic network detector and configurator

columbus is useful when you use your machines on different networks. This is great for laptop users.

columbus uses ARP pins to look up known MAC IP addresses. He can do this even when the missing IP address has been assigned yet, which is a good idea when you are on a new network.

columbus can connect to your network script. It can also be connected before your order, and you will be told to re-check the network every time the computer wakes up.

columbus also has a modified version of one of the link checks of Donald Becker tools. Thus, it will check your networks when your network cable is connected again and, if necessary, complete all synchronization steps.

0
source

Source: https://habr.com/ru/post/1301108/


All Articles