3 /etc
/init.d
/miniupnpd enabled
&& {
5 local state
="${ZONE}_${INTERFACE}"
9 config_get extif config external_iface
11 if [ "$ACTION" = "add" ] && [ "$INTERFACE" = "$extif" ]; then
14 config_get active
"$state" ifname
18 config_get ipaddr
"$extif" ipaddr
20 logger
-t "upnp" "adding $INTERFACE ($DEVICE - $ipaddr) to firewall"
22 iptables
-t nat
-N MINIUPNPD
2>/dev
/null
23 iptables
-t nat
-A prerouting_rule
-i $DEVICE -d $ipaddr -j MINIUPNPD
24 iptables
-t filter
-N MINIUPNPD
2>/dev
/null
25 iptables
-t filter
-A forwarding_rule
-i $DEVICE ! -o $DEVICE -j MINIUPNPD
27 uci_set_state upnpd
"$state" "" "firewall"
28 uci_set_state upnpd
"$state" ifname
"$DEVICE"
29 uci_set_state upnpd
"$state" ipaddr
"$ipaddr"
32 elif [ "$ACTION" = "remove" ] && [ "$INTERFACE" = "$extif" ]; then
35 config_get ifname
"$state" ifname
36 config_get ipaddr
"$state" ipaddr
38 [ -n "$ifname" ] && [ -n "$ipaddr" ] && {
39 logger
-t "upnp" "removing $INTERFACE ($ifname - $ipaddr) from firewall"
40 iptables
-t nat
-D prerouting_rule
-i $ifname -d $ipaddr -j MINIUPNPD
41 iptables
-t filter
-D forwarding_rule
-i $DEVICE ! -o $DEVICE -j MINIUPNPD
42 uci_revert_state upnpd
"$state"