NatureNMoon
Restricted
- Jul 8, 2016
- 70
- 124
- 86
Hello guys,
Sysctl.conf is a file which can help you with preventing DDoS Attacks. While using sysctl.conf, you can prevent many attacks. For example, ICMP Attacks(I have already mentioned below.). Sysctl.conf may help you better than IPTABLES. It has 5.000.000 Packet Per Second rate(It is 5 times better than IPTABLES). However, this rate depends on RAM, CPU, STORAGE, NIC, Operation System, Kernel Version of your machine.
Here is the sysctl.conf bash script;
How to use?
Put the bash script into a file called "r4p3-sysctl.sh" and use the command line below to start the bash script.
How to disable ICMP(Optional)
I didn't add the rule blocking ICMP packets into the bash script. If you want to block ICMP traffic, you can use the command line below;
There is the sysctl.conf, on the attachment, in a firewall developed for a hospital in 2018 by me. I would really like to share it with you. It may help you a lot.
(You can optimize that sysctl.conf by using your interface. For example, there is an interface called "enp12s0f0", you can change it as "eth0" or whatever it is)
Sysctl.conf is a file which can help you with preventing DDoS Attacks. While using sysctl.conf, you can prevent many attacks. For example, ICMP Attacks(I have already mentioned below.). Sysctl.conf may help you better than IPTABLES. It has 5.000.000 Packet Per Second rate(It is 5 times better than IPTABLES). However, this rate depends on RAM, CPU, STORAGE, NIC, Operation System, Kernel Version of your machine.
Here is the sysctl.conf bash script;
Bash:
#!/bin/bash
# Daniel Q. - Nature N Moon - R4P3.NET
# This script will add some commands to your sysctl.conf to prevent the (D)DoS attacks.
# Use this command to start this script "chmod +x r4p3-sysctl.sh && ./r4p3-sysctl.sh"
# There may be some errors which should be about your kernel version or the other things, just ignore it, it will not be a big deal :)
echo "NATURE N MOON - R4P3.NET - SYSCTL.CONF HAS BEEN SUCCESSFULLY STARTED!"
sleep 5
echo 'net.netfilter.nf_conntrack_acct = 0' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_buckets = 65536' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_checksum = 1' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_count = 8668' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_loose = 1' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_closereq = 64' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_closing = 64' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_open = 43200' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_partopen = 480' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_request = 240' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_respond = 480' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_timewait = 240' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_events = 1' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_expect_max = 1024' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_generic_timeout = 300' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_helper = 0' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_icmp_timeout = 20' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_log_invalid = 0' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_max = 50000000' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_closed = 10' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_cookie_echoed = 3' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_cookie_wait = 3' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_established = 432000' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_heartbeat_acked = 210' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_heartbeat_sent = 30' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_shutdown_ack_sent = 3' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_shutdown_recd = 0' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_shutdown_sent = 0' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_be_liberal = 0' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_loose = 0' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_max_retrans = 3' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_close = 10' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_close_wait = 15' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_established = 86400' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 10' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_last_ack = 10' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_max_retrans = 300' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_syn_recv = 15' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_syn_sent = 15' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_time_wait = 15' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_unacknowledged = 15' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_timestamp = 0' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_udp_timeout = 10' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_udp_timeout_stream = 15' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log.0 = NONE' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log.1 = NONE' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log.10 = NONE' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log.11 = NONE' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log.12 = NONE' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log.2 = NONE' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log.3 = NONE' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log.4 = NONE' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log.5 = NONE' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log.6 = NONE' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log.7 = NONE' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log.8 = NONE' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log.9 = NONE' >> /etc/sysctl.conf
echo 'net.netfilter.nf_log_all_netns = 0' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_closereq = 64' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_closing = 64' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_open = 43200' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_partopen = 480' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_request = 240' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_respond = 480' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_dccp_timeout_timewait = 240' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_generic_timeout = 300' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_icmp_timeout = 20' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_closed = 10' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_cookie_echoed = 3' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_cookie_wait = 3' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_established = 432000' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_heartbeat_acked = 210' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_heartbeat_sent = 30' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_shutdown_ack_sent = 3' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_shutdown_recd = 0' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_sctp_timeout_shutdown_sent = 0' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_close = 10' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_close_wait = 15' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_established = 86400' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_fin_wait = 10' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_last_ack = 10' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_max_retrans = 300' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_syn_recv = 15' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_syn_sent = 15' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_time_wait = 15' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_tcp_timeout_unacknowledged = 15' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_udp_timeout = 10' >> /etc/sysctl.conf
echo 'net.netfilter.nf_conntrack_udp_timeout_stream = 15' >> /etc/sysctl.conf
sysctl -p
sleep 5
echo "NATURE N MOON - R4P3.NET - SYSCTL.CONF HAS BEEN SUCCESSFULLY DONE!"
How to use?
Put the bash script into a file called "r4p3-sysctl.sh" and use the command line below to start the bash script.
Code:
chmod 777 r4p3-sysctl.sh && ./r4p3-sysctl.sh
How to disable ICMP(Optional)
I didn't add the rule blocking ICMP packets into the bash script. If you want to block ICMP traffic, you can use the command line below;
Code:
echo 'net.ipv4.icmp_echo_ignore_all = 1' >> /etc/sysctl.conf && sysctl -p
There is the sysctl.conf, on the attachment, in a firewall developed for a hospital in 2018 by me. I would really like to share it with you. It may help you a lot.
(You can optimize that sysctl.conf by using your interface. For example, there is an interface called "enp12s0f0", you can change it as "eth0" or whatever it is)