I need to test whether an OpenVPN Service (ssl-vpn) is listening on a specific IP address and port from a linux box. I'd like to do that with a bash script or some code in python or c/c++ but that's not the problem - I can implement it as soon as I know how UDP works here.

My problem is: the VPN service on the remote machine is configured to use UDP and since UDP isn't a protocoll that supports connections like TCP I assume that any answer to a message/package that I sent to the remote machine is answered to another port on my local machine.

I know netcat but obviously I won't receive an answer using the connectionless UDP protocoll, so checking with nc -u ip port won't work.

So, how do I check if VPN is really up and running behind an IP address and port.

Is it possible to emulate the VPN with a bash script? Something like connecting with a HELO like in SMTP and checking if the VPN server sent an answer back? I'd know how this works with tcp but I have no clue how to do that with UDP.

I just found this answer. So, how do I listen to ICMP packages that should be answered when the remote server isn't available? Is that possible with bash/python/c/c++ or netcat? How do I know if the server is there, listening to requests (there shouldn't be an ICMP response then, right?)?


The only way I think you can reliably test this would be to simply establish a connectionto the VPN.

As you said OpenVPN while using TCP cannot be tested using a simple TCP connect. I suspect the only way to test is by speaking the OpenVPN protocol.

I soppose it could be possible to modify the client to test while not fully connecting.

  • I also thought about sending some kind of HELO like in SMTP and check if I get an answer. But since the answer doesn't seem to come back at the same connection (for the lack of a connection), I don't know how to do this. – wullxz Dec 25 '12 at 21:33
  • I suspect you would need to examine the OpenVPN source. I am not sure if there are any methods available as part of the protocol. I doubt you can test with bash, and you would need to learn C. – Zoredache Dec 26 '12 at 7:37
  • the programming part is not the problem. I just don't know how to handle the UDP "connection" (which isn't a connection as in TCP). – wullxz Dec 26 '12 at 9:20
  • It is possible to test udp ports with nmap (parameter -sU). However, our problem is (I didn't know that when I asked this question), that some packets are dumped at the firewall. To test if this is the case, we have to try to connect to our VPN server. – wullxz Jan 3 '13 at 5:55

This is from my previous answer to a similar question.
How to check that an OpenVPN server is listening on a remote port without using OpenVPN client?
If you are using tls authentication (tls-auth configuration line) this is not working, but you can get the idea of UDP conversation.

import socket
senddata= "\x38\x01\x00\x00\x00\x00\x00\x00\x00"

def checkserver(ip,port):
   print('Checking %s:%s' %(ip,port)) 
   sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
   sock.settimeout(5) # in seconds
   sock.connect((ip, port))
   print("Sending request...")
      print("Server reply: %s" %(dta))
      print("Server not responding")

def main():

if __name__ == "__main__":

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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