How to make Asterisk work behind a FRITZ!Box

There are many Home DSL modems/routers that think it’s a good idea to mess with SIP and unfortunately I have one of them: the FRITZ!Box 7360.

I have an Asterisk server on a local LAN that sits behind a FRITZ!Box 7360 providing my Internet connection. The problem is that, while a remote client’s SIP registration to the Asterisk server on the local LAN succeeds, the FRITZ!Box intercepts all SIP calls, even if they are destined for the Asterisk server on the local LAN, making any call from a remote client to the Asterisk server time-out aka fail.

Yes that’s right: apparently the FRITZ!Box thinks it’s the only SIP server in the universe grabbing all SIP calls it sees, even if they are not destined for the FRITZ!Box.

If you want to see the reason with your own eyes, just backup the config of your FRITZ!Box and open it in your favourite text editor. Search for “voip” and you will find gems like this:

and this:

And this:

To make SIP calls work between remote clients and my Asterisk server, the FRITZ!Box configuration needs some serious fixing. Here are the steps to make your FRITZ!Box no longer mess with SIP.

Caveat: please be aware that the VoIP functionality of the FRITZ!Box may be impacted by this new config. As in that the VoIP/Telephony functionality of the FRITZ!Box no longer or only partially works. I do not use any of that functionality so have not tested it but given the all or nothing nature of the FRITZ!Box config it’s not an unreasonable assumption.

Step 1 – Backup the config of your FRITZ!Box

Open your browser and surf to the webinterface of the FRITZ!Box and enter your password if you have set it (good idea).

Now in the menu on the left click on “System” then in the “System” menu click on “Backup” and then click on “Save” in the lower right corner.

In my case the name of the generated config file is:
FRITZ.Box Fon WLAN 7360 124.06.04i_25.03.14_1730

Step 2 – Make a copy of the config file

Let’s create a copy of the config and work so there’s always the original config to revert back to in case anything goes wrong.

Step 3 – Make changes in the copy of the config file

Make the following changes in the copy of the config file which in my case is:
FRITZ.Box Fon WLAN 7360 124.06.04i_25.03.14_1730-CHANGED.export

– at the top of the file add “NoChecks=yes” between “Country=” and “Language=”
– change port 5060 to for example 45060
– change port 7078 range to for example 47078
– change port 7077 to for example 47077

Feel free to choose different numbers. Just make sure they don’t interfere with other applications.

Here is a diff of the changes I made:

Step 4 – Upload the new config to the FRITZ!Box

DISCLAIMER: USE AT OWN RISK. I CAN NOT BE HELD RESPONSIBLE IF YOU BRICK YOUR FRTIZ!BOX.

Again surf to the webinterface of the FRITZ!Box and enter your password if you have set it (still a good idea). In the menu on the left click on “System” then in the “System” menu click on “Backup” and then at the top of the screen click on the tab “Restore”.

The option “Way of Restoring Settings” should be set to the top one: “from this FRITZ!Box or another FRITZ!Box of the same model”. In my case that was the default. Next click on “Browse” and select the copy of the config file with the changes and let the FRITZ!Box restore the new config.

Once the FRITZ!Box has rebooted with the new config it should no longer mess with SIP calls destined for a SIP server on the local LAN.

7 thoughts on “How to make Asterisk work behind a FRITZ!Box”

    1. BTR,

      It’s unclear what you are asking. If you want to specify the SIP port on which the Fritz!Box listens then look at the sip_srcport variable. See step 3.

      Best, Patrick

  1. hi Patrick,

    I’ve been running into a problem similar to this. My asterisk server is hosted on the internet and I use the ATA port on the FRitzbox to use an analog phone.

    My problem being that my asterisk runs on a non-standard port and the Fritz!Box GUI doesn’t let me choose the SIP port to use.
    I used to have the BBox configured as sip client, but at least then, I could both select the source port and sip destination sip for sip registration.

    Do the changes you propose affect the sip client configuration on the Fritz!Box?
    So changing 5060 to 45060 in the config file would also make the F!B connect remotely on this port?

    Thanks,
    Amaury

    1. Hi Amaury,

      I don’t know if it affects the SIP client configuration as I have never used the Fritz!Box as a SIP client.

      Best,
      Patrick

  2. I have the same problem here, and my ITSP does not seem to solve it. So I tried what you suggest. But if i just add the line “NoChecks=yes”, the FB answer “Une erreur s’est produite pendant la restauration de la configuration. Le fichier indiqué n’est pas un fichier d’importation valide.” (= the file is not valid, import has failed).
    May be I have a more recent firmware?
    Do you have smoe sort of manual for the syntax of the config file?
    thanks!
    Laurent

    1. Laurent,

      It worked for me with firmware version 6.20 (English language). Unfortunately I don’t have a manual for the syntax of the config file but iirc Google has a lot of info.

      Best, Patrick

  3. Instead of changing the fritzbox config, in some cases it might be easier to run sip on an different port.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.