> For the complete documentation index, see [llms.txt](https://help.sipgate.de/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.sipgate.de/trunking/en/wie-konfiguriere-ich-asterisk-fuer-sipgate-trunking.md). Agents can also search and read this documentation through its [MCP server](https://help.sipgate.de/~gitbook/mcp).

# How do I configure Asterisk for sipgate trunking?

Guidance on configuring an Asterisk for sipgate trunking, including an encrypted connection via TLS/SRTP.

Below are some notes on configuring an Asterisk. A corresponding peer with **an encrypted connection (TLS/SRTP)** could look like this:

```ini
[global]
endpoint_identifier_order = username,ip

[generic_transport]
type = transport
protocol = tls
bind = 0.0.0.0
; A separate certificate (cert_file/priv_key_file) is not required:
; sipgate does not require a client certificate, and incoming calls are routed
; over the TLS connection established by your Asterisk.
; The system CA bundle is sufficient to verify the sipgate server certificate:
ca_list_file = /etc/ssl/certs/ca-certificates.crt

[generic_endpoint](!)
type=endpoint
context=error
100rel=no
direct_media=no allow=!all,g722,alaw,ulaw,g726aal2,gsm,ilbc
g726_non_standard=yes
rtp_timeout=120
rtp_timeout_hold=900
t38_udptl=yes
t38_udptl_ec=redundancy
fax_detect=no
t38_udptl_nat=yes
aors=generic_aor
moh_passthrough=yes
dtmf_mode=auto
allow_transfer=no
tos_audio=ef
cos_audio=5
sdp_session=VoIP
GW timers=no
send_diversion=no
; SRTP with SDES key exchange (required when using TLS):
media_encryption=sdes

[sipgateregister]
type = registration
server_uri = sip:#SIPID#@sipgate.de:5061
client_uri = sip:#SIPID#@sipgate.de:5061
contact_user = inbound-calls
outbound_proxy = sip:sip.sipgate.de:5061\;lr
outbound_auth = sipgateauthreg

[sipgateendpoint](generic_endpoint)
type = endpoint
aors = sipgateaor
context = inbound
;auth = sipgateauth
outbound_auth = sipgateauth
from_domain=sipgate.de
from_user=#SIPID#
; If incoming calls are not being routed through, enable:
; rewrite_contact=yes

[sipgateaor]
type = aor
contact = sip:sipgate.de:5061

[sipgateidentify]
type = identify
match = sip.sipgate.de
endpoint = sipgateendpoint

[sipgateauthreg]
type = auth
auth_type = userpass
username = #SIPID#
password = #SIPPASSWORD#

[sipgateauth]
type = auth
auth_type = userpass
username = #SIPID#
password = #SIPPASSWORD#
```

For the placeholders **#SIPID#** and **#SIPPASSWORD#** please enter your **personal SIP ID** and your **personal SIP password** .

The information in the **outbound\_auth** line is particularly important to ensure that you connect to the correct server. For incoming calls, Asterisk must register with our server. Pay attention to the entries **outbound\_proxy** (`sip.sipgate.de`) and **media\_encryption=sdes**: sipgate trunking uses TLS with **SRTP (SDES)**; TLS connections without SRTP are rejected. The transport is selected via the section **\[generic\_transport]** (`protocol = tls`); the URIs still use the `sip:` scheme. An unencrypted TCP connection is not supported. Alternatively, you can register via UDP with the registrar `sipgate.de`  and without an outbound proxy.

```ini
[general]
static=yes
writeprotect=yes

[outbound]
exten = _NX.,1,NoOp(dialout)
same = n,Dial(PJSIP/${EXTEN}@sipgateendpoint,120,trb(dialhook^s^1))

[dialhook]
exten = s,1,Set(PJSIP_HEADER(add,P-Preferred Identity) = <sip:49<someNiceNumber>@sipgate.de>)
same = n,Return()

[inbound]
exten = _X.,1,Dial(PJSIP/aPhone)
same = n,Playback(beep)
same = n,Hangup
```

For outgoing calls, please set the desired caller ID in E.164 format (i.e. international format without leading zeros or "+" signs) as a new header **P-Preferred-Identity**:

```
SipAddHeader(P-Preferred-Identity: <sip:492111234567@sipgate.de>)
```

Would you like to **suppress the phone number**, enter the following:

```
SipAddHeader(P-Preferred-Identity: <sip:492111234567@sipgate.de>)
SipAddHeader(Privacy: id)
```

Incoming calls are signaled with the full dialed **E.164 number in the Request URI** . This allows you to work with it easily in the variable `${EXTEN}` . There is no need to extract the number from the To URI.

If you set up **call forwarding**in your phone system, you can signal this too. To do so, use the Diversion header and enter the originally dialed number there (in the following example, this was written to the ORIGEXTEN variable in the dialplan):

```
SipAddHeader(Diversion: <sip:${ORIGEXTEN}@sipgate.de>)
```

{% hint style="info" %}
**Note:** As an alternative to an encrypted connection, unencrypted registration via **UDP** is possible. We recommend the encrypted connection via TLS/SRTP, as described above. You can find all configuration details in the article [Configuring sipgate trunking](https://help.sipgate.de/trunking/en/konfiguration-sipgate-trunking.md).
{% endhint %}

For more information, see the [configuration guides](https://app.sipgate.com/w0/team/faq/setup/index/id/219).


---

# 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://help.sipgate.de/trunking/en/wie-konfiguriere-ich-asterisk-fuer-sipgate-trunking.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.
