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

Update TTL settings to nftables

This commit is contained in:
Ycarus (Yannick Chabanois) 2024-10-29 09:34:53 +01:00
parent ebce49935a
commit d11f409225
2 changed files with 9 additions and 3 deletions

View file

@ -5,8 +5,12 @@
_set_ttl() { _set_ttl() {
device=$(uci -q get network.$1.name) device=$(uci -q get network.$1.name)
ttl=$(uci -q get network.$1.ttl) ttl=$(uci -q get network.$1.ttl)
if [ -n "$ttl" ] && [ -z "$(iptables-save 2>/dev/null | grep TTL | grep $device)" ]; then if [ -n "$ttl" ]; then
iptables -w -t mangle -I POSTROUTING -o $device -j TTL --ttl-set $ttl 2>&1 >/dev/null if [ -e /usr/sbin/iptables-nft ] && [ -z "$(nft list ruleset 2>/dev/null | grep ttl | grep $device)" ]; then
nft add rule inet fw4 mangle_forward oifname $device ip ttl set $ttl >/dev/null 2>&1
elif [ ! -e /usr/sbin/iptables-nft ] && [ -z "$(iptables-save 2>/dev/null | grep TTL | grep $device)" ]; then
iptables -w -t mangle -I POSTROUTING -o $device -j TTL --ttl-set $ttl >/dev/null 2>&1
fi
fi fi
} }

View file

@ -155,13 +155,15 @@ if [ "$(uci -q get firewall.ttl)" = "" ]; then
uci -q batch <<-EOF >/dev/null uci -q batch <<-EOF >/dev/null
set firewall.ttl=include set firewall.ttl=include
set firewall.ttl.path=/etc/firewall.ttl set firewall.ttl.path=/etc/firewall.ttl
set firewall.ttl.type='script'
set firewall.ttl.fw4_compatible='1'
commit firewall commit firewall
EOF EOF
fi fi
if [ "$(uci -q get firewall.upnp)" = "" ]; then if [ "$(uci -q get firewall.upnp)" = "" ]; then
uci -q batch <<-EOF >/dev/null uci -q batch <<-EOF >/dev/null
set firewall.upnp=include set firewall.upnp=include
set firewall.upnp.path='/etc/firewall.ttl' set firewall.upnp.path='/etc/firewall.upnp'
set firewall.upnp.type='script' set firewall.upnp.type='script'
set firewall.upnp.fw4_compatible='1' set firewall.upnp.fw4_compatible='1'
commit firewall commit firewall