@LimitedPrivate({"HDFS","MapReduce"})
@Unstable
public class DNS
extends java.lang.Object
| Constructor | Description |
|---|---|
DNS() |
| Modifier and Type | Method | Description |
|---|---|---|
static java.lang.String |
getDefaultHost(java.lang.String strInterface) |
Returns the default (first) host name associated by the default
nameserver with the address bound to the specified network interface
|
static java.lang.String |
getDefaultHost(java.lang.String strInterface,
java.lang.String nameserver) |
|
static java.lang.String |
getDefaultHost(java.lang.String strInterface,
java.lang.String nameserver,
boolean tryfallbackResolution) |
Returns the default (first) host name associated by the provided
nameserver with the address bound to the specified network interface
|
static java.lang.String |
getDefaultIP(java.lang.String strInterface) |
Returns the first available IP address associated with the provided
network interface or the local host IP if "default" is given.
|
static java.lang.String[] |
getHosts(java.lang.String strInterface) |
Returns all the host names associated by the default nameserver with the
address bound to the specified network interface
|
static java.lang.String[] |
getHosts(java.lang.String strInterface,
java.lang.String nameserver,
boolean tryfallbackResolution) |
Returns all the host names associated by the provided nameserver with the
address bound to the specified network interface
|
static java.lang.String[] |
getIPs(java.lang.String strInterface) |
|
static java.lang.String[] |
getIPs(java.lang.String strInterface,
boolean returnSubinterfaces) |
Returns all the IPs associated with the provided interface, if any, in
textual form.
|
static java.util.List<java.net.InetAddress> |
getIPsAsInetAddressList(java.lang.String strInterface,
boolean returnSubinterfaces) |
Returns all the IPs associated with the provided interface, if any, as
a list of InetAddress objects.
|
static java.lang.String |
reverseDns(java.net.InetAddress hostIp,
java.lang.String ns) |
Returns the hostname associated with the specified IP address by the
provided nameserver.
|
public static java.lang.String reverseDns(java.net.InetAddress hostIp,
@Nullable
java.lang.String ns)
throws javax.naming.NamingException
hostIp - The address to reverse lookupns - The host name of a reachable DNS serverjavax.naming.NamingException - If a NamingException is encounteredpublic static java.lang.String[] getIPs(java.lang.String strInterface)
throws java.net.UnknownHostException
strInterface - input strInterface.getIPs(String, boolean), but returns all
IPs associated with the given interface and its subinterfaces.java.net.UnknownHostException - If no IP address for the local host could be found.public static java.lang.String[] getIPs(java.lang.String strInterface,
boolean returnSubinterfaces)
throws java.net.UnknownHostException
strInterface - The name of the network interface or sub-interface to query
(eg eth0 or eth0:0) or the string "default"returnSubinterfaces - Whether to return IPs associated with subinterfaces of
the given interfacejava.net.UnknownHostException - If the given interface is invalidpublic static java.lang.String getDefaultIP(java.lang.String strInterface)
throws java.net.UnknownHostException
strInterface - The name of the network interface or subinterface to query
(e.g. eth0 or eth0:0) or the string "default"java.net.UnknownHostException - If the given interface is invalidpublic static java.lang.String[] getHosts(java.lang.String strInterface,
@Nullable
java.lang.String nameserver,
boolean tryfallbackResolution)
throws java.net.UnknownHostException
strInterface - The name of the network interface or subinterface to query
(e.g. eth0 or eth0:0)nameserver - The DNS host nametryfallbackResolution - if true and if reverse DNS resolution fails then attempt to
resolve the hostname with
InetAddress.getCanonicalHostName() which includes
hosts file resolution.java.net.UnknownHostException - if the given interface is invalidpublic static java.lang.String[] getHosts(java.lang.String strInterface)
throws java.net.UnknownHostException
strInterface - The name of the network interface to query (e.g. eth0)java.net.UnknownHostException - If one is encountered while querying the default interfacepublic static java.lang.String getDefaultHost(@Nullable
java.lang.String strInterface,
@Nullable
java.lang.String nameserver,
boolean tryfallbackResolution)
throws java.net.UnknownHostException
strInterface - The name of the network interface to query (e.g. eth0)nameserver - The DNS host nametryfallbackResolution - Input tryfallbackResolution.java.net.UnknownHostException - If one is encountered while querying the default interfacepublic static java.lang.String getDefaultHost(@Nullable
java.lang.String strInterface)
throws java.net.UnknownHostException
strInterface - The name of the network interface to query (e.g. eth0).
Must not be null.java.net.UnknownHostException - If one is encountered while querying the default interfacepublic static java.lang.String getDefaultHost(@Nullable
java.lang.String strInterface,
@Nullable
java.lang.String nameserver)
throws java.net.UnknownHostException
strInterface - The name of the network interface to query (e.g. eth0)nameserver - The DNS host namejava.net.UnknownHostException - If one is encountered while querying the default interfacepublic static java.util.List<java.net.InetAddress> getIPsAsInetAddressList(java.lang.String strInterface,
boolean returnSubinterfaces)
throws java.net.UnknownHostException
strInterface - The name of the network interface or sub-interface to query
(eg eth0 or eth0:0) or the string "default"returnSubinterfaces - Whether to return IPs associated with subinterfaces of
the given interfacejava.net.UnknownHostException - If the given interface is invalidCopyright © 2008–2025 Apache Software Foundation. All rights reserved.