Title: | 'IP' Address 'Lookup' |
---|---|
Description: | A micro-package for getting your 'IP' address, either the local/internal or the public/external one. Currently only 'IPv4' addresses are supported. |
Authors: | Drew Schmidt [aut, cre], Wei-Chen Chen [aut] |
Maintainer: | Drew Schmidt <[email protected]> |
License: | BSD 2-clause License + file LICENSE |
Version: | 0.1-4 |
Built: | 2024-10-31 22:08:52 UTC |
Source: | https://github.com/wrathematics/getip |
A micro-package for getting your IP address, either the local/internal or the public/external one. Currently only IPv4 addresses are supported.
Drew Schmidt
Get your internal/local or external/public IP address. Currently only IPv4 addresses are supported.
getip(type = "local")
getip(type = "local")
type |
One of |
The internal/local IP lookup is done in-process, i.e., it does not call
system()
or the like.
For an external address, the function returns a lookup from one of several services, including Amazon AWS http://checkip.amazonaws.com/, httpbin http://httpbin.org/ip, ipify https://www.ipify.org/, and "My External IP address is ..." http://myexternalip.com/. You must be connected to the internet for this to work. Please note that pathological use could end up in your getting banned from these services, rendering the function useless. So don't call this function a billion times in a loop or something.
Returns the requested IP address as a string.
library(getip) # internal/local address getip("local") # same as getip("internal") # external/public getip("public") # same as getip("external")
library(getip) # internal/local address getip("local") # same as getip("internal") # external/public getip("public") # same as getip("external")
Converts a hostname (or vector of hostnames) to
hostname2ip(hosts)
hostname2ip(hosts)
hosts |
A vector of hostnames as strings (or just one). |
Only IPv4 addresses will be returned. If only IPv6 addresses exist (and if
that is the case, allow me to be the first to greet you, person from the
distant future) then NA
is returned for that hostname.
The function uses getaddrinfo()
on *NIX systems, and
gethostbyname()
on Windows.
A list of vectors of IP's. Each IP is stored as a string.
library(getip) hosts = c("www.google.com", "localhost", "www.yahoo.com") hostname2ip(hosts)
library(getip) hosts = c("www.google.com", "localhost", "www.yahoo.com") hostname2ip(hosts)
Check if a string is a valid IP address. Currently only IPv4 addresses are supported.
validip(ip)
validip(ip)
ip |
A string or vector of strings. |
This function is not like a 'ping'. It merely checks if the string is correctly formatted and could theoretically be a valid IP address.
Returns TRUE
if the input is a potentially valid IP address, and
FALSE
otherwise.
library(getip) validip(c("192.168.1.1", "700.168.1.1"))
library(getip) validip(c("192.168.1.1", "700.168.1.1"))