mirror of
https://github.com/kiddin9/op-packages.git
synced 2026-11-01 10:53:56 +08:00
🌴 Sync 2026-03-05 23:51:42
This commit is contained in:
1 parent
97c049ed0a
commit
0acff03804
14253 files changed
+3893239
No files matched your search
Executable
+38
@@ -0,0 +1,38 @@
|
||||
#!/bin/sh
|
||||
# NATMap
|
||||
outter_ip=$1
|
||||
outter_port=$2
|
||||
ip4p=$3
|
||||
inner_port=$4
|
||||
protocol=$5
|
||||
|
||||
if [ ! -z $FORWARD_USE_NATMAP ] && [ $FORWARD_USE_NATMAP = '1' ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$FORWARD_PORT" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -z "$FORWARD_TARGET" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
rule_name=$(echo "${NAT_NAME}_v4" | sed 's/[^a-zA-Z0-9]/_/g' | awk '{print tolower($0)}')
|
||||
final_forward_port=$FORWARD_PORT
|
||||
if [ $final_forward_port = 0 ]; then
|
||||
final_forward_port=$outter_port
|
||||
fi
|
||||
# ipv4 redirect
|
||||
uci set firewall.$rule_name=redirect
|
||||
uci set firewall.$rule_name.name="$NAT_NAME"
|
||||
uci set firewall.$rule_name.proto=$protocol
|
||||
uci set firewall.$rule_name.src='wan'
|
||||
uci set firewall.$rule_name.dest='lan'
|
||||
uci set firewall.$rule_name.target='DNAT'
|
||||
uci set firewall.$rule_name.src_dport="${inner_port}"
|
||||
uci set firewall.$rule_name.dest_ip="${FORWARD_TARGET}"
|
||||
uci set firewall.$rule_name.dest_port="${final_forward_port}"
|
||||
# reload
|
||||
uci commit firewall
|
||||
/etc/init.d/firewall reload
|
||||
Reference in new issue
Block a user