7

I'm looking for some no-brainer commandline tool or script that can be used to forward a given port from the LAN's router (which supports UPNP) to the local machine.

E.g.

upnpforward 9000

would forward port 9000 to from the router to the local host.

GJ.
  • 9,673
  • 26
  • 74
  • 115
  • what exactly are you attempting to do? UPNP is something that should be on an internal network, so there shouldn't be any reason for port forwarding since there is no firewall. What device will the mac connect to with upnp and what is your LAN setup like? – MaQleod Sep 24 '10 at 00:42
  • @MaQleod, UPnP can be used for setting up a lot of different network devices. A popular category of UPnP-capable devices are home gateway routers, which the UPnP spec calls "Internet Gateway Devices" (IGDs). UPnP's IGD protocols can be used to registering NAT port mappings. – Spiff Sep 24 '10 at 04:31

2 Answers2

7

Try the MiniUPNP client

Its usage is:

upnpc-static [options] -a ip port external_port protocol
        Add port redirection
upnpc-static [options] -d external_port protocol [port2 protocol2] [...]
        Delete port redirection
upnpc-static [options] -s
        Get Connection status
upnpc-static [options] -l
        List redirections
upnpc-static [options] -r port1 protocol1 [port2 protocol2] [...]
        Add all redirections to the current host
GJ.
  • 9,673
  • 26
  • 74
  • 115
  • This client does not appear to have a Mac port directly available at the link provided. They only suggest going to MacPorts and trying to find one. – James Mar 15 '13 at 06:29
  • Note that you can now install `miniupnpc` for UPNP or `libnatpmp` for NAT-PMP via Homebrew, depending on which your router supports. They give you the `upnpc` and `natpmpc` commands, respectively. – tvon Mar 23 '14 at 17:02
  • If using Nix, you can try it via `nix-shell -p miniupnpc` – 0xZ3RR0 Mar 30 '23 at 10:00
4

If a GUI tool is fine, or you don't mind creating that command line application yourself, have a look at Port Map / TCMPortMapper

0xZ3RR0
  • 103
  • 3
Daniel Beck
  • 109,300
  • 14
  • 287
  • 334
  • Can confirm that the GUI app still works great as of April 2023 on macOS Monterey. Also is super simple to use. – 0xZ3RR0 Mar 30 '23 at 10:02