resolver.setLocalAddress([ipv4][, ipv6])


  • ipv4 <string> IPv4 地址的字符串表示形式。 默认值: '0.0.0.0'
  • ipv6 <string> IPv6 地址的字符串表示形式。 默认值: '::0'

解析器实例将从指定的 IP 地址发送其请求。 这允许程序在多宿主系统上使用时指定出站接口。

如果没有指定 v4 或 v6 地址,则设置为默认值,操作系统会自动选择本地地址。

解析器在向 IPv4域名系统服务器发出请求时将使用 v4 本地地址,在向 IPv6域名系统服务器发出请求时将使用 v6 本地地址。 解析请求的 rrtype 对使用的本地地址没有影响。

  • ipv4 <string> A string representation of an IPv4 address. Default: '0.0.0.0'
  • ipv6 <string> A string representation of an IPv6 address. Default: '::0'

The resolver instance will send its requests from the specified IP address. This allows programs to specify outbound interfaces when used on multi-homed systems.

If a v4 or v6 address is not specified, it is set to the default and the operating system will choose a local address automatically.

The resolver will use the v4 local address when making requests to IPv4 DNS servers, and the v6 local address when making requests to IPv6 DNS servers. The rrtype of resolution requests has no impact on the local address used.