@@ -68,33 +68,94 @@ net.ipv4.ip_forward = 0
6868net.ipv6.conf.all.forwarding = 0
6969
7070## do not accept ICMP redirects (prevents MITM attacks) ##
71- net.ipv4.conf.default.accept_redirects = 0
7271net.ipv4.conf.all.accept_redirects = 0
73- net.ipv6.conf.default.accept_redirects = 0
7472net.ipv6.conf.all.accept_redirects = 0
7573
7674## do not send ICMP redirects (we are not a router) ##
77- net.ipv4.conf.default.send_redirects = 0
7875net.ipv4.conf.all.send_redirects = 0
7976
8077## do not accept IP source route packets (we are not a router) ##
81- net.ipv4.conf.default.accept_source_route = 0
8278net.ipv4.conf.all.accept_source_route = 0
83- net.ipv6.conf.default.accept_source_route = 0
8479net.ipv6.conf.all.accept_source_route = 0
8580
8681## allowed local port range (set to max limit) ##
8782net.ipv4.ip_local_port_range = 1024 65535
8883net.ipv6.ip_local_port_range = 1024 65535
8984
90- ## log Martian packets (IPv4 only) ##
91- net.ipv4.conf.all.log_martians = 1
85+ ## increase TCP SYN backlog to prevent SYN flood attacks ##
86+ net.ipv4.tcp_max_syn_backlog = 2048
87+ net.ipv6.tcp_max_syn_backlog = 2048
88+
89+ ## enable TCP syn cookies (SYN flood attack protection) ##
90+ net.ipv4.tcp_syncookies = 1
91+
92+ ## reduce TCP FIN timeout (improves performance) ##
93+ net.ipv4.tcp_fin_timeout = 30
94+
95+ ## enable TCP window scaling (useful for high latency networks) ##
96+ net.ipv4.tcp_window_scaling = 1
97+
98+ ## enable IP source address validation (anti-spoofing) ##
99+ net.ipv4.conf.all.src_valid_mark = 1
100+
101+ ## set max open files (for high traffic servers) ##
102+ fs.file-max = 2097152
103+
104+ ## tune buffer space for high traffic connections ##
105+ net.ipv4.tcp_rmem = 4096 87380 16777216
106+ net.ipv4.tcp_wmem = 4096 65536 16777216
107+
108+ ## enable TCP timestamps (for high latency networks) ##
109+ net.ipv4.tcp_timestamps = 1
110+
111+ ## enable TCP keepalive to detect dead connections ##
112+ net.ipv4.tcp_keepalive_time = 7200
113+ net.ipv4.tcp_keepalive_intvl = 75
114+ net.ipv4.tcp_keepalive_probes = 9
115+
116+ ## enable TCP Fast Open ##
117+ net.ipv4.tcp_fastopen = 3
118+
119+ ## disable IPv4 forwarding on lo interface ##
120+ net.ipv4.conf.lo.forwarding = 0
121+
122+ ## enable TCP SACK (Selective Acknowledgments) ##
123+ net.ipv4.tcp_sack = 1
124+
125+ ## restrict the number of connections in SYN_RECV state ##
126+ net.ipv4.tcp_max_orphans = 32768
127+
128+ ## limit TCP buffer allocations to prevent overflow ##
129+ net.ipv4.tcp_mem = 786432 16777216 33554432
92130
93131## disable IPv6 globally (if needed) ##
94132# net.ipv6.conf.all.disable_ipv6 = 1
95133# net.ipv6.conf.default.disable_ipv6 = 1
96134# net.ipv6.conf.lo.disable_ipv6 = 1
97135# net.ipv6.conf.all.accept_ra = 0
136+ # net.ipv6.conf.all.disable_ipv6_nd = 1
137+
138+ ## disable IPv6 privacy extensions ##
139+ net.ipv6.conf.all.use_tempaddr = 0
140+ net.ipv6.conf.default.use_tempaddr = 0
141+
142+ ## disable IPv6 Router Advertisements (RA) ##
143+ net.ipv6.conf.all.accept_ra = 0
144+ net.ipv6.conf.default.accept_ra = 0
145+
146+ ## disable IPv6 Duplicate Address Detection (DAD) ##
147+ net.ipv6.conf.all.dad_transmits = 0
148+ net.ipv6.conf.default.dad_transmits = 0
149+
150+ ## disable IPv6 RFC 4941 (Privacy Extensions) ##
151+ net.ipv6.conf.all.rfc4941 = 0
152+
153+ ## set maximum initial window size for TCP/UDP (optimization) ##
154+ net.ipv4.tcp_init_rwnd = 10
155+
156+ ## adjust maximum buffer size for TCP connections ##
157+ net.core.rmem_max = 16777216
158+ net.core.wmem_max = 16777216
98159
99160####################################################################################################
100161#### Ubuntu Kernel: TCP + UDP Settings #############################################################
0 commit comments