How to Change TTL in Linux

Understanding and modifying a Linux system’s Time to Live (TTL) values can significantly enhance your network’s efficiency and reliability. The TTL value determines the lifespan of network packets, dictating how many hops a packet can make before being discarded. This article provides a simplified, step-by-step guide on changing the TTL settings in Linux, helping novices and seasoned users improve their system’s networking performance. Through a clearer comprehension and effective modification of TTL values, you can optimize network traffic, reducing unnecessary load and fostering a more streamlined communication flow within your network infrastructure.

What is TTL in Linux?

TTL, or Time to Live, is a vital networking concept used in Linux and other operating systems to specify the lifespan of network packets, denoted by the number of hops or nodes a packet can traverse before being discarded or returning an error. Each hop reduces the TTL value by one, and at zero, the packet is discarded with an error message sent back to the originating host. TTL’s main purpose is to prevent endless packet circulation, avoiding network congestion or loops. It helps manage network resources efficiently and ensures smoother data flow. In Linux, users can view or modify the TTL value using various networking tools and commands to achieve specific networking objectives or troubleshoot issues, such as faster network problem detection with a lower TTL or ensuring longer packet travel with a higher TTL.

Changing TTL in Linux

Changing the Time to Live (TTL) value in Linux requires a bit of knowledge in working with the terminal. Please ensure you have the necessary privileges to execute these commands. Here’s a step-by-step guide to changing the TTL value in Linux:

1. Open the Terminal. You can open the terminal by searching for “Terminal” in your system’s application menu or by pressing Ctrl + Alt + T together.

2. Check the Current TTL Value.  Execute the following command to check the current TTL value. Use this command below:

sysctl net.ipv4.ip_default_ttl

The system will return a value, which is the current TTL setting.

Sample output:

net.ipv4.ip_default_ttl = 64

3. Change the TTL Value Temporarily. To change the TTL value temporarily (which will revert back to the original value after a system reboot), use the following command, replacing NEW_TTL_VALUE with the desired TTL value:

sudo sysctl -w net.ipv4.ip_default_ttl=NEW_TTL_VALUE


sudo sysctl -w net.ipv4.ip_default_ttl=100

4. Change the TTL Value Permanently. To make a permanent change, you’ll need to modify the sysctl.conf file. Open sysctl.conf with a text editor (like nano) using the following command:

sudo nano /etc/sysctl.conf

Scroll down to the bottom of the file and add the following line, replacing NEW_TTL_VALUE with the desired TTL value:

net.ipv4.ip_default_ttl = NEW_TTL_VALUE


net.ipv4.ip_default_ttl = 100

Save and exit the editor (in nano, press Ctrl + X to close, press Y to confirm changes, and then press Enter).

5. Apply the Changes. To apply the changes immediately without rebooting, run the following command:

sudo sysctl -p

Output (if successful):

net.ipv4.ip_default_ttl = 100

6.  Verify the New TTL Value. Verify the new TTL value by running the command from step 2 again:

sysctl net.ipv4.ip_default_ttl


net.ipv4.ip_default_ttl = 100

That’s it! Now, you have successfully changed the TTL value on your Linux system. By taking control of the TTL settings, you not only gain better command over your network’s efficiency but also move a step closer to mastering the nuances of network management in a Linux environment. Keep exploring and continue enhancing your networking acumen with each change you implement. If you want to know how TTL works, refer to this article to learn more.


Looking to deploy Linux in the cloud? With Gcore Cloud, you can choose from Basic VM, Virtual Instances, or VPS/VDS suitable for Linux:

Choose an instance

Subscribe and discover the newest
updates, news, and features

We value your inbox and are committed to preventing spam