1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice

Welcome To SNBForums

SNBForums is a community for anyone who wants to learn about or discuss the latest in wireless routers, network storage and the ins and outs of building and maintaining a small network.

If you'd like to post a question, simply register and have at it!

While you're at it, please check out SmallNetBuilder for product reviews and our famous Router Charts, Ranker and plenty more!

Script to Clear Ports Forwarded By UPnP

Discussion in 'ASUSWRT - Official' started by tbrock47, Dec 5, 2019.

  1. tbrock47

    tbrock47 Occasional Visitor

    Joined:
    Dec 1, 2015
    Messages:
    16
    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!
     
  2. ColinTaylor

    ColinTaylor Part of the Furniture

    Joined:
    Mar 31, 2014
    Messages:
    10,267
    Location:
    UK
    Try:
    Code:
    iptables -t nat -F VUPNP
    iptables -t nat -F PUPNP
    iptables -F FUPNP
    
     
  3. tbrock47

    tbrock47 Occasional Visitor

    Joined:
    Dec 1, 2015
    Messages:
    16
    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:
    [email protected]:/tmp/home/root#
    [email protected]:/tmp/home/root# iptables -t nat -F VUPNP
    [email protected]:/tmp/home/root# iptables -t nat -F PUPNP
    iptables: No chain/target/match by that name.
    [email protected]:/tmp/home/root# iptables -F FUPNP
    [email protected]:/tmp/home/root#
    
     
  4. ColinTaylor

    ColinTaylor Part of the Furniture

    Joined:
    Mar 31, 2014
    Messages:
    10,267
    Location:
    UK
    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.
     
  5. tbrock47

    tbrock47 Occasional Visitor

    Joined:
    Dec 1, 2015
    Messages:
    16
    Perfect. Thanks so much!