Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you detect a VPN or Proxy connection? [closed]

Tags:

proxy

vpn

I would like to block all connections to my server that use a VPN or Proxy. Is there anyway to detect that a VPN or proxy connection is being used? If not, is there anyway that I can check the likelihood that a VPN or proxy is being used? Lastly, is there anything that I can query or prompt the user with to check if they are using a VPN or Proxy so that if anyone does get through, I can try and perform additional verification? I do not need any information from the user such as location, true IP, or anything like that. I just want to entirely bar connections from VPNs or Proxies.

Edit: I've been thinking that I could potentially run a test to see if there is consistent discrepancies between ping to the VPN IP and the detectable latency of the client, but that sounds pretty unreliable.

Edit2: A proxy or VPN server would likely have many more ports open than a standard home connection so I could use the number of ports open to help gauge the likelihood of a connection coming from a VPN by running a port scan of the person connecting.

like image 651
Zach Sugano Avatar asked Oct 23 '15 11:10

Zach Sugano


People also ask

Can VPN connections be detected?

The IP addresses of VPN servers aren't difficult to recognize — there are even databases specializing in VPN detection, that try to determine whether an IP belongs to a particular provider. When you access a website with a VPN on, it may be able to identify that you're using a VPN using your IP.

Can a proxy be detected?

It'd be impossible to detect all proxy servers, but some can be detected. Proxy providers continually change their IP addresses to try to avoid detection. There are multiple lists of known proxy IP addresses available online, and ipdata combines many of them, along with proprietary lists to detect the larger proxies.


2 Answers

Unfortunately, there's is no proper technical way to get the information you want. You might invent some tests, but those will have a very low correlation with the reality. So either you'll not catch those you want, or you'll have a larger number of false positives. Neither can be considered to make sense.

Generating any kind of traffic backwards from an Internet server in response to an incoming client (a port scan, or even a simple ping) is generally frowned upon. Or, in the case of a port scan, it may be even worse for you, eg when the client lives behind a central corporate firewall, the worst of which is when the client comes from behind the central government network firewall pool...

Frankly, IP-based bans (or actually, any kind of limiting focusing on people who do not exclusively possess their public IP address: proxy servers, VPNs, NAT devices, etc) have been unrealistic for a long time, and as the IPv4 pools have been getting depleted in many parts of the world, ISPs are putting more and more clients behind large NAT pools (it's this week's news in my country that the largest ISP, a subsidiary of Deutsche Telekom, has started handing out private IPv4 addresses as a standard way of business to its customers, and people have to ask the provider explicitly to get a public IP address), so there's even less and less point in doing so. If you want to ban clients, you should ban them based on identity (account), and not based on IP address.

like image 81
Laszlo Valko Avatar answered Oct 02 '22 23:10

Laszlo Valko


At IPinfo we offer a privacy detection API, which will let you know if a connection is coming from a VPN, an anonymous proxy, a tor exit node, or a hosting provider (which could be used to tunnel traffic). Here's an example:

$ curl ipinfo.io/43.241.71.120/privacy?token=$TOKEN {     "vpn": true,     "proxy": false,     "tor": false,     "hosting": true } 

If you wanted to block connections to your site from VPNs then you could make an API request to get this information, and reply with an error if it's detected as a VPN. In PHP that would look something like this:

$ip = $_SERVER['REMOTE_ADDR']; $url = "http://ipinfo.io/{$ip}/privacy?token={$IPINFO_API_TOKEN}"; $details = json_decode(file_get_contents($url)); // Just block VPNs if($details->vpn) {      return echo "VPN Access Blocked!"; }  // Or we could block all the other types of private / anonymous connections... if($details->vpn || $details->proxy || $details->tor || $details->hosting) {      return echo "Access Blocked!"; }     
like image 23
Ben Dowling Avatar answered Oct 02 '22 23:10

Ben Dowling