0

To verify the user is logging in a safe machine I need to take the user machine's personal IP address. After long search I'm not able to find the solution in Angular 2 with typescript. How to get the personal IP address?

NOTE : Don't need to access the user's notwork IP address.

Suresh Kumar
  • 172
  • 3
  • 12
  • 2
    https://stackoverflow.com/questions/391979/how-to-get-clients-ip-address-using-javascript-only – Z. Bagley Oct 06 '17 at 13:56
  • You can't get the individual user's IP address if they are behind a proxy / firewall / other infrastructure. The IP address is not even guaranteed to be genuine - it is perfectly simple to spoof it. – Fenton Oct 06 '17 at 13:56

1 Answers1

2

you can use this website that gives a lot of information about your machine : http://freegeoip.net/json/

here is the code to get your personnal IP address using typescript:

this._http.get("http://freegeoip.net/json/")
        .map(data => {

            console.log(data.json().ip);
});
Mohamed Ali RACHID
  • 3,245
  • 11
  • 22
  • 1
    This website is producing the network's IP address not personal machine's IP address. – Suresh Kumar Oct 09 '17 at 05:41
  • to get your personal machine's IP address , replace the URL with this one : `https://ipinfo.io` , Hope it helps you – Mohamed Ali RACHID Oct 09 '17 at 09:20
  • It also provides the network IP's only.. I understand getting personal IP address is not best practice. Thanks for your help. – Suresh Kumar Oct 10 '17 at 12:00
  • can you please help me to sovle this https://stackoverflow.com/questions/52241799/failed-to-compile-node-modules-macaddress-lib-windows-js-in-angular-5 @MohamedAliRACHID – Zhu Sep 09 '18 at 09:41