Why my asterisk won't work

Hello I’m having trouble with my asterisk server I’m trying to make calls and get calls with a specific number Here is the errors and the extension.conf and sip.conf Please let me know if I make any changes [general]
context=default
bindport=5060
dtmfmode=rfc2833
disallow=all
allow=alaw
allow=ulaw
allow=gsm
allow=g723
allow=g726
allow=speex

; replace INBOUND_SIP_USERNAME and INBOUND_SIP_PASSWORD
; with your Inbound SIP Registration credentials
register => curlyjoey:testpassword@192.168.100.130

[1001]
type=friend
context=from=internal
host=dynamic
secret=password
disallow=all
allow=ulaw

[1002]
type=friend
context=from-internal
host=dynamic
secret=password
disallow=all
allow=ulaw

[trunk]
type=peer
;host=192.168.100.130 ; North America POP
context=from-trunk
qualify=yes
defaultuser=curlyjoey
remotesecret=testpassword

[trunk]
type=peer
host=192.168.100.130
username=curlyjoey
secret=testpassword
context=from-trunk
qualify=yes

;send all other numbers to outbound trunk
exten => _[0-9].,1,NoOp (#### [from-interrnal] ####)
exten => _[0-9].,n,Set(CALLERID(num)=9546699281)
exten => _[0-9].,n,Dial(SIP/+${EXTEN}@trunk}
exten => _[0-9].,n,Hangup()
[from trunk]
;send all incoming calls from trunk DDI numbers to extension 1002
exten => _[0-9].,1,NoOp(#### [from-trunk] ####)
exten => _[0-9].,n,Dial(SIP/1002)
exten => _[0-9].,n,Hangup()

exten => _1NXXNXXXXXXX,1,Dial(SIP/${EXTEN}@trunk)
exten =>_1NXXNXXXXXX,n,Hangup()
[default]
; Default context to drop unwanted calls
exten => _X.,1,NoOp(### [default] ###)
exten =>_X.,n,Hangup()
[from-internal]
; Internal call between extensions
exten => 1001,1,Dial(SIP/1001)
exten => 1001,n,Hangup()
exten => 1002,1,Dial(SIP/1002)
exten => 1002,n,Hangup()
; Send all other numbers to outbound trunk
exten => _X.,1,NoOp(#### [from-internal] ####)
exten => _X.,n,Set(CALLERID(num)=9546699281)
exten => _X.,n,Dial(SIP/${EXTEN}@trunk)
exten => _X.,n,Hangup()
[from-trunk]
; Route all incoming calls to extension 1002
exten => _X.,1,NoOp(#### [from-trunk] ####)
exten => _X.,n,Dial(SIP/1002)
exten => _X.,n,Hangup()

ERROR[2233][C-0000000b]: pbx_functions.c:700 ast_func_write: Function CallerID not registered

[Nov 26 02:19:52] ERROR[2233][C-0000000b]: netsock2.c:303 ast_sockaddr_resolve: getaddrinfo(“trunk}”, “(null)”, …): Name or service not known

[Nov 26 02:19:52] WARNING[2233][C-0000000b]: chan_sip.c:6410 create_addr: No such host: trunk}

[Nov 26 02:19:52] NOTICE[2233][C-0000000b]: app_dial.c:2750 dial_exec_full: Unable to create channel of type ‘SIP’ (cause 20 - Subscriber absent)

You haven’t actually stated what is happening or what the problem is.

im sorry here is the error ERROR[2233][C-0000000b]: pbx_functions.c:700 ast_func_write: Function CallerID not registered

[Nov 26 02:19:52] ERROR[2233][C-0000000b]: netsock2.c:303 ast_sockaddr_resolve: getaddrinfo(“trunk}”, “(null)”, …): Name or service not known

[Nov 26 02:19:52] WARNING[2233][C-0000000b]: chan_sip.c:6410 create_addr: No such host: trunk}

[Nov 26 02:19:52] NOTICE[2233][C-0000000b]: app_dial.c:2750 dial_exec_full: Unable to create channel of type ‘SIP’ (cause 20 - Subscriber absent)

You are using an obsolete channel driver. You haven’t said which version of Asterisk you are using, but can’t be one of the latest two, as it doesn’t include that driver. As you appear to be starting, you should throw away chan_sip, upgrade to at least Asterisk 21, and use chan_pjsip.

There is no function called CallerID, although there is one called CALLERID.

You have two definitions for the peer trunk, one of which is missing the host line. I think only one will be used and that might be the first one.

You are missing a context name at the start of your extensions.conf.

You have a “from trunk” context that is not used (as well as a form-trunk one, which is. I’m also not sure how spaces are handled in context name.

I don’t believe defaultuser has any effect when the host isn’t dynamic, and is rarely needed even when it is.

Your from trunk is capable of calling toll numbers.

type=friend is probably wrong, but there is not enough information to be sure.

I’m on version 22
I’m going off a video that i seen on a github gotrunk that have configure but instead of use gotrunk I’m using freepbx Here is the link GitHub - GoTrunk/asterisk-config: Asterisk SIP Trunk reference configuration

If you are using version 22, you haven’t installed it cleanly, or you are using a third party fork. You cannot get error messages from chan_sip.c in the official version 22, as the file doesn’t exist in the source code.

Also, you don’t seem to have followed that reference configuration.

As a general principle, you should not use configurations from providers, except as an aid in understanding their real SIP interface. They copy from each other and propagate bad usage, like overuse of friend, and misunderstandings about the purpose of username/defaultuser.

Ok I understand that
But what is the best way for it to work
Any how to rewrite the Syntax to make it call and not say fail to establish a call