Home/Blog/How can I trace the geographic origin of an email?
Cybersecurity

How can I trace the geographic origin of an email?

Learn the techniques for determining where an email originated geographically, including IP address analysis, WHOIS lookups, and header investigation methods.

By Inventive HQ Team
How can I trace the geographic origin of an email?

Understanding Email Geolocation

When investigating suspicious emails, phishing attempts, or potential security incidents, one of the first questions IT professionals ask is: "Where did this email come from geographically?" While email addresses and domain names can be spoofed relatively easily, the physical location where the email server is located or where the user connected from is much harder to fake. By tracing an email's geographic origin, you can identify inconsistencies (an executive claiming to be on vacation in Japan but email coming from Nigeria), detect compromised accounts, and spot botnet activity.

However, determining geographic origin isn't as simple as looking at the From: address. Email routing involves complex paths through multiple servers, and tracing a message back to its actual point of origin requires understanding email infrastructure, DNS, IP addresses, and how to analyze header information. This guide walks you through the techniques security professionals use to determine where emails really come from.

The Foundation: IP Address Analysis

Every mail server connected to the internet has an IP address, and these IP addresses can be traced to geographic regions. The Received headers in an email contain IP addresses of mail servers that processed the message. By identifying these IP addresses and mapping them to locations, you can determine where the email originated.

Extracting IP Addresses from Headers

The Received headers are the key to finding IP addresses. A typical Received header looks like:

Received: from mail.company.com (mail.company.com [203.0.113.45])
    by mail.receiver.com with SMTP id 12345abcde
    for [email protected]; Wed, 1 Jan 2025 10:00:00 -0500

The IP address in brackets [203.0.113.45] is what you're looking for. This is the IP address of the sending mail server.

For email tracing purposes, focus on the bottom-most Received header (the one that appears last in the chain). This represents where the email originated. Reading from bottom to top, you can trace the email's path:

  1. Bottom Received header: The originating mail server's IP
  2. Middle Received headers: Intermediate mail servers the message passed through
  3. Top Received header: Your receiving mail server

The X-Originating-IP header is also useful—this header contains the IP address of the user's device/mail client that initially sent the message, though it's sometimes omitted or spoofed by attackers.

IP Geolocation Services

Once you have an IP address, you need to determine its geographic location. Multiple services provide IP geolocation data:

MaxMind GeoIP2: One of the most accurate IP geolocation databases. MaxMind maintains comprehensive databases mapping IP addresses to countries, cities, and even coordinates.

IP2Location: Another popular database providing country, city, latitude, longitude, ISP, and other details.

Google Maps API: Offers geolocation capabilities if you already know addresses or coordinates.

WHOIS Lookups: Query public databases to find who owns an IP address and what region they're in.

GeoIP tools: Free online services like IP lookup tools let you paste an IP and get location information.

Understanding IP Location Accuracy

Important caveat: IP geolocation is not 100% accurate. Different databases may show slightly different locations for the same IP. Accuracy varies:

  • Country level: Usually 99% accurate
  • City level: 75-90% accurate depending on the database
  • Specific coordinates: Can be off by miles or kilometers

Additionally, many organizations use:

  • VPNs: Hide true location, show the VPN provider's location instead
  • Proxies: Route traffic through different countries
  • Content delivery networks: Use servers in multiple countries
  • Residential proxies: Route traffic through consumer internet connections
  • Datacenter IPs: Might not represent actual user location

So if you trace an email to a major datacenter IP, the actual sender could be anywhere in the world.

Advanced Header Analysis for Location Determination

The Received Header Chain Analysis

By examining all Received headers together, you can build a complete picture of the message's journey:

Received: from mail.receiver.com (mail.receiver.com [198.51.100.50])
    by mail.archive.com with SMTP
    ; Wed, 1 Jan 2025 10:05:00 -0500

Received: from mail.company.com (mail.company.com [203.0.113.45])
    by mail.receiver.com with SMTP
    ; Wed, 1 Jan 2025 10:00:00 -0500

Received: from user-computer.corp (user-computer.corp [192.0.2.75])
    by mail.company.com with SMTP
    ; Wed, 1 Jan 2025 09:55:00 -0500

