Flash Sale:75% Off Hosting + Free DomainEnds in13h47m14sView Plans
Hostvento logoHostvento

Understanding TTL Values and How to Choose the Right One

Learn what TTL means for DNS and for network packets, how to check it and which value to use.

Domains and DNS3 min read6 steps3 screenshots

What is TTL

TTL stands for Time To Live. It has two meanings:

  1. In DNS, TTL tells resolvers how many seconds they may keep a record in cache. After that they must ask again.
  2. In IP networks, TTL is a number in each packet that goes down by one at every router (hop). When it reaches 0 the packet is dropped. This stops packets from looping forever.

TTL in Linux networks

ping: see the TTL in the replies

ping www.google.com
Pinging a website to see the TTL

Each reply shows ttl=.... A packet starts with a value such as 64 (Linux), 128 (Windows) or 255 (network devices). The number you see is what is left after the hops. This also hints at the operating system of the remote host.

traceroute: see each hop

traceroute www.google.com
Tracing the route and the hops

traceroute sends packets with TTL 1, 2, 3 and so on. Each router that drops a packet sends back a message, so you see the whole path.

Default TTL on your system

cat /proc/sys/net/ipv4/ip_default_ttl

ip route show

ip route show
The routing table

It shows the routes your packets use.

When to change a TTL value

DNS caching

A short DNS TTL means changes (like a new IP) spread fast, but there are more DNS queries. A long TTL means fewer queries and faster lookups, but changes spread slowly.

Network security and troubleshooting

You can use low TTL values in traceroute to find where a connection fails. Some firewalls and tools also look at the TTL of packets.

Tuning applications

Proxies and CDNs often use TTL to decide how long cached content stays fresh. Choose a value that balances freshness against load.

How to choose the right DNS TTL

SituationSuggested TTL
Before you move a site or change an IP300 s (5 minutes)
Normal websites3600 s (1 hour)
Rarely changing records (MX, NS, TXT)14400 to 86400 s (4 to 24 hours)
Failover or load balancing records60 to 300 s

Steps for a safe migration:

  1. A day or two before the change, lower the TTL to 300.
  2. Wait until the old TTL has passed.
  3. Change the record.
  4. When all works, set the TTL back to a high value.

Check a DNS TTL

dig example.com A

The number in the answer section is the remaining TTL in seconds.

Quick recap

  • DNS TTL is how long a record stays in cache. Lower it before changes.
  • Packet TTL counts hops and stops loops.