Problem registering a sip extension

I have a problem with extension 1008 is not registering and in the log i get this

[2016-06-02 21:53:59] SECURITY[20942] res_security_log.c: SecurityEvent="ChallengeSent",EventTV="2016-06-02T21:53:59.328-0300",Severity="Informational",Service="SIP",EventVersion="1",AccountID="1008",SessionID="0x7fb2c034fce8",LocalAddress="IPV4/UDP/192.168.1.50/5060",RemoteAddress="IPV4/UDP/192.168.40.40/5060",Challenge="1b667289"

Could someone give some help with this??

Thanks

Not enough log lines but possibly extension 1008 did not respond to the challenge appropriately because you probably have

alwaysauthreject=yes

Where can i check this.?

Sorry i put here 2 complete lines from the log. The line repeats every 4 seconds

[2016-06-03 06:21:23] SECURITY[20942] res_security_log.c: SecurityEvent=“ChallengeSent”,EventTV=“2016-06-03T06:21:23.086-0300”,Severity=“Informational”,Service=“SIP”,EventVersion=“1”,AccountID=“1008”,SessionID=“0x7fb2c008a278”,LocalAddress=“IPV4/UDP/192.168.1.50/5060”,RemoteAddress=“IPV4/UDP/192.168.40.40/5060”,Challenge=“3d932320”
[2016-06-03 06:21:27] SECURITY[20942] res_security_log.c: SecurityEvent=“ChallengeSent”,EventTV=“2016-06-03T06:21:27.120-0300”,Severity=“Informational”,Service=“SIP”,EventVersion=“1”,AccountID=“1008”,SessionID=“0x7fb2c008a278”,LocalAddress=“IPV4/UDP/192.168.1.50/5060”,RemoteAddress=“IPV4/UDP/192.168.40.40/5060”,Challenge=“3d932320”

What is the device at 192.16840.40 ( ext 1008) and how does it differ from the working devices?

There’s something spooky going on here. Check your network setup, specifically netmasks or VLAN setups. I’m going to guess that you’re not getting traffic from one place to the other.

192.168.1.50 is Asterisk IP

Extension 1008 is conecting from outside (WAN) but its IP is not 192.168.40.40, its public IP is 200.xxx.xxx.xxx

Today i conect another extension, 1014. This extension registers ok but can not stablish calls and in the log appears the same

[2016-06-03 11:55:21] SECURITY[20942] res_security_log.c: SecurityEvent=“ChallengeSent”,EventTV=“2016-06-03T11:55:21.663-0300”,Severity=“Informational”,Service=“SIP”,EventVersion=“1”,AccountID=“1014”,SessionID=“0x7fb2c005f388”,LocalAddress=“IPV4/UDP/192.168.1.50/5060”,RemoteAddress=“IPV4/UDP/190.123.110.216/5060”,Challenge=“6ac40fc3”
[2016-06-03 11:55:21] SECURITY[20942] res_security_log.c: SecurityEvent=“SuccessfulAuth”,EventTV=“2016-06-03T11:55:21.720-0300”,Severity=“Informational”,Service=“SIP”,EventVersion=“1”,AccountID=“1014”,SessionID=“0x7fb2c005f388”,LocalAddress=“IPV4/UDP/192.168.1.50/5060”,RemoteAddress=“IPV4/UDP/190.123.110.216/5060”,UsingPassword=“1”

I would investigate your natting/routing this time 190.123.110.216 replied with a successfulauth

Yes the extension registers in asterisk but when i call it appears “failled call”

This is the vlan configuration.

I agree with @dicko on this one. There’s definitely some hinkiness going on with your networking.

The “remote” address on the first one should be a routable address if that phone is outside the local network, and the “NAT” setting on the phone should be supplying the external address for the network.

In the second one, the remote address is more correct, but there’s still some kinds of problems with the network.

At the least, I’m going to guess there’s a network firewall issue, possibly at both ends, that are keeping this from working. It may be NAT, it may be blocked port(s), it’s hard to say at this point.

Also, some phones require access to a “STUN” server, which you’ll need to set up in the firewall as well.

I was checking Network Settings and i put netmask 255.255.255.0

but when i save the changes netmask is 24

Could it be the problem??

No , 255.255.255.0 is the same as 24 for netmask, your problem is likely starting in your NAT setup and compounded by your firewall/routing setup on 192.168.1.1

I rebooted asterisk just for testing and now freepbx says “Can not connect to Asterisk”

This is the log

[2016-06-03 13:47:02] VERBOSE[20841] asterisk.c: Asterisk uncleanly ending (0).
[2016-06-03 13:47:02] VERBOSE[20841] asterisk.c: Executing last minute cleanups
[2016-06-03 13:47:02] WARNING[20841] res_odbc.c: res_odbc: Error SQLConnect=-1 errno=2002 [unixODBC][MySQL][ODBC 5.1 Driver]Can’t connect to local MySQL server through socket '/var/lib/mysq
[2016-06-03 13:47:02] WARNING[20841] cdr_adaptive_odbc.c: cdr_adaptive_odbc: Unable to retrieve database handle for ‘asteriskcdrdb:cdr’. CDR failed: INSERT INTO cdr (
[2016-06-03 13:47:02] WARNING[20841] res_odbc.c: res_odbc: Error SQLConnect=-1 errno=2002 [unixODBC][MySQL][ODBC 5.1 Driver]Can’t connect to local MySQL server through socket '/var/lib/mysq
[2016-06-03 13:47:02] WARNING[20841] cdr_adaptive_odbc.c: cdr_adaptive_odbc: Unable to retrieve database handle for ‘asteriskcdrdb:cdr’. CDR failed: INSERT INTO cdr (
[2016-06-03 13:47:02] WARNING[20841] res_odbc.c: res_odbc: Error SQLConnect=-1 errno=2002 [unixODBC][MySQL][ODBC 5.1 Driver]Can’t connect to local MySQL server through socket '/var/lib/mysq
[2016-06-03 13:47:02] WARNING[20841] cdr_adaptive_odbc.c: cdr_adaptive_odbc: Unable to retrieve database handle for ‘asteriskcdrdb:cdr’. CDR failed: INSERT INTO cdr (

That is a different problem that you will need to fix first, use the search icon above (it looks like a magnifying glass). . .