Getting my server's requesting IP address from an outgoing cURL request?
Solution 1
I was inspired by @Atsby's answer and found this article: http://tecadmin.net/5-commands-to-get-public-ip-using-linux-terminal/
Here are it's suggestions:
curl ipecho.net/plain; echo
curl icanhazip.com
curl ifconfig.me
wget http://ipecho.net/plain -O - -q ; echo
wget http://observebox.com/ip -O - -q ; echo
Solution 2
I want to know what my server's host address is [...]
The simplest way is to fetch a page that echoes back your IP address, like http://www.whatismyip.com/
Note that this isn't the most reliable way, as it depends on such services to be available. There are AWS APIs you can use to determine the public-facing IP of an AWS box.
T. Brian Jones
I'm a programmer and systems architect who loves to analyze massive data sets. I have a degree in Mechanical Engineering and an MBA. Before becoming a full time computer jockey, I was a manufacturing and design engineer doing industrial automation and robotics. I have experience with: OSX, Linux, HTML & CSS, PHP, MySQL, MongoDB, Sphinx, ElasticSearch, CodeIgniter, CakePHP, Slim Framework, SupervisorD, Amazon Web Services ( VPC, EC2, EBS, RDS, SQS, & S3, etc., etc. ), Subversion & Assembla, GIT & Github, Jira & Confluence, API Design, Big Data management and analysis, and large scale web-crawling. I've also worked with proprietary industrial automation languages (like GE Fanuc).
Updated on June 04, 2022Comments
-
T. Brian Jones almost 2 years
I'm making a request to an external API that accepts my request and returns information. I want to know what my server's host address is based on what the external API sees. Is there a way to get this information from a Command Line cURL request (or other method)?
My server is behind a bunch of firewalls in a VPC on Amazon AWS, so I'm not sure what my request looks like and where it's coming from.
Currently I'm making this request and don't see the info I need:
curl -v 'http://www.apihost.com/request/url'