How to get primary and secondary DNS servers in Qt?
I have configured on a Windows machine primary DNS server = 220.127.116.11 and secondary DNS server = 18.104.22.168. How can I find these addresses using Qt?
Hi and welcome to devnet,
Out of curiosity, why do you need that information ?
If you would like to query them, there’s the QDnsLookup class.
Hi, @SGaist, thanks for replying. I need to find out the IP address of the primary DNS server to pass it to another module that requires it (pjsip). I can't use public DNS servers (like 22.214.171.124) because some organizations that use the software I'm working on blocks external DNS servers. So I need to find the primary DNS server configured on the machine.
I took a look at QDnsLookup class before and it didn't help me. I imagine the only solution is to use QProcess to invoke nslookup and then parse the resulting string.
Then indeed it's outside of Qt's scope.
You may want to take a look at this stackoverflow post for platform specific solutions.