## IPv6 basic settings
enable_ipv6 = 1
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0
net.ipv6.conf.lo.disable_ipv6 = 0

## IPv6 forwarding and security
net.ipv6.conf.all.forwarding = 1
net.ipv6.conf.default.forwarding = 1
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.default.accept_redirects = 0
net.ipv6.conf.all.accept_ra = 2
net.ipv6.conf.default.accept_ra = 2
net.ipv6.conf.all.autoconf = 1
net.ipv6.conf.default.autoconf = 1
net.ipv6.conf.all.dad_transmits = 1
net.ipv6.conf.default.dad_transmits = 1
net.ipv6.conf.all.router_solicitations = 1
net.ipv6.conf.default.router_solicitations = 1
net.ipv6.conf.all.use_tempaddr = 2
net.ipv6.conf.default.use_tempaddr = 2

## IPv4 basic settings
net.ipv4.ip_forward = 1
net.ipv4.conf.all.forwarding = 1
net.ipv4.conf.default.forwarding = 1
net.ipv4.conf.all.route_localnet = 1
net.ipv4.conf.all.accept_redirects = 0
net.ipv4.conf.default.accept_redirects = 0
net.ipv4.conf.all.secure_redirects = 0
net.ipv4.conf.default.secure_redirects = 0
net.ipv4.conf.all.send_redirects = 0
net.ipv4.conf.default.send_redirects = 0
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0

## IPv4 TCP settings
net.ipv4.tcp_fack = 1
net.ipv4.tcp_early_retrans = 3
net.ipv4.tcp_keepalive_time = 600
net.ipv4.tcp_keepalive_intvl = 15
net.ipv4.tcp_keepalive_probes = 2
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_syncookies = 1
net.ipv4.tcp_timestamps = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_max_tw_buckets = 10000
net.ipv4.tcp_fastopen = 3
net.ipv4.tcp_low_latency = 1
net.ipv4.tcp_mtu_probing = 1
net.ipv4.tcp_autocorking = 0
net.ipv4.tcp_slow_start_after_idle = 0
net.ipv4.tcp_max_syn_backlog = 262144
net.ipv4.tcp_notsent_lowat = 16384
net.ipv4.tcp_no_metrics_save = 0
net.ipv4.tcp_ecn = 1
net.ipv4.tcp_ecn_fallback = 1
net.ipv4.tcp_frto = 1
net.ipv4.tcp_min_rto = 200
net.ipv4.tcp_orphan_retries = 1
net.ipv4.tcp_retries1 = 2
net.ipv4.tcp_retries2 = 5
net.ipv4.tcp_congestion_control = bbr
net.ipv4.tcp_rmem = 4096 87380 33554432
net.ipv4.tcp_wmem = 4096 65536 33554432
net.ipv4.tcp_adv_win_scale = 2
net.ipv4.ip_local_port_range = 1024 65535
net.ipv4.ip_local_reserved_ports = 40000-49999

## IPv6 TCP settings
net.ipv6.tcp_syncookies = 1
net.ipv6.tcp_timestamps = 1
net.ipv6.tcp_fin_timeout = 15
net.ipv6.tcp_max_tw_buckets = 10000
net.ipv6.tcp_fastopen = 3
net.ipv6.tcp_mtu_probing = 1
net.ipv6.tcp_low_latency = 1
net.ipv6.tcp_autocorking = 0
net.ipv6.tcp_slow_start_after_idle = 0
net.ipv6.tcp_congestion_control = bbr
net.ipv6.tcp_rmem = 4096 87380 33554432
net.ipv6.tcp_wmem = 4096 65536 33554432

## UDP settings
net.ipv4.udp_rmem_min = 32768
net.ipv4.udp_wmem_min = 32768
net.ipv4.udp_mem = 65536 131072 262144
net.ipv6.udp_rmem_min = 32768
net.ipv6.udp_wmem_min = 32768
net.ipv6.udp_mem = 65536 131072 262144

## ICMP settings
net.ipv4.icmp_echo_ignore_all = 0
net.ipv4.icmp_echo_ignore_broadcasts = 1
net.ipv4.icmp_ignore_bogus_error_responses = 1
net.ipv6.icmp_echo_ignore_all = 0
net.ipv6.icmp_echo_ignore_broadcasts = 1
net.ipv6.icmp_ignore_bogus_error_responses = 1

## Neighbor cache
net.ipv4.neigh.default.gc_thresh1 = 512
net.ipv4.neigh.default.gc_thresh2 = 1024
net.ipv4.neigh.default.gc_thresh3 = 2048
net.ipv4.neigh.default.unres_qlen = 10000
net.ipv6.neigh.default.gc_thresh1 = 512
net.ipv6.neigh.default.gc_thresh2 = 1024
net.ipv6.neigh.default.gc_thresh3 = 2048
net.ipv6.neigh.default.unres_qlen = 10000

## Network performance and queueing
net.core.netdev_max_backlog = 50000
net.core.netdev_budget = 300
net.core.netdev_budget_usecs = 3000
net.core.default_qdisc = fq
net.core.somaxconn = 65535
net.core.busy_read = 50
net.core.busy_poll = 50

## File descriptors and memory
fs.file-max = 262144
net.core.rmem_max = 33554432
net.core.wmem_max = 33554432
net.core.rmem_default = 33554432
net.core.wmem_default = 33554432

## Memory management
vm.swappiness = 1
vm.overcommit_memory = 1
vm.dirty_background_ratio = 5
vm.dirty_ratio = 20

## Kernel parameters
kernel.pid_max = 64000

## Connection tracking
net.netfilter.nf_conntrack_max = 131072
