mirror of
https://github.com/espressif/openthread.git
synced 2026-07-31 16:17:47 +00:00
[nat64] support using IPv4 DNS server addresses in CLI (#8212)
Similar to TCP/UDP/PING commands, this command will print "Synthesized IPv6 DNS server address:" when an IPv4 address is received.
This commit is contained in:
@@ -1063,6 +1063,17 @@ The parameters after `hostname` are optional. Any unspecified (or zero) value fo
|
||||
> DNS response for ipv6.google.com - 2a00:1450:401b:801:0:0:0:200e TTL: 300
|
||||
```
|
||||
|
||||
The DNS server IP can be an IPv4 address, which will be synthesized to an IPv6 address using the preferred NAT64 prefix from the network data.
|
||||
|
||||
> Note: The command will return `InvalidState` when the DNS server IP is an IPv4 address but the preferred NAT64 prefix is unavailable.
|
||||
|
||||
```bash
|
||||
> dns resolve example.com 8.8.8.8
|
||||
Synthesized IPv6 DNS server address: fdde:ad00:beef:2:0:0:808:808
|
||||
DNS response for example.com. - fd4c:9574:3720:2:0:0:5db8:d822 TTL:20456
|
||||
Done
|
||||
```
|
||||
|
||||
### dns browse \<service-name\> \[DNS server IP\] \[DNS server port\] \[response timeout (ms)\] \[max tx attempts\] \[recursion desired (boolean)\]
|
||||
|
||||
Send a browse (service instance enumeration) DNS query to get the list of services for given service-name.
|
||||
@@ -1085,12 +1096,16 @@ instance2
|
||||
Done
|
||||
```
|
||||
|
||||
> Note: The DNS server IP can be an IPv4 address, which will be synthesized to an IPv6 address using the preferred NAT64 prefix from the network data. The command will return `InvalidState` when the DNS server IP is an IPv4 address but the preferred NAT64 prefix is unavailable.
|
||||
|
||||
### dns service \<service-instance-label\> \<service-name\> \[DNS server IP\] \[DNS server port\] \[response timeout (ms)\] \[max tx attempts\] \[recursion desired (boolean)\]
|
||||
|
||||
Send a service instance resolution DNS query for a given service instance. Service instance label is provided first, followed by the service name (note that service instance label can contain dot '.' character).
|
||||
|
||||
The parameters after `service-name` are optional. Any unspecified (or zero) value for these optional parameters is replaced by the value from the current default config (`dns config`).
|
||||
|
||||
> Note: The DNS server IP can be an IPv4 address, which will be synthesized to an IPv6 address using the preferred NAT64 prefix from the network data. The command will return `InvalidState` when the DNS server IP is an IPv4 address but the preferred NAT64 prefix is unavailable.
|
||||
|
||||
### dns compression \[enable|disable\]
|
||||
|
||||
Enable/Disable the "DNS name compression" mode.
|
||||
|
||||
+9
-2
@@ -2945,17 +2945,24 @@ exit:
|
||||
otError Interpreter::GetDnsConfig(Arg aArgs[], otDnsQueryConfig *&aConfig)
|
||||
{
|
||||
// This method gets the optional DNS config from `aArgs[]`.
|
||||
// The format: `[server IPv6 address] [server port] [timeout]
|
||||
// The format: `[server IP address] [server port] [timeout]
|
||||
// [max tx attempt] [recursion desired]`.
|
||||
|
||||
otError error = OT_ERROR_NONE;
|
||||
bool recursionDesired;
|
||||
bool nat64SynthesizedAddress;
|
||||
|
||||
memset(aConfig, 0, sizeof(otDnsQueryConfig));
|
||||
|
||||
VerifyOrExit(!aArgs[0].IsEmpty(), aConfig = nullptr);
|
||||
|
||||
SuccessOrExit(error = aArgs[0].ParseAsIp6Address(aConfig->mServerSockAddr.mAddress));
|
||||
SuccessOrExit(error = Interpreter::ParseToIp6Address(GetInstancePtr(), aArgs[0], aConfig->mServerSockAddr.mAddress,
|
||||
nat64SynthesizedAddress));
|
||||
if (nat64SynthesizedAddress)
|
||||
{
|
||||
OutputFormat("Synthesized IPv6 DNS server address: ");
|
||||
OutputIp6AddressLine(aConfig->mServerSockAddr.mAddress);
|
||||
}
|
||||
|
||||
VerifyOrExit(!aArgs[1].IsEmpty());
|
||||
SuccessOrExit(error = aArgs[1].ParseAsUint16(aConfig->mServerSockAddr.mPort));
|
||||
|
||||
Reference in New Issue
Block a user