Skip to content

Instantly share code, notes, and snippets.

@markan
Created August 21, 2015 17:52
Show Gist options
  • Save markan/a8eabbae4cf06e62023b to your computer and use it in GitHub Desktop.
Save markan/a8eabbae4cf06e62023b to your computer and use it in GitHub Desktop.
shimo/vpnc "ERROR: can't send packet: Can't assign requested address"

The problem

I've frequently been bit by failures restarting my vpn on my Mac. The connection may appear to start up in Shimo (the menu icon will change) but it looks like vpnc can't connect.

Looking at the log, we see the connection gets stuck

ERROR: can't send packet: Can't assign requested address

This has plagued me for a while, and my only fix has been to restart the machine. I hate restarting my machine. So I finally made time to dig in and find a better solution

I noticed that I couldn't ping 199.12.34.56 (the address of the vpn server) either.

What appears to be happening is the route to the vpn server get stuck to an old address/interface.

netstat -nr
Routing tables

Internet:
Destination        Gateway            Flags        Refs      Use   Netif Expire
default            192.168.1.1        UGSc           51        8     en8
127                127.0.0.1          UCS             0        0     lo0
127.0.0.1          127.0.0.1          UH             25    49984     lo0
169.254            link#13            UCS             0        0     en8
192.168.0/16       link#13            UCS             1        0     en8
192.168.1.1/32     link#13            UCS             1        0     en8
192.168.1.1        d4:ca:6d:dd:f1:a5  UHLWIir        52        0     en8   1188
192.168.1.13/32    link#13            UCS             0        0     en8
192.168.1.22       74:d0:2b:c8:df:f5  UHLWIi          1       12     en8   1159
199.12.34.56      172.28.4.1         UGHS            0        4     en0

172.28.4.1 gateway doesn't exist...

It turns out that is the gateway I was using before I moved to my current location. (and things work when I move back there) The solution

Deleting the route fixes the problem:

sudo route delete 199.12.34.56 

and now ping and vpnc are happy.

I'm still not clear what is causing this, but it appears to only be happening when I switch both the address and the interface I'm using. Note that the above issue the route was on en0, but my main gateway was en8 (a USB ethernet dongle).

@kasim
Copy link

kasim commented Mar 22, 2019

I reproduced the above situation when using vpnc on MacOS.

I have a script to kill the vpnc process and reconnect it. But it does not work if the connection is broken after the machine slept.

I found this page on Google and I delete the route to the vpn server, and the script got work again. Now I put the deleting route command into my script.

@apolaskey
Copy link

Thanks for this, saved my 🥓

@euanmillar
Copy link

Thank you!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment