Files
routeros-geoip/README.md
Steven Polley b1ed8f75ec mondern slopify hand crafted code for the greater good.
(move from user specified blocklist download URLs to simply country codes with multiple providers available.)
2026-05-01 17:18:50 -06:00

1.8 KiB

routeros-geoip

Generate RouterOS address lists from GeoIP data for MikroTik routers. Supports multiple data providers for flexibility and redundancy.

Supported Providers

Provider Source URL
ipverse (default) RIR data via GitHub ipverse/country-ip-blocks
ipdeny RIR data via ipdeny.com ipdeny.com

Configuration

Create a JSON config file specifying your list name, provider, and countries (ISO 3166-1 alpha-2 codes):

{
    "list_name": "GeoBlock",
    "provider": "ipverse",
    "countries": [
        "ca",
        "au"
    ]
}

Configuration Fields

Field Required Default Description
list_name Yes RouterOS address list name
provider No ipverse GeoIP data provider
countries Yes ISO 3166-1 alpha-2 country codes

Usage

# Build
go build -o routeros-geoip .

# Generate blocklist
./routeros-geoip blocklist.json

# Import on your MikroTik router
/import CountryIPBlocks.rsc

Example Output

The generated .rsc file includes metadata headers and cleans up old entries before importing:

# RouterOS GeoIP Address List: CountryIPBlocks
# Generated: 2026-05-01T22:44:48Z
# Countries: 14
# Total entries: 33210
#
/ip firewall address-list remove [find list=CountryIPBlocks]
/ip firewall address-list
add address=24.152.0.0/19 comment="BRAZIL" list=CountryIPBlocks
add address=45.4.4.0/22 comment="BRAZIL" list=CountryIPBlocks
...

Adding a New Provider

Implement the Provider interface:

type Provider interface {
    Name() string
    FetchCIDRs(countryCode string) ([]string, error)
}

Then register it in NewProvider() in provider.go.