public class DNS extends Object
限定符和类型 | 字段和说明 |
---|---|
static org.apache.commons.logging.Log |
LOG |
构造器和说明 |
---|
DNS() |
限定符和类型 | 方法和说明 |
---|---|
static String |
getDefaultHost(String strInterface)
Returns the default (first) host name associated by the default
nameserver with the address bound to the specified network interface
|
static String |
getDefaultHost(String strInterface,
String nameserver)
Returns the default (first) host name associated by the provided
nameserver with the address bound to the specified network interface
|
static String |
getDefaultIP(String strInterface)
Returns the first available IP address associated with the provided
network interface
|
static String[] |
getHosts(String strInterface)
Returns all the host names associated by the default nameserver with the
address bound to the specified network interface
|
static String[] |
getHosts(String strInterface,
String nameserver)
Returns all the host names associated by the provided nameserver with the
address bound to the specified network interface
|
static String[] |
getIPs(String strInterface)
Like
getIPs(String, boolean) , but returns all
IPs associated with the given interface and its subinterfaces. |
static String[] |
getIPs(String strInterface,
boolean returnSubinterfaces)
Returns all the IPs associated with the provided interface, if any, in
textual form.
|
static String |
reverseDns(InetAddress hostIp,
String ns)
Returns the hostname associated with the specified IP address by the
provided nameserver.
|
public static String reverseDns(InetAddress hostIp, String ns) throws NamingException
hostIp
- The address to reverse lookupns
- The host name of a reachable DNS serverNamingException
- If a NamingException is encounteredpublic static String[] getIPs(String strInterface) throws UnknownHostException
getIPs(String, boolean)
, but returns all
IPs associated with the given interface and its subinterfaces.public static String[] getIPs(String strInterface, boolean returnSubinterfaces) throws UnknownHostException
strInterface
- The name of the network interface or subinterface to query
(eg eth0 or eth0:0) or the string "default"returnSubinterfaces
- Whether to return IPs associated with subinterfaces of
the given interfaceUnknownHostException
- If an UnknownHostException is encountered in querying the
default interface or the given interface can not be foundpublic static String getDefaultIP(String strInterface) throws UnknownHostException
strInterface
- The name of the network interface or subinterface to query
(e.g. eth0 or eth0:0) or the string "default"UnknownHostException
- If one is encountered in querying the default interfacepublic static String[] getHosts(String strInterface, String nameserver) throws UnknownHostException
strInterface
- The name of the network interface or subinterface to query
(e.g. eth0 or eth0:0) or the string "default"nameserver
- The DNS host nameUnknownHostException
public static String[] getHosts(String strInterface) throws UnknownHostException
strInterface
- The name of the network interface to query (e.g. eth0)UnknownHostException
- If one is encountered while querying the deault interfacepublic static String getDefaultHost(String strInterface, String nameserver) throws UnknownHostException
strInterface
- The name of the network interface to query (e.g. eth0)nameserver
- The DNS host nameUnknownHostException
- If one is encountered while querying the deault interfacepublic static String getDefaultHost(String strInterface) throws UnknownHostException
strInterface
- The name of the network interface to query (e.g. eth0)UnknownHostException
- If one is encountered while querying the deault interfaceCopyright © 2009 The Apache Software Foundation