Forum > General

Get public IP adress

<< < (2/3) > >>

trev:

--- Quote from: Remy Lebeau on April 15, 2020, 12:05:53 am ---However, it has recently come to my attention that some ISPs hide their users behind a NAT on the ISP's side, in which case such sites will see the ISP's IP, not the user's IP.  So, to get your own external IP (ie, the IP that is connected to the ISP) in that situation, you would have to query your modem/router directly instead, such as with uPNP.

--- End quote ---

With the current scarcity of IPv4, many ISPs (in Australia) are now using CG-NAT. However, querying the user's modem/router in this situation will not provide an external/public IP, but rather the private IP used within the ISP's network and which is useless outside of the ISP's network.

Remy Lebeau:

--- Quote from: trev on April 15, 2020, 07:54:29 am ---However, querying the user's modem/router in this situation will not provide an external/public IP, but rather the private IP used within the ISP's network

--- End quote ---

True.  But it will still be the external IP from the perspective of the user's PC.


--- Quote from: trev on April 15, 2020, 07:54:29 am ---and which is useless outside of the ISP's network.

--- End quote ---

That depends on why you are querying the IP in the first place.

Thaddy:

--- Quote from: Remy Lebeau on April 15, 2020, 07:31:09 pm ---That depends on why you are querying the IP in the first place.

--- End quote ---
This is usually very common as a - small - part of user identification, e.g. in banking, where users need to register their devices.
It can be an indicator of proper use or mis-use. If multiple indicators fail, any transaction will be invalid.

Note it is not as relevant as it used to be, since multiple factor authentication is now common practice. But it is still such a factor....

Remy Lebeau:

--- Quote from: Thaddy on April 15, 2020, 07:55:43 pm ---This is usually very common as a - small - part of user identification, e.g. in banking, where users need to register their devices.
It can be an indicator of proper use or mis-use. If multiple indicators fail, any transaction will be invalid.

--- End quote ---

The only time I've ever needed to query my local LAN's external IP is when using protocols, like FTP or custom, that accept incoming connections from the outside world and need to give the IP to an outside party so they know where to connect to.

blastiko:
Under Linux, or in any case with curl installed:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function getPublicIP() : string;        var            proc: TProcess;            outp : TStringList;            ip : string;        begin                proc := TProcess.create(nil);                proc.Executable := '/usr/bin/curl';                proc.Parameters.Add('ifconfig.me');                proc.Options := proc.Options + [poWaitOnExit, poUsePipes];                proc.Execute;                outp := TStringList.Create;                outp.LoadFromStream(proc.Output);                if (outp.Count > 0) then begin                        ip := outp[0];                        if (not IsIp(ip)) then ip := '---';                end     else                ip := '---';             outp.Free;                proc.Free;                 Result := ip;        end; 

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version