I want to find out if a user is using a VPN when a user sends a request to the API (to warn the user that he is using a VPN and to use the API he must turn off the VPN)
I get the user’s IP using the following code:
x_forwarded_for = request.META.get('HTTP_X_FORWARDED_FOR')
ip_list = x_forwarded_for.split(',')
But there are different ways to detect the use of VPN by the user, which are limited and also not free Is there a way to solve this problem?
Are you looking to detect someone using any VPN, or using one specific (e.g. corporate) VPN?
If it’s a corporate VPN situation, then you should be able to identify the subnet that the VPN is configured to use.
No i want to detect someone using any type of VPN not specific!
That’s an interesting topic! I just searched the internet for “detect VPN connection” and found a number of blog posts, etc, that talk about this issue.
The bottom line is that no method is going to be 100% effective and it’s a never-ending battle between those creating VPN enpoints and the people trying to detect them. (And, from what I can see, a “private” VPN used by a very small number of people is going to be nearly impossible to identify.)
Yes, tell me about it
Apparently, there is no 100% solution for this issue
But I want to increase this percentage as much as possible
And honestly, one solution is to have a list of VPV IPs that should always be updated and through it we can find out whether the user is using VPN or not, which is a very difficult task.