简体   繁体   中英

Can NodeJS prefer IPv6 DNS lookups by default?

I am developing multiple TypeScript (NodeJS 14) client applications (all Dockerized). Most of the HTTP requests are made using axios , but not exclusively.

By default, all DNS queries resolve to IPv4 addresses, so all HTTP traffic is over IPv4 as well.

I could specify the exact IPv6 address for each and every one of the requests I make - but I'd like to find a way to have these apps opt for IPv6 DNS resolution, preferably with as little code changes as possible. Maybe a tsnode.json modification or some other flag that affects NodeJS at the "root" level?

Pretty sure You are looking for dns.setDefaultResultOrder(order) which allows you to set dns lookup priority: ipv4first and verbatim .

https://nodejs.org/api/dns.html#dnssetdefaultresultorderorder

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM