diff --git a/config/rootfiles/common/configroot b/config/rootfiles/common/configroot index 4ac0e7029..11ec28ca4 100644 --- a/config/rootfiles/common/configroot +++ b/config/rootfiles/common/configroot @@ -202,3 +202,4 @@ var/ipfire/wireless #var/ipfire/wireless/settings var/ipfire/ddos var/ipfire/loxilb +var/ipfire/xdpdns diff --git a/config/rootfiles/common/x86_64/initscripts b/config/rootfiles/common/x86_64/initscripts index 6b394bde6..10f013a7b 100644 --- a/config/rootfiles/common/x86_64/initscripts +++ b/config/rootfiles/common/x86_64/initscripts @@ -93,6 +93,7 @@ etc/rc.d/init.d/waitdrives etc/rc.d/init.d/wlanclient etc/rc.d/init.d/ddos etc/rc.d/init.d/loxilb +etc/rc.d/init.d/xdpdns #etc/rc.d/rc0.d #etc/rc.d/rc0.d/K01imspetor #etc/rc.d/rc0.d/K01motion diff --git a/lfs/configroot b/lfs/configroot index b52eee538..f704f4f0f 100644 --- a/lfs/configroot +++ b/lfs/configroot @@ -54,7 +54,7 @@ $(TARGET) : ethernet extrahd/bin fwlogs fwhosts firewall ipblocklist key langs logging mac main \ menu.d modem optionsfw \ ovpn patches pakfire portfw ppp private proxy/advanced/cre \ - proxy/calamaris/bin qos/bin red remote ddos loxilb keepalived sensors suricata time \ + proxy/calamaris/bin qos/bin red remote ddos loxilb keepalived xdpdns sensors suricata time \ updatexlrator/bin updatexlrator/autocheck urlfilter/autoupdate urlfilter/bin vpn \ wakeonlan wireless ; do \ mkdir -p $(CONFIG_ROOT)/$$i; \ @@ -68,7 +68,7 @@ $(TARGET) : fwhosts/customnetworks fwhosts/customhosts fwhosts/customgroups fwhosts/customservicegrp fwhosts/customlocationgrp fwlogs/ipsettings fwlogs/portsettings ipblocklist/modified \ ipblocklist/settings mac/settings main/hosts main/routing main/security main/settings optionsfw/settings \ 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 ddos/settings ddos/tcp_ports ddos/udp-ddos-settings ddos/udp_ports ddos/dns-ddos-settings loxilb/settings keepalived/keepalived.conf keepalived/runsettings keepalived/settings keepalived/configvs keepalived/configrs qos/settings qos/classes qos/subclasses qos/level7config qos/portconfig \ + ppp/settings-5 ppp/settings proxy/settings proxy/squid.conf proxy/advanced/settings proxy/advanced/cre/enable remote/settings ddos/settings ddos/tcp_ports ddos/udp-ddos-settings ddos/udp_ports ddos/dns-ddos-settings loxilb/settings xdpdns/settings keepalived/keepalived.conf keepalived/runsettings keepalived/settings keepalived/configvs keepalived/configrs 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; do \ touch $(CONFIG_ROOT)/$$i; \ @@ -105,6 +105,7 @@ $(TARGET) : cp $(DIR_SRC)/config/cfgroot/dns-ddos-settings $(CONFIG_ROOT)/ddos/dns-ddos-settings cp $(DIR_SRC)/config/cfgroot/loxilb-settings $(CONFIG_ROOT)/loxilb/settings cp $(DIR_SRC)/config/cfgroot/loxilb-FWconfig.txt $(CONFIG_ROOT)/loxilb/FWconfig.txt + cp $(DIR_SRC)/config/cfgroot/xdpdns-settings $(CONFIG_ROOT)/xdpdns/settings cp $(DIR_SRC)/config/cfgroot/time-settings $(CONFIG_ROOT)/time/settings cp $(DIR_SRC)/config/cfgroot/logging-settings $(CONFIG_ROOT)/logging/settings cp $(DIR_SRC)/config/cfgroot/ethernet-vlans $(CONFIG_ROOT)/ethernet/vlans diff --git a/src/initscripts/system/xdpdns b/src/initscripts/system/xdpdns new file mode 100755 index 000000000..474a4e580 --- /dev/null +++ b/src/initscripts/system/xdpdns @@ -0,0 +1,81 @@ +#!/bin/sh +############################################################################### +# # +# IPFire.org - A linux based firewall # +# Copyright (C) 2007-2022 IPFire Team # +# Copyright (C) 2024 BPFire # +# # +# 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 . # +# # +############################################################################### + +. /etc/sysconfig/rc +. $rc_functions + +eval $(/usr/local/bin/readhash /var/ipfire/xdpdns/settings) + +load_dnsblock () { + /usr/sbin/xdp-loader status green0 | grep -w 'xdp_dns_denylist' + if [ $? -ne 0 ]; then + xdp-loader load green0 -P 70 -p /sys/fs/bpf/xdp-dns-denylist -n xdp_dns_denylist /usr/lib/bpf/xdp_dns.bpf.o + if [ $? -ge 1 ]; then + boot_mesg "Native mode not supported, try SKB" + xdp-loader load green0 -m skb -P 70 -p /sys/fs/bpf/xdp-dns-denylist -n xdp_dns_denylist /usr/lib/bpf/xdp_dns.bpf.o + fi + fi +} + +unload_dnsblock () { + /usr/sbin/xdp-loader status green0 | grep -w 'xdp_dns_denylist' + if [ $? -eq 0 ]; then + prog_id=$(xdp-loader status green0 | grep 'xdp_dns_denylist' | awk '{print $4}') + /usr/sbin/xdp-loader unload -i $prog_id green0 + else + boot_mesg "Error xdp_dns_denylist not loaded!" + fi +} + + +case "$1" in + start) + boot_mesg -n "Starting xdp-dns-denylist..." + if [ "$ENABLE_DNSBLOCK" == "on" ]; then + load_dnsblock + loadproc -b xdp_dns_log + fi + ;; + + stop) + boot_mesg "Stopping xdp-dns-denylist..." + if [ "$ENABLE_DNSBLOCK" == "off" ]; then + unload_dnsblock + killproc xdp_dns_log + fi + ;; + + status) + statusproc /usr/sbin/xdp_dns_log + ;; + + restart) + $0 stop + sleep 1 + $0 start + ;; + + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac