{"id":23161599,"url":"https://github.com/vvampirius/fail2ban-for-asterisk","last_synced_at":"2026-02-02T22:34:00.971Z","repository":{"id":141937017,"uuid":"533822514","full_name":"vvampirius/fail2ban-for-asterisk","owner":"vvampirius","description":"Blocks Asterisk REGISTER scanners by iptables","archived":false,"fork":false,"pushed_at":"2022-09-09T10:03:07.000Z","size":28,"stargazers_count":1,"open_issues_count":0,"forks_count":3,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-05T18:12:03.302Z","etag":null,"topics":["asterisk-server","pjsip"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vvampirius.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-07T15:17:58.000Z","updated_at":"2023-11-23T01:53:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"446405fc-0b27-403b-a484-8e53892ca6f7","html_url":"https://github.com/vvampirius/fail2ban-for-asterisk","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vvampirius/fail2ban-for-asterisk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvampirius%2Ffail2ban-for-asterisk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvampirius%2Ffail2ban-for-asterisk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvampirius%2Ffail2ban-for-asterisk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvampirius%2Ffail2ban-for-asterisk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vvampirius","download_url":"https://codeload.github.com/vvampirius/fail2ban-for-asterisk/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vvampirius%2Ffail2ban-for-asterisk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":270933701,"owners_count":24670479,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-18T02:00:08.743Z","response_time":89,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["asterisk-server","pjsip"],"created_at":"2024-12-17T23:14:41.207Z","updated_at":"2026-02-02T22:34:00.912Z","avatar_url":"https://github.com/vvampirius.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# fail2ban-for-asterisk\n\nThis tool watch for REGISTER request with \"Failed to authenticate\" in 'journald' for unit 'asterisk' and ban unwanted IP with iptables + **ipset** (and provides metrics for Prometheus monitoring).\n\n\u003e **This tool is not related to [fail2ban](https://github.com/fail2ban/fail2ban) project.**\n\nIt requires Linux with iptables and \u003cu\u003eipset\u003c/u\u003e.\n\nBan rules:\n- IP address will be banned temporary for one hour if it has failed auth only to one user for more than 20 times (in 5 minutes).\n- IP address will be banned permanently if it has failed auth to \u003e1 users for \u003e=3 times in summary (in 5 minutes).\n\n# Usage:\n\n```shell\n./fail2ban-for-asterisk -l 127.0.0.1:8080 -ipset-name asterisk_ban\n```\n\nfail2ban-for-asterisk creates ipset list 'asterisk_ban' on start if not exists and related iptables rule.\n\n```shell\nipset create asterisk_ban hash:ip\niptables -A INPUT -m set --match-set asterisk_ban src -j DROP\n```\n\nFurther, it just adds/removes IPs to the list for ban.\n\n```shell\nipset add asterisk_ban \u003cIP\u003e\n```\n\nMetrics:\n\n```shell\ncurl -s http://127.0.0.1:8080/metrics | egrep '(ipset|ban|auth)'\n# HELP banned Banned counter\n# TYPE banned counter\nbanned{type=\"permanent\"} 250\n# HELP failed_to_authenticate Failed to authenticate mentions in log\n# TYPE failed_to_authenticate counter\nfailed_to_authenticate 1021\n# HELP ipset_entries Count of entries in ipset list\n# TYPE ipset_entries gauge\nipset_entries 251\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvampirius%2Ffail2ban-for-asterisk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvvampirius%2Ffail2ban-for-asterisk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvvampirius%2Ffail2ban-for-asterisk/lists"}