loxilb: add loxilb init script

add loxilb init script and initial loxilb FW settings

Signed-off-by: Vincent Li <vincent.mc.li@gmail.com>
This commit is contained in:
Vincent Li
2025-04-27 10:48:42 -07:00
parent e0353f023c
commit 5df5d88abd
8 changed files with 81 additions and 2 deletions

View File

@@ -0,0 +1 @@
{"fwAttr":[{"opts":{"counter":"0:0","doSnat":true,"onDefault":true,"toIP":"REDIP"},"ruleArguments":{"destinationIP":"0.0.0.0/0","portName":"green0","sourceIP":"0.0.0.0/0"}}]}

View File

@@ -0,0 +1 @@
ENABLE_LOXILB=off

View File

@@ -100,6 +100,7 @@ var/ipfire/langs
#var/ipfire/langs/tr.pl
var/ipfire/logging
#var/ipfire/logging/settings
var/ipfire/loxilb
var/ipfire/mac
#var/ipfire/mac/settings
var/ipfire/main

View File

@@ -31,6 +31,7 @@ etc/rc.d/init.d/halt
etc/rc.d/init.d/ipsec
etc/rc.d/init.d/leds
etc/rc.d/init.d/localnet
etc/rc.d/init.d/loxilb
etc/rc.d/init.d/modules
etc/rc.d/init.d/mountfs
etc/rc.d/init.d/mountkernfs

View File

@@ -4,3 +4,4 @@ opt/loxilb/llb_kern_sock.o
opt/loxilb/llb_xdp_main.o
opt/loxilb/loxilb_libdp.o
usr/bin/loxilb
etc/rc.d/rc3.d/S106loxilb

View File

@@ -51,7 +51,7 @@ $(TARGET) :
# Create all directories
for i in addon-lang auth backup ca captive certs connscheduler crls ddns dhcp dhcpc dns dnsforward \
ethernet extrahd/bin fwlogs fwhosts firewall ipblocklist key langs logging mac main \
ethernet extrahd/bin fwlogs fwhosts firewall ipblocklist key langs logging loxilb mac main \
menu.d modem optionsfw \
ovpn patches pakfire portfw ppp private proxy/advanced/cre \
proxy/calamaris/bin qos/bin red remote sensors suricata time \
@@ -66,7 +66,7 @@ $(TARGET) :
dhcp/fixleases dhcp/advoptions dhcp/dhcpd.conf.local dns/settings dns/servers dnsforward/config ethernet/aliases ethernet/settings ethernet/known_nics ethernet/scanned_nics \
ethernet/wireless extrahd/scan extrahd/devices extrahd/partitions extrahd/settings firewall/settings firewall/locationblock firewall/input firewall/outgoing \
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 \
ipblocklist/settings loxilb/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 qos/settings qos/classes qos/subclasses qos/level7config qos/portconfig \
qos/tosconfig suricata/settings vpn/config vpn/settings vpn/ipsec.conf \
@@ -115,6 +115,8 @@ $(TARGET) :
cp $(DIR_SRC)/config/cfgroot/ddos-settings $(CONFIG_ROOT)/ddos/settings
cp $(DIR_SRC)/config/cfgroot/tcp-ddos-settings $(CONFIG_ROOT)/ddos/tcp-ddos-settings
cp $(DIR_SRC)/config/cfgroot/tcp_ports $(CONFIG_ROOT)/ddos/tcp_ports
cp $(DIR_SRC)/config/cfgroot/loxilb-settings $(CONFIG_ROOT)/loxilb/settings
cp $(DIR_SRC)/config/cfgroot/loxilb-FWconfig.txt $(CONFIG_ROOT)/loxilb/FWconfig.txt
# Oneliner configfiles
echo "ENABLED=off" > $(CONFIG_ROOT)/vpn/settings
echo "01" > $(CONFIG_ROOT)/certs/serial

View File

@@ -185,6 +185,7 @@ $(TARGET) :
#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/loxilb /etc/rc.d/rc3.d/S106loxilb
ln -sf ../../../../../usr/local/bin/qosctrl \
/etc/rc.d/init.d/networking/red.up/24-RS-qos

71
src/initscripts/system/loxilb Executable file
View File

@@ -0,0 +1,71 @@
#!/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/loxilb/settings)
case "$1" in
start)
boot_mesg -n "Starting loxilb..."
if [ "$ENABLE_LOXILB" == "on" ]; then
if [ -d /opt/loxilb/dp/ ]; then
umount /opt/loxilb/dp/
rm -fr /opt/loxilb/dp/bpf
fi
mkdir -p /opt/loxilb/dp/
mount -t bpf bpf /opt/loxilb/dp/
#enable egress firewall SNAT for green network
redip=$(< /var/ipfire/red/local-ipaddress)
sed -i "s/\"REDIP\"/\"$redip\"/" /var/ipfire/loxilb/FWconfig.txt
loadproc -b loxilb --config-path="/var/ipfire/loxilb/" --blacklist="eth[0-9]"
fi
;;
stop)
boot_mesg "Stopping loxilb..."
if [ "$ENABLE_LOXILB" == "off" ]; then
#remove egress firewall SNAT for green network
loxicmd delete firewall --firewallRule="portName:green0"
killproc loxilb
fi
;;
status)
statusproc /usr/bin/loxilb
;;
restart)
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac