Every time I connect to a VPN I need to extract my IP adress from ifconfig and manually update it in an rc-file accordingly.
I would like to automate this process. I.e. once connected to the VPN and the IP for the tun0 device got assigned, I would like to write said IP to the environment variable
Question: How can I automatically detect that the system is connected to a vpn, that tun0 has an IP address, and update the environment variable accordingly?
Extracting the IP from ifconfig output is the easiest part. But how do I conveniently detect the network state change on OSX? launchd? Automator script? Something totally different?