[SOLVED] Fritzbox: Open tcp port by openHAB


Is there any option to open / close a port (e.g. FTP, ssh, …) on a Fritzbox through a switch / script by openHAB?

No one have an idea?

shouldn’t this be possible by UPnP?

My use case is:
Open VPN port as soon as I leave the house - otherwise it’s closed.

I don’t think, that’s possible with sole openHAB logic as I don’t know of a binding, which can trigger VPN inside Fritz.Box.

one solution would be to use a Fritz.Box script to turn VPN on/off and trigger that via exec-binding.
i don’t know and use Fritz.Box Scripting, but have a look (german only, sorry…) here for a start:

Sorry, I was a little imprecise.

I am running OpenVPN on my Raspberry, but would only like to switch the ports within the Fritzbox not the vpn itself.

I would also like to do it for other purposes as well like opening temporarily an sftp port.

I found a solution:

just use the per script here:

PLEASE NOTE the comment on the bottom of the page mentioned above (manual modification needed):
That line is supposed to be:
chomp($devnum = <>);
But the less than and greater than signs got disappeared. (Probably because it looked like an HTML tag and got stripped.)

You can simply open let’s say a webserver port by:
sudo /etc/openhab2/scripts/igdctl.pl -a -e 80 -i 80 -I -P TCP
and close it by:
sudo /etc/openhab2/scripts/igdctl.pl -R -e 80 -i 80 -I -P TCP

Please make sure that UPnP support is enabled on your fritzbox.