<dns>
<txt name="example" value="example value"/>
<forwarder addr="8.8.8.8"/>
- <forwarder domain='example.com' addr="8.8.4.4"/>
+ <forwarder domain='example.com' addr='8.8.4.4' port='1234'/>
<forwarder domain='www.example.com'/>
<srv service='name' protocol='tcp' domain='test-domain-name' target='.'
port='1024' priority='10' weight='10'/>
will be resolved locally (or via the host's standard DNS forwarding if
they can't be resolved locally). If an ``addr`` is specified by itself,
then all DNS requests to the network's DNS server will be forwarded to the
- DNS server at that address with no exceptions. ``addr`` :since:`Since
- 1.1.3` , ``domain`` :since:`Since 2.2.0`.
+ DNS server at that address with no exceptions. Optionally, the ``port``
+ attribute can be given among with ``addr`` to specify a nonstandard
+ port of the DNS server. ``addr`` :since:`Since 1.1.3`, ``domain``
+ :since:`Since 2.2.0`, ``port`` :since:`Since 12.0.0`.
``txt``
A ``dns`` element can have 0 or more ``txt`` elements. Each txt element
defines a DNS TXT record and has two attributes, both required: a name
for (i = 0; i < nfwds; i++) {
g_autofree char *addr = virXMLPropString(fwdNodes[i], "addr");
- if (addr && virSocketAddrParse(&def->forwarders[i].addr,
- addr, AF_UNSPEC) < 0) {
- virReportError(VIR_ERR_XML_ERROR,
- _("Invalid forwarder IP address '%1$s' in network '%2$s'"),
- addr, networkName);
- return -1;
+ if (addr) {
+ int port = -1;
+ int rc;
+
+ if (virSocketAddrParse(&def->forwarders[i].addr,
+ addr, AF_UNSPEC) < 0) {
+ virReportError(VIR_ERR_XML_ERROR,
+ _("Invalid forwarder IP address '%1$s' in network '%2$s'"),
+ addr, networkName);
+ return -1;
+ }
+
+ if ((rc = virXMLPropInt(fwdNodes[i], "port", 10,
+ VIR_XML_PROP_NONZERO |
+ VIR_XML_PROP_NONNEGATIVE,
+ &port, -1)) < 0) {
+ return -1;
+ } else if (rc > 0) {
+ if (port > 65535) {
+ virReportError(VIR_ERR_INVALID_ARG,
+ _("port '%1$d' out of range"), port);
+ return -1;
+ }
+
+ virSocketAddrSetPort(&def->forwarders[i].addr, port);
+ }
}
def->forwarders[i].domain = virXMLPropString(fwdNodes[i], "domain");
if (!(addr || def->forwarders[i].domain)) {
}
if (VIR_SOCKET_ADDR_VALID(&def->forwarders[i].addr)) {
g_autofree char *addr = virSocketAddrFormat(&def->forwarders[i].addr);
+ int port = virSocketAddrGetPort(&def->forwarders[i].addr);
if (!addr)
return -1;
virBufferAsprintf(buf, " addr='%s'", addr);
+
+ if (port > 0)
+ virBufferAsprintf(buf, " port='%d'", port);
}
virBufferAddLit(buf, "/>\n");
}