1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-03-09 15:40:03 +00:00

Use iptables-legacy instead of iptables

This commit is contained in:
Ycarus (Yannick Chabanois) 2022-09-25 19:02:32 +02:00
parent ca45d952c2
commit 827a93c478
10 changed files with 233 additions and 132 deletions

View file

@ -1,6 +1,14 @@
#!/bin/sh
. /lib/functions.sh
if [ -f /usr/sbin/iptables-legacy ]; then
IPTABLESSAVE="/usr/sbin/iptables-legacy-save"
IPTABLESRESTORE="/usr/sbin/iptables-legacy-restore"
else
IPTABLESSAVE="/usr/sbin/iptables-save"
IPTABLESRESTORE="/usr/sbin/iptables-restore"
fi
_setup_rules() {
config_get lookup $1 lookup
[ -n "$lookup" ] && [ -z "$(ip rule list fwmark 0x${lookup})" ] && {
@ -30,8 +38,8 @@ _setup_fw() {
[ -n "$src_ips_forward" ] && rule="$rule -s $(echo "${src_ips_forward}" | sed 's/ /,/g')"
[ -n "$ifnames" ] && rule="$rule -i $(echo "${ifnames}" | sed 's/ /-i /g')"
if [ -n "$rule" ] && [ -n "$lookup" ]; then
iptables-save --counters | grep -v "0x${lookup}" | iptables-restore -w --counters
iptables-restore -w --wait=60 --noflush <<-EOF
$IPTABLESAVE --counters | grep -v "0x${lookup}" | $IPTABLERESTORE -w --counters
$IPTABLERESTORE -w --wait=60 --noflush <<-EOF
*mangle
-A omr-gre-tunnel ${rule} -j MARK --set-mark 0x${lookup}
COMMIT
@ -39,8 +47,8 @@ _setup_fw() {
fi
}
if [ -z "$(iptables-save | grep omr-gre-tunnel)" ]; then
iptables-restore -w --wait=60 --noflush <<-EOF
if [ -z "$($IPTABLESAVE | grep omr-gre-tunnel)" ]; then
$IPTABLERESTORE -w --wait=60 --noflush <<-EOF
*mangle
:omr-gre-tunnel -
-I PREROUTING 1 -m addrtype ! --dst-type LOCAL -j omr-gre-tunnel