Problem with dialplan(lua)

Configured Trunk between 2 asterisk servers. The settings are simple

Dialpan is written

extensions = {
[“ABsip”] = {
["_XXX"] = function (context, exten, trunk) app.dial (“PJSIP /” … exten … “@ABsip”); end

when I dial 222, which is registered at, I call from 111, which is registered at, on both servers I see the following <= A server output is the same, only ip changes

Setting global variable ‘SIPDOMAIN’ to '10 .20.30.222 ’
- Executing [222 @ ABsip: 1] dial (“PJSIP / 404-000007da”, “PJSIP / 222 @ ABsip”)

Setting global variable ‘SIPDOMAIN’ to '10 .20.30.111 ’
- Executing [222 @ ABsip: 1] dial (“PJSIP / ABsip-000007e0”, “PJSIP / 222 @ ABsip”)
- Called PJSIP / 222 @ ABsip

I tried to rewrite the recruitment plan in different ways, but it was unsuccessful, please help.

At the same time, having some kind of magic, a dialpan that works for internal numbers also works at, but I want to understand how to send it to the trunk, and not with magic.

Bellow it

extensions = {
[“ABsip”] = {
["_XXX"] = function(context, exten) app.dial(“PJSIP/”… exten); end

PSJIP diall strings always start PJSIP/endpoint

endpoint must be defined in pjsip.conf.

An endpoint may refer to a single session device, such as a phone, a switching device that accepts URIs, or a dummy endpoint, that provides settings for the call, but isn’t used for routing, and always requires a full URI.

In PSIP/222@ABSip, the whole string is an endpoint name.

Most likely what you want is PSIP/ABSip/222@ABSip.example, where ABSip describes the endpoint of the “trunk”, not that Asterisk actually has the concept of a trunk.

${SIPDOMAIN} is write only relative to the Asterisk binary. It is set for incoming calls (at least for chan_sip), but ignored for outgoing ones.

@david551 looks like you started using PJSIP :grinning: