I am trying to get the DNS Server IP Addresses using python. To do this in Windows command prompt, I would use
ipconfig -all
As shown below:

I want to do the exact same thing using a python script. Is there any way to extract these values? I was successful in extracting the IP address of my device, but DNS Server IP is proving to be more challenging.
DNS Python (dnspython) might be helpful. You can get the DNS server address with:
import dns.resolver
dns_resolver = dns.resolver.Resolver()
dns_resolver.nameservers[0]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With