Console9

How to Find a Domain IP Address with dig

Use dig with the +short option to find the IPv4 or IPv6 address of any domain from the command line.

Find the IP address of any domain name from the command line using Domain Information Groper (dig).

Prerequisites

  • A Linux, macOS, or Windows (WSL) system with terminal access.
  • The dig command installed. On Debian/Ubuntu, install it with sudo apt install dnsutils. On RHEL/CentOS/Fedora, install it with sudo dnf install bind-utils.
  • An active internet connection to reach DNS servers.

Step-by-Step: Find a Domain IP Address with dig

  1. Open a terminal and run dig with the domain name. dig queries the A record by default and returns the IPv4 address in the ANSWER section:
dig example.com

dig returns the full response with all sections. The IPv4 address appears in the ANSWER section next to the A record.

  1. Append +short to display the IP address without metadata. dig outputs the IPv4 address on a single line:
dig example.com +short
93.184.216.34

Dig command with short option, IP address highlighted

  1. Find the IPv6 address of a domain by querying the AAAA record type. dig returns the 128-bit IPv6 address when AAAA records exist:
dig example.com AAAA +short
2606:2800:21f:cb07:6820:80da:af6b:8b2c
  1. Query a specific DNS server to check how a particular resolver responds. dig sends the query to Google Public DNS (8.8.8.8) when the @ argument is specified:
dig @8.8.8.8 example.com +short

How to Verify the IP Address Lookup Was Successful

Domain Information Groper (dig) confirms a successful lookup when the +short output returns one or more IP addresses. An empty response means no A or AAAA record exists for the domain. Run dig without +short and check for status: NOERROR in the HEADER section to confirm the domain exists in DNS.

Common Issues When Finding a Domain IP with dig

  • Empty output with +short: The domain has no A record. Try querying the AAAA record type with dig example.com AAAA +short for an IPv6 address. Also confirm the domain name is spelled correctly.
  • Multiple IP addresses returned: The domain uses DNS round-robin load balancing. Each IP address is a valid endpoint for the domain.
  • Different IP addresses from different DNS servers: DNS caching and geographic load balancing can cause different resolvers to return different addresses. Query the authoritative nameserver directly for the canonical answer: dig @ns1.example.com example.com +short.