public class DNSUtils extends Object
| Constructor and Description |
|---|
DNSUtils() |
| Modifier and Type | Method and Description |
|---|---|
static DNSRecord |
createARecord(String name,
long ttl,
String ip)
Creates a DNS A type record.
|
static DNSRecord |
createMXRecord(String name,
String target,
long ttl,
int priority)
Creates a DNS MX record.
|
static DNSRecord |
createSOARecord(String name,
long ttl,
String nameServer,
String hostMaster,
int serial,
long refresh,
long retry,
long expire,
long minumum)
Create a DNS SOA record.
|
static DNSRecord |
createSRVRecord(String name,
String target,
long ttl,
int port,
int priority,
int weight)
Create a DNS SRV type record.
|
static DNSRecord |
createX509CERTRecord(String address,
long ttl,
X509Certificate cert)
Creates a DNS CERT record containing an X509 public certificate.
|
static DNSRecord |
fromWire(byte[] data)
Converts a raw wire transfer format of a record to a DNS record.
|
static byte[] |
toWire(DNSRecord rec)
Converts a DNS record to a raw wire transfer format.
|
public static DNSRecord createARecord(String name, long ttl, String ip) throws DNSRecordCreationException
name - The record name. Generally a fully qualified domain name such as host.example.com.ttl - The time to live in seconds.ip - The ip4 address that the name will resolve.ConfigurationStoreExceptionDNSRecordCreationExceptionpublic static DNSRecord createSRVRecord(String name, String target, long ttl, int port, int priority, int weight) throws DNSRecordCreationException
name - The service name.target - The target name that is hosting the service.ttl - The time to live in seconds.port - The port that the service is offered on.priority - The priority of the service. Lower priorities are preferred.weight - A value used to select between services with the same priority.ConfigurationStoreExceptionDNSRecordCreationExceptionpublic static DNSRecord createX509CERTRecord(String address, long ttl, X509Certificate cert) throws DNSRecordCreationException
address - The name or address corresponding to the certificate.ttl - The time to live in seconds.cert - The X509 public certificate to be stored with the name/address.ConfigurationStoreExceptionDNSRecordCreationExceptionpublic static DNSRecord createMXRecord(String name, String target, long ttl, int priority) throws DNSRecordCreationException
name - The email domain or host used to determine where email should be sent to.target - The host server that email should be sent to.ttl - The time to live in seconds.priority - The priority of the target host. Lower priorities are preferred.ConfigurationStoreExceptionDNSRecordCreationExceptionpublic static DNSRecord createSOARecord(String name, long ttl, String nameServer, String hostMaster, int serial, long refresh, long retry, long expire, long minumum) throws DNSRecordCreationException
name - The root name of the zone.ttl - The time to live in seconds.nameServer - Name of the server that responds authoritatively to this zone.hostMaster - The email address of the administrator of the zone. The @ symbol is replaced with a "."serial - The current serial number of record.refresh - The time in seconds the a slave server tries to refresh its information from the master.retry - The time in seconds that a slave server retires after a failed refresh.expire - Time in seconds when the zone data is not longer authoritative.minumum - See RFC 2308.DNSRecordCreationExceptionpublic static byte[] toWire(DNSRecord rec) throws IOException
rec - The DNSRecord to convert.IOExceptionpublic static DNSRecord fromWire(byte[] data) throws IOException
data - The raw byte stream of a record in wire transfer format.IOExceptionCopyright © 2025. All rights reserved.