What's new

Script to Clear Ports Forwarded By UPnP

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

tbrock47

Occasional Visitor
I'm looking for a command/script that will essentially clear any ports forwarded by UPnP (not necessarily all ports if possible) as I find many ports are not auto-closing.
My current solutions are rebooting the router or disabling and then enabling UPnP via the GUI, both of which are not ideal.
I'd like to be able to either run it on-demand via SSH or set it up to run on a schedule (cron?).

Thanks in advance!
 
Try:
Code:
iptables -t nat -F VUPNP
iptables -t nat -F PUPNP
iptables -F FUPNP

One or more of those seemed to do it. However, there was no "PUPNP" chain in the nat table.
Do I actually need all three commands?

Code:
admin@RT-AC5300:/tmp/home/root#
admin@RT-AC5300:/tmp/home/root# iptables -t nat -F VUPNP
admin@RT-AC5300:/tmp/home/root# iptables -t nat -F PUPNP
iptables: No chain/target/match by that name.
admin@RT-AC5300:/tmp/home/root# iptables -F FUPNP
admin@RT-AC5300:/tmp/home/root#
 
Whether the PUPNP chain exists or not depends on which firmware you're running. It's best to issue all 3 commands anyway (just ignore the errors) so that everything is consistent.
 

Similar threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Staff online

Top