# How do I configure Asterisk for sipgate trunking?

Below you will find notes on configuring an Asterisk. A corresponding peer could look like this:

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

[generic_transport]
type = transport
protocol = udp
bind = 0.0.0.0

[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
transport=generic_transport
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

[sipgateregister]
type = registration
server_uri = sip:#SIPID#@sipconnect.sipgate.de
client_uri = sip:#SIPID#@sipconnect.sipgate.de
contact_user = inbound-calls
outbound_auth = sipgateauthreg

[sipgateendpoint](generic_endpoint)
type = endpoint
aors = sipgateaor
context = inbound
;auth = sipgateauth
outbound_auth = sipgateauth
from_domain=sipconnect.sipgate.de
from_user=#SIPID#

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

[sipgateidentify]
type = identify
match = sipconnect.sipgate.de
match = 217.10.68.150:5060
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 **#password#** please enter your **personal sip ID** as well as your **personal sip password** .

The information in the line **outbound\_auth**is particularly important, to ensure that you end up on the correct server. For incoming calls, the Asterisk must register with our server. It is important that the peer **sipconnect.sipgate.de** is named.

```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>@sipconnect.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 number in E164 format (that is, international without leading zeros or "+" signs) as a new header **P-Preferred-Identity**:

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

Would you like **Suppress caller ID**to do so, enter the following:

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

Incoming calls will be signaled to you with the full dialed **E164 number in the Request URI** . This allows you to work with it easily in the variable `${EXTEN}` . It is not necessary to cut the number out of the To-URI.

If you in your telephone system **set up call forwarding**, you can signal this as well. To do so, please use the Diversion header and enter the originally called number there (in the following example, this was written into the variable ORIGEXTEN in the dialplan):

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

Further information can be found in the [configuration guides](https://app.sipgate.com/w0/team/faq/setup/index/id/219).


---

# Agent Instructions: 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:

```
GET https://help.sipgate.de/trunking/en/wie-konfiguriere-ich-asterisk-fuer-sipgate-trunking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