This chain tells the story:

  1. Email originated from 192.0.2.75 (user's computer)
  2. Sent to 203.0.113.45 (company's mail server)
  3. Forwarded to 198.51.100.50 (recipient's mail server)

If you geolocate these IPs, you can see if the path makes sense. If an employee's computer IP is in New York, the company mail server should be in a location consistent with company location, and the recipient's location should be consistent with their stated location.

Timestamp Analysis Combined with Geolocation

Timestamps in Received headers can be combined with geolocation data to identify suspicious patterns:

Example: An email claims to be from your CEO in New York office, but:

  • X-Originating-IP shows 203.0.113.100 (geolocates to Dubai)
  • Received timestamp shows 3 AM New York time
  • The CEO's email signature says they're in New York office

This combination suggests either a compromised account or someone spoofing the account from Dubai.

Analyzing Mail Server Configuration

Sometimes the mail server address itself provides information. Looking at the Received header:

Received: from mail.company.com (mail.company.com [203.0.113.45])

The domain "mail.company.com" tells you this is company.com's mail server. You can reverse-DNS this IP to confirm:

  • Does the reverse DNS match the forward DNS?
  • Does the domain match what's expected?
  • Are there any mismatches suggesting spoofing?

WHOIS and DNS Analysis for Geographic Information

WHOIS Lookups

WHOIS databases contain registration information for IP address blocks. By querying WHOIS:

whois 203.0.113.45

You get information about:

  • IP block owner: Company or ISP name
  • Country of registration: Where the IP block is registered
  • Regional registry: ARIN (North America), RIPE (Europe), APNIC (Asia-Pacific), LACNIC (Latin America), AFRINIC (Africa)
  • Contact information: Sometimes useful for verification
  • Abuse contact: For reporting suspicious activity

DNS Reverse Lookup

Reverse DNS lookup converts an IP address to its hostname:

nslookup 203.0.113.45

This might return something like:

45.113.0.203.in-addr.arpa = mail.company.com

The hostname sometimes reveals information about the sending organization or location. Corporate mail servers typically have corporate domain names. ISP mail servers show ISP names. Datacenter IPs might show datacenter names.

SPF and MX Record Analysis

Looking at DNS records for the domain can provide geographic hints:

MX Records: Point to the organization's mail servers. If you query:

nslookup -type=MX company.com

You see which mail servers handle email for that domain. You can then geolocate those mail server IPs to understand where the organization's mail infrastructure is located.

SPF Records: Sometimes list IP addresses with geographic information in comments.

Real-World Tracing Scenarios

Scenario 1: Phishing Email Originating from Different Country

You receive a phishing email claiming to be from your bank:

  1. Extract IP from Received header: 198.51.100.200
  2. Geolocate IP: Located in Nigeria (suspicious if bank is US-based)
  3. WHOIS lookup: Registered to small ISP in Lagos, Nigeria
  4. Reverse DNS: No clear hostname, just generic ISP name
  5. Conclusion: Very likely phishing. Bank wouldn't send emails from Nigerian ISPs.

Scenario 2: Employee Email from VPN While Traveling

Your CFO is supposed to be at headquarters in Boston but you see:

  1. Email from [email protected]
  2. X-Originating-IP: 45.142.100.50
  3. Geolocate: Located in Bangkok, Thailand
  4. WHOIS: Shows VPN provider in Thailand
  5. Check executive schedule: CFO mentioned visiting Thailand for a conference
  6. Conclusion: Legitimate, employee is using VPN while traveling.

Scenario 3: Suspicious Activity from Unusual Location

Regular developer from San Francisco sends email:

  1. Email from [email protected]
  2. Received header IP: 203.0.113.100
  3. Geolocate: Located in Bucharest, Romania
  4. This developer typically sends from San Francisco (ISP IP 198.51.100.x)
  5. Conclusion: Potential account compromise. Investigate immediately.

Tools and Resources for Email Geolocation

Free Tools

WHOIS.net: Simple WHOIS lookup interface. Paste IP, see owner and location.

MaxMind GeoIP2 Lite: Free but less accurate version of MaxMind's commercial service.

IP2Location.io: Offers free lookups with decent accuracy.

DNS Lookup Tools: Tools like MXToolbox provide DNS, reverse DNS, and geolocation lookups.

Email Header Analyzer: Specialized tools that parse headers and automatically geolocate IPs, showing routing paths visually.

Paid Services

MaxMind GeoIP2 Enterprise: Most accurate commercial IP geolocation database, frequently updated.

Google Maps API: For visualizing locations on maps.

Splunk, ELK Stack: For large-scale analysis of email logs.

Challenges and Limitations

VPN and Proxy Obscuration

Modern adversaries often use VPNs, proxies, or compromised hosts to send emails from different locations than their real location. VPN exit nodes often route through datacenters that don't match the attacker's actual location.

Mitigation: Look for multiple indicators beyond just IP geolocation. Consider:

  • Behavioral patterns
  • Time zone of activity
  • Compromised account signals
  • Content analysis

Datacenter IP Addresses

Many email services (Gmail, Office365, etc.) send from datacenter IP addresses located in major tech hubs regardless of user location. You can't geolocate a Gmail user by their server IP—Gmail users in Japan might route through Virginia datacenters.

Mitigation: Understand common mail provider locations. Cross-reference with SPF records to see if the mail server is expected from that provider.

DNS Information Lag

DNS and geolocation data updates can lag by hours or days. An IP recently assigned to a new location might still show old location information in some databases.

Mitigation: Use multiple databases for cross-verification.

Best Practices for Email Geolocation Investigation

  1. Start with the originating IP: The lowest Received header's IP is most important
  2. Use multiple geolocation services: Cross-check results
  3. Verify with WHOIS: Confirm IP block owner and registration location
  4. Analyze the full header chain: Understand the complete routing path
  5. Combine with other indicators: Geolocation alone isn't conclusive
  6. Consider legitimate explanations: VPNs, traveling employees, forwarding services
  7. Check against baseline: Compare to normal sending patterns for the user
  8. Look for patterns: Single unusual location might be false positive; repeated pattern is suspicious

Conclusion

Tracing the geographic origin of emails involves multiple techniques: extracting and geolocating IP addresses from Received headers, analyzing the header chain for routing information, performing WHOIS and reverse DNS lookups, and cross-referencing with email authentication results. While not foolproof (especially against sophisticated attackers using VPNs or compromised hosts), geographic analysis provides valuable threat intelligence when combined with other investigation techniques.

Organizations that develop expertise in email geolocation can quickly identify suspicious emails originating from unexpected locations, detect account compromises, and stop geographically targeted attacks before they cause damage. The combination of automated tools and human expertise in header analysis makes email geolocation one of the most effective detective controls available to security professionals.

Need Expert Cybersecurity Guidance?

Our team of security experts is ready to help protect your business from evolving threats.