> For the complete documentation index, see [llms.txt](https://docs.mikopbx.com/mikopbx/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.mikopbx.com/mikopbx/english/faq/management/backup-internet.md).

# Backup Internet and Provider Re-Registration

Configuring Backup Internet

If your PBX is behind NAT and its public IP address changes, the PBX may not receive incoming calls until it re-registers with the provider, which by default can take 2–6 minutes.

## Create the IP Check Script

1. Connect using SSH into your MikoPBX (documentation about different ways to do that - [here](/mikopbx/english/faq/troubleshooting/connecting-to-a-pbx-using-ssh.md))
2. Create a new script file with this command:

```bash
cat > /storage/usbdisk1/mikopbx/custom_modules/update_ip.sh
```

The system will wait for input; paste the following script into the terminal:

```bash
#!/bin/bash
# File to store the previous IP
IP_FILE="/tmp/last_ip.txt"
# Command to retrieve the current public IP
CURRENT_IP=$(/usr/bin/curl -s https://checkip.amazonaws.com)

# Check if the file with the previous IP exists
if [ -f "$IP_FILE" ]; then
    LAST_IP=$(cat "$IP_FILE")
else
    LAST_IP=""
fi

# Compare the current IP with the previous IP
if [ "$CURRENT_IP" != "$LAST_IP" ]; then
    /bin/busybox logger -t 'UpdateIP' "IP changed: $LAST_IP -> $CURRENT_IP"
    echo "$CURRENT_IP" > "$IP_FILE"
    # Trigger an Asterisk command
    /usr/sbin/asterisk -rx 'pjsip send register *all'
fi
```

3. Press **CTRL+D** to finish.
4. Make the file executable:

```bash
chmod +x /storage/usbdisk1/mikopbx/custom_modules/update_ip.sh
```

## Schedule the Script

1. Go to the MikoPBX web interface → "**System"** → "**System file customization":**

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2FhTmaJ0lPE0zg51NSG7oV%2FsystemFileCustomization.jpg?alt=media&amp;token=07a5052e-efb2-40ef-9974-832cbf4d8eae" alt=""><figcaption><p>"System file customization" section</p></figcaption></figure>

2. Open the file: **`/var/spool/cron/crontabs/root`**

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2F5fXczAQFwgoItvXJqLzY%2FcrontabsFile.jpg?alt=media&amp;token=4732b873-810d-4457-94ad-2357c144c463" alt=""><figcaption><p>"crontabs/root" file</p></figcaption></figure>

3. Append the following line to the end of the file:

```
*/1 * * * * /storage/usbdisk1/mikopbx/custom_modules/update_ip.sh > /dev/null 2> /dev/null
```

This schedule runs the script every minute to check for a changed public IP. If the IP has changed, it re-registers all providers.

<figure><img src="https://835495363-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FsZ8acWnNlSalIHQjMFu1%2Fuploads%2F3oCGDajpSgvgg7Sm5MBG%2FediditngFile.jpg?alt=media&amp;token=269278f7-fb06-499e-a92c-796d34e1d93c" alt=""><figcaption><p>Editing file crontabs/root</p></figcaption></figure>

{% hint style="success" %}
If the IP changes, you’ll see an informational log in `system/messages` stating the old and new IP addresses.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.mikopbx.com/mikopbx/english/faq/management/backup-internet.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
