Determining IP Address: Difference between revisions
From MediaWiki
Jump to navigationJump to search
(New page: This page offers suggestions on how one might determine the '''IP''' address associated with a particular system. = Internet IP Address = There are many ways in which one can == For Sc...) |
|||
(2 intermediate revisions by one other user not shown) | |||
Line 3: | Line 3: | ||
= Internet IP Address = | = Internet IP Address = | ||
There are many ways in which one can | There are many ways in which one can determine the Internet '''IP''' address associated with a particular system. | ||
== For Scripting == | == For Client Side Scripting == | ||
The following '''URL'''s will return your '''IP''' address (as you appear to the Internet) as a simple text string: | The following '''URL'''s will return your '''IP''' address (as you appear to the Internet) as a simple text string: | ||
* http://nst.sourceforge.net/nst/cgi-bin/ip.cgi | * http://nst.sourceforge.net/nst/cgi-bin/ip.cgi | ||
* http://www.networksecuritytoolkit.org/nst/cgi-bin/ip.cgi | * http://www.networksecuritytoolkit.org/nst/cgi-bin/ip.cgi | ||
* http:// | * http://whatismyip.org/ | ||
* https://geoip.ubuntu.com/lookup | |||
The following '''bash''' script fragment demonstrates how one can retrieve the Internet '''IP''' address and store it in a variable: | The following '''bash''' script fragment demonstrates how one can retrieve the Internet '''IP''' address and store it in a variable: |
Latest revision as of 12:35, 7 December 2023
This page offers suggestions on how one might determine the IP address associated with a particular system.
Internet IP Address
There are many ways in which one can determine the Internet IP address associated with a particular system.
For Client Side Scripting
The following URLs will return your IP address (as you appear to the Internet) as a simple text string:
- http://nst.sourceforge.net/nst/cgi-bin/ip.cgi
- http://www.networksecuritytoolkit.org/nst/cgi-bin/ip.cgi
- http://whatismyip.org/
- https://geoip.ubuntu.com/lookup
The following bash script fragment demonstrates how one can retrieve the Internet IP address and store it in a variable:
# Use wget to retrieve the IP address IP_ADDRESS="$(wget -O - http://nst.sourceforge.net/nst/cgi-bin/ip.cgi 2>/dev/null)";
The getipaddress script uses this basic technique and adds error checking, caching and the ability to use multiple sources (should a server be down). The following demonstrates how one would achieve similar results using the --public-address option provided by the getipaddr script:
# Use getipaddress to retrieve the IP address IP_ADDRESS="$(getipaddr --public-address)";