How to change ttl on linux

Good afternoon, dear blog readers, today I want to ask you, can you use the ping command to determine which device or operating system is responding to you? If not, then you have come to the right place and I will tell you another purpose of the ping utility. I think this material will be useful for both beginners and advanced users, especially when you are looking for the cause of a malfunction in a network or service, I have seen many times that you think that one server is answering you, but in fact it is another, because someone , I changed something and didn’t document it.

How to Permanently Change a Package Time to Live (TTL) in Ubuntu

The article on packet lifetime provided an example of changing the TTL in Windows.
Today we’ll talk about how to change the default TTL value in Ubuntu-like Linux distributions. The main nuance here is this: changing the TTL value is easy, but you also need to save it. In order to check the lifetime of packages in Linux, it is enough to also run ping localhost. By default on Linux TTL=64. To change this value in Ubuntu and other similar distributions, use the command. Of course, you can specify a value other than 65. In the screenshot below you can see that the ping command now displays TTL=65.

However, the TTL setting will reset after a reboot. To prevent this from happening, you need to add this setting to startup. This setting is performed under the root user.

Remember that you cannot work as the root user all the time. Use it only for system configuration.

We need to create a file in the /etc/sysctl.d directory, I named it 99_default_ttl.conf, but it doesn't have to be exactly that. To create a file, I use the cat command that is convenient for me (you can read more about commands for creating files in Linux at this link):

After pressing enter, the data from standard input (i.e. from the keyboard) will be redirected to the file /etc/sysctl.d/99_default_ttl.conf. Enter the setting we need, namely:

and press enter. The combinations Ctrl + D or Ctrl + C will write the changes to the file. Then we apply the settings with the command

The screenshot below shows the entire process described here.

As you can see, the TTL value in the ping command has also changed. And this setting will be saved after a reboot.

Source

Artyom Sannikov

Most modern mobile operators, such as MTS and Yota, provide tariffs that allow you to use the Internet without traffic restrictions. Everything seems to be good and convenient. But if we consider this issue in more detail, then everything will not be so good.

Initially, the terms of the tariff are as follows: you can use the Internet at any time of the day and without traffic restrictions, but for distributing an Internet connection via Wi-Fi, USB modem or Bluetooth, you will be charged a subscription fee of N rubles.

PS: I use the services of the MTS operator, and for distributing the Internet they used to charge 30 rubles per day, but now they charge 50 rubles.

But what if you need to distribute the Internet via Wi-Fi, but there is no extra money on your balance? Everything is very simple! you need to fix the TTL value of the file to a certain value in the operating system: Linux, Windows or Mac OS.

PSS: this article is for informational purposes only; I do not encourage anyone to use this information for practical purposes.

Changing TTL value in Ubuntu operating system

To bypass the restriction on distributing the Internet through your phone to a computer with Ubuntu on board, if your operator is Iota, you must do a few simple things.

1. Open the terminal using the key combination Ctrl+Alt+T.

2. Enter the following command from the super user:

sudo vi /etc/init.d/local.autostart

Press Enter.

3. The system will require you to enter a password for the administrator account, enter it and press Enter. Next, press the i button - this will tell the vi editor to go into editing mode.

4. Now we must enter a script taking into account the features of the operating system of your smartphone. If you have Android or iOS, you need to specify the value TTL=65 (instead of 64), and if Windows, then specify TTL=129 (instead of 128).

Why is the value 1 greater? It's very simple, the TTL value on the computer should be 1 greater than the TTL value on the phone from which you are distributing.

Script to bypass internet sharing restrictions for Android and iOS:

#!/bin/bash sudo iptables -t mangle -A POSTROUTING -j TTL —ttl-set 65

Script to bypass restrictions on Internet distribution for Windows Phone:

#!/bin/bash sudo iptables -t mangle -A POSTROUTING -j TTL —ttl-set 129

5. To complete editing, press Esc. Then save the changes made by pressing the keys: Shift+ZZ (press Z twice).

6. Assign the script permissions to run:

sudo chmod +x /etc/init.d/local.autostart

Press Enter.

7. Add the script to autorun:

sudo update-rc.d local.autostart defaults 80

8. Press Enter.

All is ready! We successfully fixed the TTL value in the Ubuntu operating system, and bypassed the restriction of mobile operators: MTS and Yota, on distributing an Internet connection via Wi-Fi, USB modem and Bluetooth.

Best regards, Artyom Sannikov

Website:

Tags : Ubuntu, Guides.

How to permanently change TTL in Ubuntu?

I tried to do it like this, but alas, after a reboot ttl=64.

I tried this:

Normal distros have /etc/sysctl.conf, I don’t know how it is in Ubuntu.

Oh yeah, sorry. This is a temporary installation.

The best option is probably to create a file, something like /etc/sysctl.d/99_default_ttl.conf, to which add net.ipv4.ip_default_ttl=65. Then sudo sysctl –system.

Thank you, this helped =)

This is in all distros

Is this linux? I’ll bring the conclusion from Solara now.

Wow, in Ghent the /etc/sysctl.conf file is considered legacy. Are the configs in /etc/sysctl.d/ considered a modern approach?

I don't know why you do this, but here it is:

Clearly, the reason is this:

saved a life

Rating
( 1 rating, average 5 out of 5 )
Did you like the article? Share with friends:
For any suggestions regarding the site: [email protected]
Для любых предложений по сайту: [email protected]