3

I am trying to set static local ip on ubuntu 20.04 server by disabling cloud-init, then set my 50-cloud-init.yaml

This is on a Raspberry Pi 4 with wired connection.

network:
    ethernets:
        eth0:
            addresses: [192.168.1.11/24]
            dhcp4: false
            gateway4: 192.168.1.1
            nameservers:
                addresses: [8.8.8.8, 8.8.4.4]
    version: 2

executed netplan generate and then netplan try. It works, and successfully set static local IP.

However, this causes "sleeps". When i ssh to it, then leave it for a moment, input would take seconds to respond again. This is not only on SSH, i also ran a TCP server and same thing happens, it seems to sleep if left for a while.

It only happens after setting static ip.

Can anyone suggest what is going on?

intika
  • 13,920
  • 7
  • 41
  • 79
user3414321
  • 93
  • 1
  • 7
  • 2
    Did you run `netplan apply`? – Panki Jul 01 '20 at 10:08
  • @Panki yeah, but it still happens – user3414321 Jul 01 '20 at 12:33
  • Could be related to having arp cache entries cleared in either end (or somewhere in the middle) of the connection. But doesn't answer why they then would take so long to re-establish. I'd look carefully at the filrewall rules of the devices concerned. – Juha Laiho Jul 05 '20 at 08:45

2 Answers2

2

Linux has built-in support for keepalive. you can change setup it with sysctl to be able to configure the kernel parameters at runtime.

The procedures involving keepalive use three user-driven variables:

tcp_keepalive_time: the interval between the last data packet sent (simple ACKs are not considered data) and the first keepalive probe; after the connection is marked to need keepalive, this counter is not used any further

tcp_keepalive_intvl: the interval between subsequential keepalive probes, regardless of what the connection has exchanged in the meantime

tcp_keepalive_probes: the number of unacknowledged probes to send before considering the connection dead and notifying the application layer

You can try to change those value with:

echo 600 > /proc/sys/net/ipv4/tcp_keepalive_time
echo 60 > /proc/sys/net/ipv4/tcp_keepalive_intvl
echo 20 > /proc/sys/net/ipv4/tcp_keepalive_probes

If this solve your issue you can make the change permanent on /etc/sysctl.conf with:

net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_intvl = 60
net.ipv4.tcp_keepalive_probes = 20
intika
  • 13,920
  • 7
  • 41
  • 79
1

I accidentally found the probable cause of issue, I tried to install netsniff-ng and somehow its installation removed the lagging, and the only notable change was that Systemd-timesyncd was removed, i am investigating how this is related to my network problem.

user3414321
  • 93
  • 1
  • 7