| Crates.io | cupnp |
| lib.rs | cupnp |
| version | 0.1.1 |
| created_at | 2025-10-25 22:13:43.423444+00 |
| updated_at | 2025-10-25 22:22:40.220886+00 |
| description | cupnp is a CLI tool to manage uPnP trivially |
| homepage | https://github.com/erikh/cupnp |
| repository | https://github.com/erikh/cupnp |
| max_upload_size | |
| id | 1900717 |
| size | 34,465 |
cupnp is a tiny tool for managing port forwards on your home router. Suitable for short sessions where you just need a quick port forward, or for putting in systemd timers, cron, etc to keep ports regularly open without having to dive into your router's terrible user interface for this.
You do not need to be root to run this program; it requires no elevated permissions.
Please install cargo and a rust compiler. rustup makes this easy. Then run this:
cargo install cupnp
NOTE: a lot of (even nice ones) home routers don't support lease duration on uPnP port forwards; they will not expire, so you must remove them yourself.
# expose port 8000 over tcp with a 1 hour lease
$ cupnp expose 8000 tcp 3600
# tcp and 3600 are the default, so we can do this:
$ cupnp expose 8000
# to remove, the same, just delete instead of expose:
$ cupnp delete 8000
# for udp:
$ cupnp delete 8000 udp
Note that this will never remove the port forward, but you can add this line to the system (/etc/crontab) or user (crontab -e) crontab to keep your ports open:
User:
*/30 * * * * cupnp enable 8000
System:
*/30 * * * * nobody cupnp enable 8000
You can create systemd files to keep this port forward up until you tell it to turn off. Should work just fine in $HOME/.config/systemd/user if that is desired. You will want to create a pair for each port forward, and be sure to systemctl start the timer file, not the service.
.timer file:
[Unit]
Description=cupnp port forward
After=network-online.target
[Timer]
OnUnitInactiveSec=30min
[Install]
WantedBy=timers.target
.service file:
[Unit]
Description=cupnp port forward
After=network-online.target
[Service]
Type=oneshot
ExecStart=cupnp expose 8000
ExecStop=cupnp delete 8000
MIT
Erik Hollensbe git@hollensbe.org