kbr / fritzconnection

Python-Tool to communicate with the AVM Fritz!Box by the TR-064 protocol and the AHA-HTTP-Interface
MIT License
303 stars 59 forks source link

Error 403 when trying to Port forward #161

Closed DerGrubengraeber closed 2 years ago

DerGrubengraeber commented 2 years ago

Hey, when i try to port forward via ipv6 i get an Error 403.

This is my Code:

fc = FritzConnection(address='exampleIP',password='examplepw')
        ss = fc.call_action('WANIPv6Firewall1', 'AddPinhole', RemoteHost="::", RemotePort=1234, InternalClient='exampleMAC', InternalPort=1234, Protocol="6", LeaseTime=0)

This is the Error i get: errorCode: 403 errorDescription: Not available Action

kbr commented 2 years ago

This is an error message forwarded from the router. Seems that the router-api reports 'AddPinhole' as an action but does not support it. It could be that the action is deactivated. Did you checked GetFirewallStatus ?

DerGrubengraeber commented 2 years ago

InboundPinholeAllowed is indeed set to False, is there a way to enable it or does my Router just not support it?

kbr commented 2 years ago

I suppose these data are mostly read-only. Consider to open pinholes by a public api – that would be a serious security issue for the router. May be that in the web-interface at "Internet -> Permit Access -> Port Sharing" are some settings to change the behaviour and configure the firewall. However, I have never tried this.

DerGrubengraeber commented 2 years ago

I enabled "selbstständige Portfreigabe" for my device (even tho i dont think i want to keep it enabled due to the security implications) and it did change InboundPinholeAllowed to True. I also slightly change my code to now use the UniqueID argument, but now the Script is giving me this error message. errorCode: 606 errorDescription: Unknown Error Code

Maybe this is due to something being wrong with my code in which case you prolly don't have to help me but i don't really now what to make of "Unkown Error Code"

kbr commented 2 years ago

I don't know what you mean by "prolly" but 606 is a SecurityError, so from the viewpoint of the router it seems that you have messed up something. The errorDescription – however strange in this context – is provided "as is" from the router.

DerGrubengraeber commented 2 years ago

This is my current code, should anything acutally be wrong with it it is my fault I guess and i'll close the issue.

fc = FritzConnection(address='IP', password='Password') ss = fc.call_action('WANIPv6Firewall1', 'AddPinhole', RemoteHost="::", RemotePort=12345, InternalClient='IP', InternalPort=12345, Protocol="6", LeaseTime=0, UniqueID=4)

kbr commented 2 years ago

Code is syntactically ok. As this issue is about the router and not the library I will close this.