For no clear reason, OpenVPN on Mac with Tunnelblick (any version, had this problem for a few years already) results in these kind of error messages (and refuses to connect):
2013-02-05 17:44:31 write UDPv4: Can't assign requested address (code=49) 2013-02-05 17:44:33 write UDPv4: Can't assign requested address (code=49)
This seems to appear more often when swapping WiFi/IP range (after my Mac goes into sleep). But also happens when connecting to the same WiFi. It doesn’t change anything whether I disconnect OpenVPN before putting the Mac to sleep.
The solution I’ve found to solve this is:
- Disconnect OpenVPN (via Tunnelblick)
- Turn off WiFi
- Run the script I’ve attached below (flush.sh)
- Fill in your admin/sudo password
- Hit ctrl+C if it doesn’t exit instantly (happens in 99% of the cases)
- Run the script once or twice more to be sure, it will exit correctly this time
- Reconnect to the WiFi
- Reconnect OpenVPN (via Tunnelblick): this time it will work
The script (name it flush.sh, chmod +x, and run ./flush.sh via Terminal):
Edit: updated script (29/01/2014)
#!/bin/bash # Change IFACE to match your WiFi interface # (en0 on Macbook Air and Retina, en1 on old Macbook Pros with ethernet) IFACE=en0 sudo ifconfig $IFACE down sudo route flush sudo ifconfig $IFACE up
In case the script hangs (sometimes, route flush hangs): hit ctrl+C, and execute it again.
Yesterday I’ve start using Prowl, as I heard good comments about it. And one of the things I want it to check, are my server statuses. I made a quick script using bash and crontab to check every 10 min if it replies on ping. Per server, I created “host.domain.tld.sh” (e.g. zero.rootspirit.com.sh), and added this in the file:
#!/bin/bash KEY=YourApiKey HOST=zero.rootspirit.com ping -c 1 $HOST &>/dev/null if [ $? -ne 0 ] ; then curl -k -s "https://prowl.weks.net/publicapi/add?apikey=$KEY&application=Server%20Connectivity%20Failure&event=&description=$HOST&priority=2" fi
Of course, change KEY to your API key, HOST to the IP or DNS of the server it should ping. Also, make sure, that when pinging on your host where you’ll run the bash script on, a non-existing domain actually returns:
ping: unknown host ezfzigjagaqg.reg
PING ezfzigjagaqg.reg.rootspirit.com (184.108.40.206) 56(84) bytes of data.
(Should depend on the search line in /etc/resolv.conf) As I’m pinging about 6 servers I created the file “checkServers.sh” with this content:
#!/bin/bash `/home/yeri/prowl/zero.rootspirit.com.sh &>/dev/null` `/home/yeri/prowl/one.rootspirit.com.sh &>/dev/null` `/home/yeri/prowl/two.rootspirit.com.sh &>/dev/null` `/home/yeri/prowl/four.rootspirit.com.sh &>/dev/null` `/home/yeri/prowl/vm0.rootspirit.com.sh &>/dev/null` `/home/yeri/prowl/vm1.rootspirit.com.sh &>/dev/null`
Make sure to chmod +x *.sh, to make it executable, and edit crontab and add something like that:
*/10 * * * * /home/yeri/prowl/checkServers.sh &>/dev/null
Don’t forget to test it whether it works or not (try non-existing domain(s), and run the script again).