ddos: add ddos init script

add ddos init to load/attach XDP DDoS main
program with empty tail call table as place
holder for tcp, udp, icmp...etc XDP DDoS program

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
This commit is contained in:
Vincent Li
2025-03-28 19:02:57 -07:00
parent 6ff3d8e48e
commit 88c90aadcd
6 changed files with 85 additions and 3 deletions

View File

@@ -0,0 +1 @@
ENABLE_DDOS=on

View File

@@ -202,3 +202,4 @@ var/ipfire/wireless
#var/ipfire/wireless/config
#var/ipfire/wireless/settings
var/ipfire/xdptailcall
var/ipfire/ddos

View File

@@ -93,6 +93,7 @@ etc/rc.d/init.d/vnstat
etc/rc.d/init.d/waitdrives
etc/rc.d/init.d/wlanclient
etc/rc.d/init.d/xdptailcall
etc/rc.d/init.d/ddos
#etc/rc.d/rc0.d
etc/rc.d/rc0.d/K01grub-btrfsd
#etc/rc.d/rc0.d/K01imspetor
@@ -141,6 +142,7 @@ etc/rc.d/rc3.d/S99grub-btrfsd
#etc/rc.d/rc3.d/S99motion
#etc/rc.d/rc3.d/S99vdradmin
etc/rc.d/rc3.d/S102xdptailcall
etc/rc.d/rc3.d/S105ddos
#etc/rc.d/rc6.d
etc/rc.d/rc6.d/K01grub-btrfsd
#etc/rc.d/rc6.d/K01imspetor

View File

@@ -56,7 +56,7 @@ $(TARGET) :
ovpn patches pakfire portfw ppp private proxy/advanced/cre \
proxy/calamaris/bin qos/bin red remote sensors suricata time \
updatexlrator/bin updatexlrator/autocheck urlfilter/autoupdate urlfilter/bin vpn \
wakeonlan wireless xdptailcall; do \
wakeonlan wireless xdptailcall ddos; do \
mkdir -p $(CONFIG_ROOT)/$$i; \
done
@@ -70,7 +70,7 @@ $(TARGET) :
ovpn/ccd.conf ovpn/ccdroute ovpn/ccdroute2 pakfire/settings portfw/config ppp/settings-1 ppp/settings-2 ppp/settings-3 ppp/settings-4 \
ppp/settings-5 ppp/settings proxy/settings proxy/squid.conf proxy/advanced/settings proxy/advanced/cre/enable remote/settings qos/settings qos/classes qos/subclasses qos/level7config qos/portconfig \
qos/tosconfig suricata/settings vpn/config vpn/settings vpn/ipsec.conf \
vpn/ipsec.secrets vpn/caconfig wakeonlan/clients.conf wireless/config wireless/settings xdptailcall/settings; do \
vpn/ipsec.secrets vpn/caconfig wakeonlan/clients.conf wireless/config wireless/settings xdptailcall/settings ddos/settings; do \
touch $(CONFIG_ROOT)/$$i; \
done
@@ -112,6 +112,7 @@ $(TARGET) :
cp $(DIR_SRC)/config/fwhosts/customservices $(CONFIG_ROOT)/fwhosts/customservices
cp $(DIR_SRC)/config/fwhosts/customservices $(CONFIG_ROOT)/fwhosts/customservices.default
cp $(DIR_SRC)/config/cfgroot/xdptailcall-settings $(CONFIG_ROOT)/xdptailcall/settings
cp $(DIR_SRC)/config/cfgroot/ddos-settings $(CONFIG_ROOT)/ddos/settings
# Oneliner configfiles
echo "ENABLED=off" > $(CONFIG_ROOT)/vpn/settings
echo "01" > $(CONFIG_ROOT)/certs/serial

View File

@@ -184,7 +184,7 @@ $(TARGET) :
ln -sf ../init.d/xdptailcall /etc/rc.d/rc3.d/S102xdptailcall
#ln -sf ../init.d/xdpsni /etc/rc.d/rc3.d/S103xdpsni
#ln -sf ../init.d/xdpgeoip /etc/rc.d/rc3.d/S104xdpgeoip
#ln -sf ../init.d/ddos /etc/rc.d/rc3.d/S105ddos
ln -sf ../init.d/ddos /etc/rc.d/rc3.d/S105ddos
ln -sf ../../../../../usr/local/bin/qosctrl \
/etc/rc.d/init.d/networking/red.up/24-RS-qos

77
src/initscripts/system/ddos Executable file
View File

@@ -0,0 +1,77 @@
#!/bin/sh
###############################################################################
# #
# IPFire.org - A linux based firewall #
# Copyright (C) 2007-2022 IPFire Team <info@ipfire.org> #
# Copyright (C) 2024-2025 BPFire <vincent.mc.li@gmail.com> #
# #
# This program is free software: you can redistribute it and/or modify #
# it under the terms of the GNU General Public License as published by #
# the Free Software Foundation, either version 3 of the License, or #
# (at your option) any later version. #
# #
# This program is distributed in the hope that it will be useful, #
# but WITHOUT ANY WARRANTY; without even the implied warranty of #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
# GNU General Public License for more details. #
# #
# You should have received a copy of the GNU General Public License #
# along with this program. If not, see <http://www.gnu.org/licenses/>. #
# #
###############################################################################
. /etc/sysconfig/rc
. $rc_functions
eval $(/usr/local/bin/readhash /var/ipfire/ddos/settings)
load_ddos () {
/usr/sbin/xdp-loader status red0 | grep -w 'xdp_ddos'
if [ $? -ne 0 ]; then
xdp-loader load red0 -P 80 -p /sys/fs/bpf/xdp-ddos -n xdp_ddos /usr/lib/bpf/xdp_ddos.bpf.o
if [ $? -ge 1 ]; then
boot_mesg "Native mode not supported, try SKB"
xdp-loader load red0 -m skb -P 80 -p /sys/fs/bpf/xdp-ddos -n xdp_ddos /usr/lib/bpf/xdp_ddos.bpf.o
fi
fi
}
unload_ddos () {
/usr/sbin/xdp-loader status red0 | grep -w 'xdp_ddos'
if [ $? -eq 0 ]; then
prog_id=$(xdp-loader status red0 | grep 'xdp_ddos' | awk '{print $4}')
/usr/sbin/xdp-loader unload -i $prog_id red0
else
boot_mesg "Error xdp_ddos not loaded!"
fi
}
case "$1" in
start)
boot_mesg -n "Starting xdp-ddos..."
if [ "$ENABLE_DDOS" == "on" ]; then
load_ddos
fi
;;
stop)
boot_mesg "Stopping xdp-ddos..."
if [ "$ENABLE_DDOS" == "off" ]; then
unload_ddos
fi
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac