MeshWorld India Logo MeshWorld.
Linux Networking DNS Commands Ubuntu 26.04 6 min read

Find IP Address of Any Website Using Linux Commands

Jena
By Jena
| Updated: Apr 26, 2026
Find IP Address of Any Website Using Linux Commands

DNS translates human-readable domain names into IP addresses that computers use to communicate. Whether you’re troubleshooting connectivity, verifying DNS propagation, or simply curious about a website’s infrastructure, Linux provides powerful command-line tools for DNS resolution.

[!TIP] Real-World Scenario: Your application suddenly can’t reach api.example.com. Is it a DNS issue or is the server down? A quick dig command reveals whether the domain resolves and which IP addresses are returned, narrowing your troubleshooting scope immediately.

- `dig example.com` — comprehensive DNS lookup with detailed response - `host example.com` — simple IP address output - `nslookup example.com` — interactive DNS query tool - `ping -c 1 example.com` — resolve and test connectivity - All tools included in Ubuntu 26.04 base installation

How do I use dig to find a website’s IP address?

dig (Domain Information Groper) is the most comprehensive DNS lookup tool, providing detailed query and response information that network administrators rely on.

Basic DNS lookup

dig example.com

Sample output:

; <<>> DiG 9.18.18 <<>> example.com
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 12345
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;example.com.		IN	A

;; ANSWER SECTION:
example.com.		86400	IN	A	93.184.216.34

;; Query time: 52 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Sun Apr 26 09:30:45 UTC 2026

The ANSWER SECTION contains the A record with the IPv4 address (93.184.216.34).

Dig query options

# Short answer only (just the IP)
dig +short example.com

# Query specific DNS server
dig @8.8.8.8 example.com

# Get IPv6 address (AAAA record)
dig example.com AAAA

# Get all record types
dig example.com ANY

# Trace the full resolution path
dig +trace example.com

# Reverse DNS lookup (IP to domain)
dig -x 93.184.216.34

Understanding dig output sections

SectionPurpose
QUESTION SECTIONShows what was queried
ANSWER SECTIONContains the DNS records
AUTHORITY SECTIONLists authoritative name servers
ADDITIONAL SECTIONExtra records (e.g., name server IPs)
Query timeHow long the lookup took

How do I use host for simple IP lookups?

host provides cleaner output than dig when you just need the IP address without extra detail.

Basic host lookup

host example.com

Output:

example.com has address 93.184.216.34
example.com has IPv6 address 2606:2800:220:1:248:1893:25c8:1946
example.com mail is handled by 0 .

Host command options

# IPv4 only
host -4 example.com

# IPv6 only
host -6 example.com

# Specific record type
host -t MX example.com        # Mail servers
host -t NS example.com        # Name servers
host -t TXT example.com       # Text records (SPF, DKIM)

# Use specific DNS server
host example.com 1.1.1.1

How do I use nslookup for DNS queries?

nslookup offers interactive and non-interactive modes for DNS investigation.

Non-interactive usage

nslookup example.com

Output:

Server:		127.0.0.53
Address:	127.0.0.53#53

Non-authoritative answer:
Name:	example.com
Address: 93.184.216.34

Interactive mode

nslookup
> server 8.8.8.8          # Switch to Google's DNS
> set type=MX           # Query mail records
> example.com           # Query domain
> exit                  # Quit

Query specific record types

# Mail exchanger records
nslookup -query=MX example.com

# Name servers
nslookup -query=NS example.com

# Start of Authority (SOA)
nslookup -query=SOA example.com

Syntax for host command

host <websiteURL>

How do I verify connectivity after finding the IP?

After resolving a domain, verify the host is reachable:

# Ping test (4 packets)
ping -c 4 example.com

# Or ping the IP directly
ping -c 4 93.184.216.34

# Check routing path
traceroute example.com

# Port connectivity test (HTTP)
curl -I http://example.com

Summary

CommandBest ForOutput Style
digDetailed troubleshootingVerbose, complete DNS data
hostQuick IP lookupClean, human-readable
nslookupInteractive explorationFlexible record queries
pingConnectivity + resolutionSimple reachability test
  • Use dig +short for scripting (parsable output)
  • Use host for quick manual lookups
  • Use nslookup when exploring different record types
  • All tools are pre-installed on Ubuntu 26.04 Desktop and Server

FAQ

Why does dig show different IPs than host? Both tools query the same DNS system but may use different default name servers or caching. Specify the same server with @server (dig) or trailing argument (host) for consistent results.

Can I find a website’s IP if DNS is down? No. DNS resolution requires functioning name servers. If DNS fails, you need alternative methods like checking /etc/hosts, browser cache, or cached records from previous lookups.

What is the difference between A and AAAA records?

  • A records contain IPv4 addresses (e.g., 93.184.216.34)
  • AAAA records contain IPv6 addresses (e.g., 2606:2800:220:1:248:1893:25c8:1946) Modern dual-stack systems support both.

How do I find my own public IP address?

# Query external service
curl -s ifconfig.me
# Or:
dig +short myip.opendns.com @resolver1.opendns.com

Why does the same domain return multiple IPs? Load balancing and CDN distribution. Multiple A records distribute traffic across servers. Each query may return a different IP from the pool.