1

My IP is not changing after connecting to the VPN(NordVPN). Here's my code:

How can I fix this? I am noob in python please help by listing the step by step guide.

import requests
res=requests.get("https://httpbin.org/ip")
print(res.text)
Jab
  • 26,853
  • 21
  • 75
  • 114
piggyback
  • 11
  • 1
  • 2
  • 2
    python wont solve this, you need to make your VPN the default route for your web traffic. – Nathan McCoy Mar 27 '19 at 19:01
  • How should I do that? Any code or step by step to do this? – piggyback Mar 27 '19 at 19:04
  • First make sure you can do that with plain `curl` (and before that, reach with a plain `ping`). Then you can access that from whatever language; the language is not a problem. – 9000 Mar 27 '19 at 19:04
  • Possible duplicate of [use vpn with python requests](https://stackoverflow.com/questions/35132154/use-vpn-with-python-requests) – Nazim Kerimbekov Mar 27 '19 at 19:10
  • once you connected your VPN, do `curl ifconfig.io` which will tell you your current public IP address – Wallace Mar 27 '19 at 19:12

1 Answers1

3

I can't comment on this post so I'll just tell you that you should format code by surrounding it with backticks (this character: ` ). Also, please separate each line. Please update your post.

As for your question, please do understand that Python code is not necessary to check your IP address. Simply going to that web address in your browser should show you your IP. Moreover, if your IP address is not changing after enabling a VPN, your VPN is at fault, not Python. When I use a VPN and go to that address in the browser, it does work.

Finally, I suspect that you are using a NordVPN browser extension, not a system-wide VPN. In that case, Python is not actually going through your browser to access the web address. It is directly requesting the information from the webpage. If you install system-wide, it should work.

101arrowz
  • 1,825
  • 7
  • 15