TCP TTL Linux Kernel Setting

How to display and modify the TCP TTL kernel setting on Linux

Time to Live (TTL)

Simply the maximum number of hops a packet may travel.

The TTL can also be specified on a per destination network basis.

You can check the current setting like so:

$ sysctl net.ipv4.ip_default_ttl
net.ipv4.ip_default_ttl = 64

Dynamic Configuration

To change the running configuration, use this command with your desired value:

$ sysctl -w net.ipv4.ip_default_ttl=NN

You can confirm like so:

$ sysctl net.ipv4.ip_default_ttl

Permanent Configuration

To make this setting persistent across reboots, edit the /etc/sysctl.conf file like so, save and quit:

$ vi /etc/sysctl.conf

net.ipv4.ip_default_ttl = NN

:wq

You can then reboot to check the setting persists, or alternatively, run this command to load them:

$ sysctl -p /etc/sysctl.conf

Confirm with this:

$ sysctl net.ipv4.ip_default_ttl