> 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

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="/files/DHv0ttNdah5HdRRKcv6U" alt=""><figcaption><p>"System file customization" section</p></figcaption></figure>

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

<figure><img src="/files/G5Chc7Vl7dnhaVUbL7Eq" 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="/files/pOuFcHCpYfmxrvCSdrBe" 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

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

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
