Skip to content

Instantly share code, notes, and snippets.

@GamePlayer-8
Created July 19, 2023 08:31
Show Gist options
  • Save GamePlayer-8/56a0a0d9900a58496c94904c143841f8 to your computer and use it in GitHub Desktop.
Save GamePlayer-8/56a0a0d9900a58496c94904c143841f8 to your computer and use it in GitHub Desktop.
sysctl.conf
kernel.printk = 4 4 1 7
kernel.panic = 10
kernel.sysrq = 0
kernel.shmmax = 4294967296
kernel.shmall = 4194304
kernel.core_uses_pid = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
vm.swappiness = 20
vm.dirty_ratio = 80
vm.dirty_background_ratio = 5
fs.file-max = 2097152
net.core.netdev_max_backlog = 262144
net.core.rmem_default = 31457280
net.core.rmem_max = 67108864
net.core.wmem_default = 31457280
net.core.wmem_max = 67108864
net.core.somaxconn = 65535
net.core.optmem_max = 25165824
net.ipv4.neigh.default.gc_thresh1 = 4096
net.ipv4.neigh.default.gc_thresh2 = 8192
net.ipv4.neigh.default.gc_thresh3 = 16384
net.ipv4.neigh.default.gc_interval = 5
net.ipv4.neigh.default.gc_stale_time = 120
net.netfilter.nf_conntrack_max = 10000000
net.netfilter.nf_conntrack_tcp_loose = 0
net.netfilter.nf_conntrack_tcp_timeout_established = 1800
net.netfilter.nf_conntrack_tcp_timeout_close = 10
net.netfilter.nf_conntrack_tcp_timeout_close_wait = 10
net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 20
net.netfilter.nf_conntrack_tcp_timeout_last_ack = 20
net.netfilter.nf_conntrack_tcp_timeout_syn_recv = 20
net.netfilter.nf_conntrack_tcp_timeout_syn_sent = 20
net.netfilter.nf_conntrack_tcp_timeout_time_wait = 10
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.ip_local_port_range = 1024 65000
net.ipv4.ip_no_pmtu_disc = 1
net.ipv4.route.max_size = 8048576
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv4.tcp_congestion_control = htcp
net.ipv4.tcp_mem = 65536 131072 262144
net.ipv4.udp_mem = 65536 131072 262144
net.ipv4.tcp_rmem = 4096 87380 33554432
net.ipv4.udp_rmem_min = 16384
net.ipv4.tcp_wmem = 4096 87380 33554432
net.ipv4.udp_wmem_min = 16384
net.ipv4.tcp_max_tw_buckets = 1440000
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_max_orphans = 400000
net.ipv4.tcp_window_scaling = 1
net.ipv4.tcp_rfc1337 = 1
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_synack_retries = 1
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_max_syn_backlog = 16384
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_sack = 1
net.ipv4.tcp_fack = 1
net.ipv4.tcp_ecn = 2
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_intvl = 60
net.ipv4.tcp_keepalive_probes = 10
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.ip_forward = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.all.accept_source_route = 0
net.ipv4.conf.all.rp_filter = 1
kernel.nmi_watchdog=0
net.ipv4.ping_group_range=0 2000000
net.ipv6.ping_group_range=0 2000000
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.ip_forward = 1
net.ipv6.conf.all.accept_redirects = 1
net.ipv6.conf.all.send_redirects = 1
net.ipv6.conf.all.accept_source_route = 1
net.ipv6.conf.all.rp_filter = 1
net.ipv6.tcp_slow_start_after_idle = 0
net.ipv6.ip_local_port_range = 1024 65000
net.ipv6.ip_no_pmtu_disc = 1
net.ipv6.route.max_size = 8048576
net.ipv6.icmp_echo_ignore_broadcasts = 1
net.ipv6.icmp_ignore_bogus_error_responses = 1
net.ipv6.tcp_congestion_control = htcp
net.ipv6.tcp_mem = 65536 131072 262144
net.ipv6.udp_mem = 65536 131072 262144
net.ipv6.tcp_rmem = 4096 87380 33554432
net.ipv6.udp_rmem_min = 16384
net.ipv6.tcp_wmem = 4096 87380 33554432
net.ipv6.udp_wmem_min = 16384
net.ipv6.tcp_max_tw_buckets = 1440000
net.ipv6.tcp_tw_reuse = 1
net.ipv6.tcp_max_orphans = 400000
net.ipv6.tcp_window_scaling = 1
net.ipv6.tcp_rfc1337 = 1
net.ipv6.tcp_syncookies = 1
net.ipv6.tcp_synack_retries = 1
net.ipv6.tcp_syn_retries = 2
net.ipv6.tcp_max_syn_backlog = 16384
net.ipv6.tcp_timestamps = 1
net.ipv6.tcp_sack = 1
net.ipv6.tcp_fack = 1
net.ipv6.tcp_ecn = 2
net.ipv6.tcp_fin_timeout = 10
net.ipv6.tcp_keepalive_time = 600
net.ipv6.tcp_keepalive_intvl = 60
net.ipv6.tcp_keepalive_probes = 10
net.ipv6.tcp_no_metrics_save = 1
net.ipv6.neigh.default.gc_thresh1 = 4096
net.ipv6.neigh.default.gc_thresh2 = 8192
net.ipv6.neigh.default.gc_thresh3 = 16384
net.ipv6.neigh.default.gc_interval = 5
net.ipv6.neigh.default.gc_stale_time = 120
@UrbanDesimator
Copy link

