# \[Solved\] CLI output and operation are different

**URL:** <https://community.asterisk.org/t/solved-cli-output-and-operation-are-different/77263>\
**Category:** Asterisk Dialplan\
**Created:** [November 22, 2018, 3:11am UTC](https://community.asterisk.org/t/solved-cli-output-and-operation-are-different/77263 "2018-11-22T03:11:19Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![fono09](https://avatars.discourse-cdn.com/v4/letter/f/b782af/32.png) [@fono09](https://community.asterisk.org/u/fono09)\
**Post date:** [November 22, 2018, 3:11am UTC](https://community.asterisk.org/t/solved-cli-output-and-operation-are-different/77263/1 "2018-11-22T03:11:19Z")

</div>

Hello, I have problem about pattern matching.

I can not call 801 and 802 bidirectionally, but I can call them all at 800.  
Do you have any suggestions?

sip.conf

```auto
[801]
context=from_phone
type=friend
secret=XXX
canreinvite=no
host=dynamic
dtmfmode=rfc2833

[802]
context=from_phone
type=friend
secret=XXX
canreinvite=no
host=dynamic
dtmfmode=rfc2833

[803]
context=from_phone
type=friend
secret=XXX
canreinvite=no
host=dynamic
dtmfmode=rfc2833

```

extensions.conf

```auto
[from_phone]
exten => 800,1,Dial(SIP/801&SIP/802&SIP/803)
exten => 80Z,n,Dial(SIP/${EXTEN},30)
exten => _X.,n,Set(CALLERID(num)=XXXXXXXX)
exten => _X.,n,Dial(SIP/gw/${EXTEN})

```

Output of CLI  
dialplan show 801@from\_phone, and notification when calling from 801 to 802.

```auto
CLI> dialplan show 801@from_phone
[Context 'from_phone' created by 'pbx_config']
  '_80Z' => 2. Dial(SIP/${EXTEN},30) [extensions.conf:870]
  '_X.' => 3. Set(CALLERID(num)=XXXXXXX) [extensions.conf:871]
                    4. Dial(SIP/gw/${EXTEN}) [extensions.conf:872]

-= 2 extensions (3 priorities) in 1 context. =-
[Nov 22 02:45:50] NOTICE[67][C-00000018]: chan_sip.c:26512 handle_request_invite: Call from '802' (192.168.0.3:5060) to extension '801' rejected because extension not found in context 'from_phone'.
CLI>

```

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [November 22, 2018, 12:22pm UTC](https://community.asterisk.org/t/solved-cli-output-and-operation-are-different/77263/2 "2018-11-22T12:22:03Z")

</div>

Your sip.conf doesn’t match the dialplan show output.

You don’t have a priority one for the pattern \_80Z, assuming that the dialplan show output is correct, in relation to the the use of \_.

Also:  
type=friend is inadvisable, except in special cases (can lead to mis-operation and security breaches)

canreinvite is deprecated in favour of direct media (indicates a failure to code from first principles, but currently they are treated as synonyms).

---

<div class="post-metadata">

**Author:** ![poing](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/poing/32/1696_2.png) [@poing](https://community.asterisk.org/u/poing)\
**Post date:** [November 22, 2018, 12:23pm UTC](https://community.asterisk.org/t/solved-cli-output-and-operation-are-different/77263/3 "2018-11-22T12:23:26Z")

</div>

Look closely at how you used `n` (next priority) in the dialplan.  
`80Z` does **not** have a _previous_ priority.

```auto
[from_phone]
exten => 800,1,Dial(SIP/801&SIP/802&SIP/803)
exten => 80Z,n,Dial(SIP/${EXTEN},30)
exten => _X.,n,Set(CALLERID(num)=XXXXXXXX)
exten => _X.,n,Dial(SIP/gw/${EXTEN})

```

* * *

I prefer `same` to avoid this kind of issue. I also start **every** pattern with `NoOp()` and a comment inside.

```auto
exten => 501,1,NoOp(test)
 same => n,NoOp(do something)
 same => n,HangUp()
exten => 502,1,NoOp(another one)
 same => n,NoOp(something else)
 same => n,HangUp()

```

---

<div class="post-metadata">

**Author:** ![fono09](https://avatars.discourse-cdn.com/v4/letter/f/b782af/32.png) [@fono09](https://community.asterisk.org/u/fono09)\
**Post date:** [November 22, 2018, 2:32pm UTC](https://community.asterisk.org/t/solved-cli-output-and-operation-are-different/77263/4 "2018-11-22T14:32:09Z")

</div>

Thanks a lot david551, poing

I fixed following points, and It seemed like it should be.

- every extension has 1st priority
- change type friend to peer
- canreinvite replaced by dicretmedia(allow|deny)
- use NoOp() comment

sip.conf example

```auto
[801]
context=from_phone
type=peer
secret=XXXX
host=dynamic
dtmfmode=rfc2833
directmediadeny=0.0.0.0/0
directmediaallow=192.168.X.X/24

```

extensions.conf

```auto
exten => 800,1,NoOp(Call all phones)
same => n,Dial(SIP/801&SIP/802&SIP/803)
same => n,HangUp()
exten => 80Z,1,NoOp(Call each phones)
same => n,Dial(SIP/${EXTEN},30)
same => n,HangUp()
exten => _X.,1,NoOp(OutsideLine)
same => n,Set(CALLERID(num)=XXXXXXXX)
same => n,Dial(SIP/gw/${EXTEN})
same => n,HangUp()

```
