fetch_ip_using_dns

getmac.utils.fetch_ip_using_dns()[source]

Determine the IP address of the default network interface.

Sends a UDP packet to Cloudflare’s DNS (1.1.1.1), which should go through the default interface. This populates the source address of the socket, which we then inspect and return.

Return type:

str

Returns:

IP address of this system’s default network interface as a string