Very impressive has improve 1gb Down 100mb up cable broadband in several areas thank you for sharing. And nice to see a sysctl.conf were the linux net base rules on setting rmem wmem mem sizes has been followed. I checked all your memory settings ie, number divided by 4096 1 didn't work 87380 / 4096 = 21.3330. I've seen it used in exactly the same place as you rmem wmem, and in middle in mem. I switch it out to 98112 so it reads net.ipv4.tcp_rmem = 4096 98112 33554432 same for wmem. Linux's network stack, tables, buffers and even congestion algorithms will degrade performance and latency if the memory setting don't compute equally. This is in part down to the tables that are generated if they aren’t equal they don’t stack cleanly. My network tutor literally stacked 5 equal tables with shorted legs and 5 not equal tables, he had to support the unequal stack. Said tables had lanes marked for the different parts of the transmission which again lined up on equal stack and didn't on unequal stack.

Now the really good stuff I had run numerous tests on https://www.nperf.com/en/ but my download speed was going from 900mbps to as low as 350mbps the graph shown had 4 drops. using your sysctl.conf with the change to net.ipv4.tcp_rmem ecn to 1 as I know my isp supports it. I add net.ipv4.tcp_notsent_lowat = 131072 and net.netfilter.nf_conntrack_tcp_timeout_established = 1800. and finally tcp_congestion_control swapped to nv as I have found on wired lan to 1gbps/199mbps cable modem, this beats every algorithm for download/upload speed fast.com 1gbps 105mbps, google fiber 960mbps 104mbps, ping time between 12ms and 18ms and keeps jitter to 2ms or less. On cloudflare's speedtest I saw much higher initial 2nd and 3rd download speeds judging from other speedtests that was down to systctl.conf and a reduction in ping and jitter ping had a 3.5ms reduction in the average time the initial pings were a lot faster, jitter was 0.3ms but took it under 2ms with 1.73ms.
hopefully not to much information I have also got faster page load time in firefox :-)

@UrbanDesimator
Copy link

@GamePlayer-8
Copy link
Author

@UrbanDesimator If you want I can update the sysctl with your notes along with including you as the contributor under said modifications.

@GamePlayer-8
Copy link
Author

I've published those configs in the past and I don't remember why I've sent those specific values (probably was in some relation with packet overhead on my router, dunno).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment