Specifying IP address with curl/wget

Hello,

I am wondering does anyone know of a method using curl/wget or other where by I could specify the IP address of the server I wish to query for a website.

Something similar to editing /etc/hosts but that can be done directly from the command line. I have looked through the man pages for both curl and wget and the only options to specify and IP address refer to choosing the bind-address if your machine is bound to multiple IP's.

Perhaps I am looking at this in the wrong way. Any suggestions on how I may get this to work are welcome.

Thanks,
Colin

wget -o /dev/null -O output.html "www.unix.com"

output.dat file will contain the HTML of www<dot>unix<dot>com. You can also specify IP address instead of the URL. Is this what you're looking for?

Hello balajesuri,

Thank you for your reply.

Lets say I have a website example.com hosted on two separate servers, 1.3.5.7 and 2.4.6.8.

To view each version of the site I would normally edit my /etc/hosts file to point the IP address of the server I wish to query.

What I am looking to do is use wget/curl to send the header requests to a specific IP address

i.e: wget -o /dev/null -O output.html "www.example.com" --ip 2.4.6.8 (or something to that effect)

From what I have read in the last few minutes this does not seem possible with wget or curl (I stand to be corrected).

Colin

Hello colinireland,

If there isn't any restraint on using the IP address directly, you may use the following in your script:

wget -O output.html "2.4.6.8"

Hello balajesuri,

Sorry I should have mentioned that the server is a shared hosting server so many domains are sharing the same IP address. Perhaps PHP has some answers?

Regards,
Colin