current position:Home>How to obtain the external network IP on the server

How to obtain the external network IP on the server

2022-02-04 16:35:53 CSDN Q & A

As the title , I will be a java The project is deployed on the ECS , The project has an interface that exposes the information of its server IP. I want to pass the code or fall up Linux Command to obtain the external network where the server is located IP, But always get the intranet IP, I found many tools on the Internet, but I can only get the intranet IP. Ask if there is any way to get the Internet IP Do you ?




Take the answer :

Extranet IP It's provided by the router , Where to get on this machine
Network structure :
The server <---> Router intranet port --- Router extranet port <---> Internet
Don't say you call anything on the server API Can only get local IP, Even if you use network instructions , At most, you can know the router intranet IP, Unless you log in to the router and see the configuration, you can know the external network IP
=-=-=-=-=-=
Unless you have another application on another network , Then let the server send a request to another application , So that the other party can know its external network IP What is it? , Then I'll tell it back to you .
-=-=-=-=-=
It's a bit like a company telephone switchboard and extension , You can always only find the extension number on the extension , I can't find the switchboard number , And the switchboard has several numbers , Random allocation , You can only dial one for your mobile phone and see the caller ID to know what the number is .



Other answers 2:

Extranet IP It's mapped out , The external network cannot be obtained by this machine IP.


Other answers 3:
 Alibaba cloud can use curl ident.me obtain ; Tencent cloud sometimes can't get... With the above , It can be changed curl http://metadata.tencentyun.com/meta-data/public-ipv4 try 

Other answers 4:

Tencent cloud can't see the public network in the server interface ip Well

copyright notice
author[CSDN Q & A],Please bring the original link to reprint, thank you.
https://en.cdmana.com/2022/02/202202041635514731.html

Random recommended