Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

My VPN client sometimes can't bind to the UDP port (500) it uses. It seems to leave behind a "bind" to port 500 on a previous run, even though it has quit.

The port is reported as "already in use" (Mac os X), but doesn't have an associated process:

$ sudo netstat -na | grep "udp.*\.500\>"

udp4       0      0  192.168.50.181.500     *.*                               
udp4       0      0  192.168.29.166.500     *.*                               

But sudo lsof doesn't show a process on port 500 (ie sudo lsof -i:500 -P reports nothing).

I can successfully use the VPN client after rebooting the machine, but am hoping for a less disruptive way to clear the state.

share|improve this question

migrated from stackoverflow.com Nov 12 '12 at 20:40

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

Port 500 is isakmp, used by IPsec VPNs.

Look in /sbin/ifconfig for any virtual network interfaces that might be configured to use that.

share|improve this answer
    
There is no virtual network interface in ifconfig or in the "System Pref / Networking" screen. I do use a VPN client called IPSecuritas, but it doesn't register itself as a virtual interface. I believe it's badly behaved in some circumstances, but I can't figure out how to clean up after it. –  Chocohound Nov 12 '12 at 16:50
    
Also, if what you were saying is the issue, wouldn't there be a process listed by lsof? –  Chocohound Nov 12 '12 at 16:52
    
@Chocohound if it's implemented in the kernel then there needn't be a process. –  Alnitak Nov 12 '12 at 16:53
    
Alnitak, good point. But the issue still remains -- there is no virtual network interface listed... –  Chocohound Nov 12 '12 at 17:39
add comment

Try using netstat -nap to determine which program has the port open. I don't have an OSX system to test on, but on Linux, kernel ports show - as the program.

EDIT: A quick search for OSX ipsec disable indicates that OSX may have IPSEC enabled by default. If so, you would need to disable it to free the port.

share|improve this answer
    
-p flag doesn't exist on Mac. In general netstat can't show PIDs on mac, so you can't tell whether the kernel or some other process has / had the port. The only difference between lines in "netstat -na" is that the "state" field is blank (but I think that's true of all the UDP ports). –  Chocohound Nov 12 '12 at 22:39
    
@Chocohound UPD is stateles, so I would expect it to be blank for UDP. I've updated my answer. Is there a reason you are using an assigned port in your code? –  BillThor Nov 12 '12 at 23:14
    
Sorry, disregard "my code" - it was just a test client to confirm the issue for me. My problem is that I have a VPN client (IPsecuritas) which usually works, but sometimes fails to clean itself up on quitting. I can't figure out how to deallocate it. And if I try to start the VPN client again it fails with an "address already in use". –  Chocohound Nov 13 '12 at 0:04
    
@Chocohound I find a case like this is usually the program failing to finish exiting. However, it may be using kernel services and not shutting them down. Check the logs for the daemon to see if it reports any problems. –  BillThor Nov 13 '12 at 1:30
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.