How to delete an extension via CLI

I had mis-configured my trunk URI and asterisk was giving an error and admin console was saying “Cannot connect to Asterisk”. Console would not let me edit the bad uri. So I used a VNC connection to server and manually edited files carefully to fix the bad uri.

After that “asterisk -r” showed that error went away. The full log also showed that the error was fixed.

But I was still getting “Cannot connect to Asterisk” in admin console. I did “fwconsole restart” a few times.

The fill log shows:

  • trunk uri is now reachable (good)
  • Several “Failed to authenticate” (bad). See screenshot for details. I think this has to do with something wrong with my extension configuration. The 1 is likely my extension “1” and the IP (111.111.11.11 in example) is the WAN address for my linux laptop in uri mentioned in error mesages sip:[email protected]. So It seems I should delete extension 1 to resolve the problem.

What I do not understand is why I cannot reach my freepbx admin console so I can look at and fix any mistakes with extension configuration or delete the extension.

To recover, how can I remove my extension “1” which is giving the error in full log. TIA for your help.

I manually deleted from extensions and devices table entries for my extension:

mysql -u root -D asterisk -e "delete  from users where extension = '1'"
mysql -u root -D asterisk -e "delete  from devices where id like '1'"

After that I did fwconsole restart.

I am still seeing the errors in the full log and the admin console still does not show up. Please advise.

Try:
fwconsole chown

Thanks to help from freepbxhosting.com the issue is resolved.

First problem (deleting extensions) was done using mysql commands in previous post. You would need to replace ‘1’ with the extension you are trying to delete. The following resource guided this:

Second problem, the reason why GUI was not available was that I had the WAN IP for my local networkl banned by fail2ban which scans logs for certain security related errors and bans an IP which caused it.

The following resource helped identify the root cause of the ban and to unban my ip:

[1] https://www.freepbxhosting.com/how-to-help-ive-been-blocked-from-my-pbx/

The root cause was that I had some setup a softphone (Voiper) with incorrect configuration.

To fix the problem I had to:

  • Delete the bad account config on the softphone so it does not keep causing the problem
  • grep for the incorrect configuration in config files with /etc/asterisk folder and then manually edit them to fix or remove bad configuration.

I then repeated the steps to unban in [1] and after that I am back to normal.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.