Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jsonip.com returning internal and external IP

I'm using http://jsonip.com to get the users IP address. For some users, its returning an internal and external IP as a comma separated string. I only want the external IP address. Can I assume some sort of order to the returned addresses? Is the external IP address always last? Or do I need to filter based on some criteria? For example: exclude 127.0.0.1, 192.168.., 10...*?

$.getJSON('http://jsonip.com/?callback=?', function(data){
    console.log("Current IP Address: " + data.ip);
});
like image 324
Ethan Schofer Avatar asked Jun 08 '26 13:06

Ethan Schofer


1 Answers

Sorry I never found this question until now. (I run jsonip.com)

jsonip uses the x-forwarded-for header to get the user's ip. The right-most (last) ip should be the visitor's public facing address.

like image 124
Geuis Avatar answered Jun 10 '26 04:06

Geuis