akmalovaa / mikroseclist

Mikrotik CrowdSec firewall address lists sync
3 stars 0 forks source link

routeros_api.exceptions.RouterOsApiConnectionError: [Errno -2] Name or service not known #1

Closed zengateway closed 3 months ago

zengateway commented 3 months ago

Hello! Please help, my Crowdsec Blocklist is running and worked, i can see ip list on http://LOCALIP/security/blocklist?ipv4only, on Mikrotik api-ssl is enabled, certificates was created and signed, but i got an error

08.08.24 11:13:30 INFO Mikrotik firewall address list sync started

08.08.24 11:13:30 INFO Fetch firewall address list: block

08.08.24 11:13:30 INFO Success connection to host: '192.168.101.1'

Traceback (most recent call last):

  File "/usr/local/lib/python3.11/site-packages/routeros_api/api_socket.py", line 16, in get_socket

    api_socket.connect((hostname, port))

socket.gaierror: [Errno -2] Name or service not known

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

  File "<frozen runpy>", line 198, in _run_module_as_main

  File "<frozen runpy>", line 88, in _run_code

  File "/srv/mikroseclist/main.py", line 113, in <module>

    sync_addres_list()

  File "/srv/mikroseclist/main.py", line 67, in sync_addres_list

    mikrotik_block_list: list  = mikrotik.fetch_address_list()

                                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/srv/mikroseclist/mikrotik_client.py", line 39, in fetch_address_list

    mikrotik_api = self.connection.get_api()

                   ^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/routeros_api/api.py", line 45, in get_api

    self.socket = api_socket.get_socket(self.host, self.port,

                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

  File "/usr/local/lib/python3.11/site-packages/routeros_api/api_socket.py", line 19, in get_socket

    raise exceptions.RouterOsApiConnectionError(e)

routeros_api.exceptions.RouterOsApiConnectionError: [Errno -2] Name or service not known
akmalovaa commented 3 months ago

Hi. What was the problem and how was it solved? I want to completely rewrite this service and make it more convenient

zengateway commented 3 months ago

Hi. What was the problem and how was it solved? I want to completely rewrite this service and make it more convenient

Hello. I changed docker compose it was like this:

  mikroseclist:
    image: ghcr.io/akmalovaa/mikroseclist:latest
    container_name: mikroseclist
    command: ["python", "-m", "mikroseclist.main"]
    environment:
      MIKROTIK_HOST: ${MIKROTIK_HOST:-'192.168.101.1'}
      MIKROTIK_USER: ${MIKROTIK_USER:-'crowdsec'}
      MIKROTIK_PASSWORD: ${MIKROTIK_PASSWORD:-'password'}
      BLOCKLIST_URL: 'http://crowdsec-blocklist:41412/security/blocklist?ipv4only'
      SYNC_INTERVAL_MIN: 15
    restart: unless-stopped

working docker-compose:

mikroseclist:
    image: ghcr.io/akmalovaa/mikroseclist:latest
    container_name: mikroseclist:
    command: ["python", "-m", "mikroseclist.main"]
    environment:
      MIKROTIK_HOST: 192.168.101.1
      MIKROTIK_USER: crowdsec
      MIKROTIK_PASSWORD: password
      BLOCKLIST_URL: http://crowdsec-blocklist:41412/security/blocklist?ipv4only
      SYNC_INTERVAL_MIN: 15
restart: unless-stopped

but i got new error #2

akmalovaa commented 3 months ago

Thanks