[go: up one dir, main page]

0% found this document useful (0 votes)
136 views3 pages

About Sysctl and Keepalive

The document discusses configuring TCP keepalive settings on Linux to keep connections alive even without data exchange. It recommends setting net.ipv4.tcp_keepalive_time to 60 seconds, net.ipv4.tcp_keepalive_intvl to 5 seconds, and net.ipv4.tcp_keepalive_probes to 6 in /etc/sysctl.conf. After editing the file, rebooting Linux will load the new keepalive settings. Keepalives help ensure connections remain open and allow reconnecting faster if the link is interrupted.

Uploaded by

Kavin Cavin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
136 views3 pages

About Sysctl and Keepalive

The document discusses configuring TCP keepalive settings on Linux to keep connections alive even without data exchange. It recommends setting net.ipv4.tcp_keepalive_time to 60 seconds, net.ipv4.tcp_keepalive_intvl to 5 seconds, and net.ipv4.tcp_keepalive_probes to 6 in /etc/sysctl.conf. After editing the file, rebooting Linux will load the new keepalive settings. Keepalives help ensure connections remain open and allow reconnecting faster if the link is interrupted.

Uploaded by

Kavin Cavin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 3

Sysctl Command Examples

Linux kernel parameter can be changed on the fly using sysctl command. Sysctl helps to configure
the Linux kernel parameters during runtime.
# sysctl a

Modify Kernel parameter in /etc/sysctl.conf for permanent change


After modifying the kernel parameter in the /etc/sysctl.conf, execute sysctl p to commit the changes.
The changes will still be there after the reboot.

# vi /etc/sysctl.conf

# sysctl p

Modify kernel parameter temporarily


To temporarily modify a kernel parameter, execute the following command. Please note that after
reboot these changes will be lost.

# sysctl w {variable-name=value}

Configuring Linux TCP Keepalive


In certain circumstances, it is important that Gateways using TCP/IP socket communications periodically send TCP
messages even if they have nothing to say. These null messages called keepalive packets and help inform
networking infrastructure that the endpoints are still there, connected, and expect the TCP/IP socket to stay
connected even though at the moment, they dont have any data to exchange.
By default, most Linux computers disable keepalive packets beccuase they do add some additional loading to the
network. The network load is very minimal, and this article describes how to enable keepalive packets, and how to
configure gateway to use keepalive packets on a case-by-case basis.
These are the steps to enable keepalive packets on a Gateway:
1. Configure the keepalive parameters within Linux in sysctl.conf
2. Configure the various device designators to use, or not use, keepalive packets
3. Reboot Linux for your new settings to take place.

Linux Keepalive Packets


One most Linux distributions, the file /etc/sysctl.conf contains the keepalive settings. Using your favorite text editor
(we use nano), edit this file to set the three keepalive parameters to your desired keepalive intervals. The best values
to use will depend upon your network, but because keepalive traffic is so infrequent and the packets small, we
recommend a fairly short keepalive interval.
In the file /etc/sysctl.conf there are three parameters related to keepalive:
net.ipv4.tcp_keepalive_time
net.ipv4.tcp_keepalive_intvl
net.ipv4.tcp_keepalive_probes
The net.ipv4.tcp_keepalive_timeparameter is the time before the first keepalive packet is sent out. As long as there
is TCP/IP socket communications going on, no keepalive packets are needed, but if the amount of time in seconds
specified in net.ipv4.tcp_keepalive_timepasses without any communication on a TCP/IP socket connection, then the
Linux OS will begin sending keepalive packets.
Once keepalive packets begin being sent out, they will be sent every net.ipv4.tcp_keepalive_intvl time (in seconds).
Keepalive packets are a two-way exchange. When one device sends a keepalive packet to another, the
receiving device sends a quick acknowledgement packet back. This way, both devices know the communication link
between them is OK. If the device sending the keepalive packet does not get a response back, it sends another
keepalive packet after thenet.ipv4.tcp_keepalive_intvl passes. After enough keepalive packets are sent and no
response is received, the sending device will assume the link is down, close the socket, and try to re-establish
communications. The number of keepalive packets sent before the device will reset if it does not get a response is
configured in the net.ipv4.tcp_keepalive_probesparameter.

Configuring Linux Keepalive Settings


From the Linux command line, use your favorite text editor to open up the file /etc/sysctl.conf, and edit the setting to
meet your infrastructure needs. The net.ipv4.tcp_keepalive_xxxx paramters may or may not be in the sysctl.conf file.
If they rae not, add them. Make sure there is not a hash ( # ) on the line because that designates a comment.
Raveon recommends these settings for a typical Cigorn Gateway configuration:
$ sudo nano /etc/sysctl.conf

net.ipv4.tcp_keepalive_time = 60
net.ipv4.tcp_keepalive_intvl = 5
net.ipv4.tcp_keepalive_probes = 6
The above settings will cause keepalive packets to be sent every minute. If a response it not receive it will resend
the keepalive packet every 5 seconds. After 30 seconds, it will reset the socket connection if 6 keepalives fail to get
through. This allows a cable to be disconnected and reconnected for up to 30 seconds without dropping the
connection, but it will also re-connect in less than 2 minutes if a device reboots or shuts down without properly closing
the TCP/IP socket.

Reboot Linux
From the console on the local machine, or from a remote login SSH session, issue the following Linux command to
shut down the Linux machine, and restart it:
$ shutdown -r now
Your new keepalive settings will be loaded, and Cigorn will restart.
To view the current keepalive settings, use the config command from the Cigorn command-line interface.

You might also like