Locate WAN IP from command line using lynx and www.whatismyip.com
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Distribution: Slackware, Windows, FreeBSD, OpenBSD, Mac OS X
Posts: 5,296
Rep:
Hi jtag, Welcome to LQ. I just used lynx with the link you provided and it worked as expected. Just type G for go, then paste the url in and hit enter. Is this not working for you?
The lynx is working with "http://www.whatismyip.com/tools/ip-address-lookup.asp" but (maybe I was not clear) I would like to implement this in a bash script and to grep the location (Canada, USA ...).
The problem is that I have to enter the IP on the site and I don't know how to implement this in a script.
The lynx is working with "http://www.whatismyip.com/tools/ip-address-lookup.asp" but (maybe I was not clear) I would like to implement this in a bash script and to grep the location (Canada, USA ...).
The problem is that I have to enter the IP on the site and I don't know how to implement this in a script.
I'm not sure if whatismyip.com has shortcut URL to determine the location of an IP. I also tried with -dump, -post_data, -cmd_log, -cmd_script (read from lynx's man page) but not success.
An alternative way, I suggest you use ip2location which has shortcut URL, therefore you can find out the location of an IP address from command line:
Code:
$ lynx -dump --accept_all_cookies http://ip2location.com/8.8.8.8 | grep -A9 "IP Address Country Region City Latitude"
IP Address Country Region City Latitude/
Longitude ZIP Code Time Zone
8.8.8.8 [US.gif] UNITED STATES CALIFORNIA MOUNTAIN VIEW 37.3956
-122.076 [85]94043 -08:00 Map It
Net Speed ISP Domain
DSL GOOGLE INCORPORATED GOOGLE.COM
IDD Code Area Code Weather Station
1 650 [86]USCA0746 - MOUNTAIN VIEW
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.