RepositoryGoDEGermany
janeczku

janeczku/go-ipset

:fire: Go bindings for the IPtables ipset http://ipset.netfilter.org userspace utility

127stars
53forks
2issues
1views

go-ipset

This library is a simple GoLang wrapper to the IPtables ipset userspace utility. It provides an interface to allow Go programs to easily manipulate ipsets. It is currently limited to sets of type hash.

For ipset command documentation: http://ipset.netfilter.org/ipset.man.html

go-ipset requires ipset kernel module and userspace utility version 6.0 or greater.

Installation

Install go-ipset using the "go get" command:

go get github.com/janeczku/go-ipset/ipset

Install dependencies:

go get github.com/Sirupsen/logrus
go get github.com/coreos/go-semver/semver

API Reference

GoDoc

Usage

import "github.com/janeczku/go-ipset/ipset

Create a new set

Construct a new IPset instance (creating the set on the fly), then use the various methods to manipulate the IPset. For example, to create a new ipset "customers" of type hash:ip for storing plain IPv4 addresses:

customers := ipset.New("customers", "hash:ip", &ipset.Params{})

To create a new ipset to store different sized IPv4 network addresses (with /mask).

trustedNetworks := ipset.New("trusted-networks", "hash:net", &ipset.Params{})

Add a single entry to the set

customers.Add("8.8.2.2")

Populate the set with IPv4 addresses (overwriting the previous content)

ips := []string{"8.8.8.8", "8.8.4.4"}
customers.Refresh(ips)

Remove a single entry from that set:

customers.Del("8.8.8.8")

Configure advanced set options

You can configure advanced options when creating a new set by supplying the parameters in the ipset.Params struct.

type Params struct {
  HashFamily string
  HashSize   int
  MaxElem    int
  Timeout    int
}

See http://ipset.netfilter.org/ipset.man.html for their meaning.

For example, to create a set whose entries will expire after 60 seconds, lets say for temporarily limiting abusive clients:

abusers := ipset.New("ratelimited", "hash:ip", &ipset.Params{Timeout: 60})

List entries of a set

// list is []string
list ipset.List("customers")

Similar Projects

Discover other similar projects and AI models.

RepositoryGo
avelino/awesome-go

A curated list of awesome Go frameworks, libraries and software

197.2k
Dec 2, 2026
RepositoryGo
ollama/ollama

Get up and running with Inkling, Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

188.9k
Dec 2, 2026
Repository
stamparm/ipsum

Daily feed of bad IPs (with blacklist hit scores)

2.4k
Dec 1, 2026
RepositoryShell
firehol/firehol

A firewall for humans...

1.6k
Mar 31, 2026
RepositoryPython
firewalld/firewalld

Stateful zone based firewall daemon with D-Bus interface

1.1k
Oct 31, 2026
RepositoryShell
Adamm00/IPSet_ASUS

Skynet - IPv4 firewall protection, threat feeds and traffic visibility for Asuswrt-Merlin. Manage your network through the WebUI or SSH.

447
Oct 31, 2026
RepositoryShell
AliDbg/IPBAN

⚔️🧱🔥🛑IP BAN Block Allow GEOIP country traffic limit server input/output to IP countries with iptables+xt_geoip, auto db-ip update, firewall fail2ban gfw ufw cidr blacklist netfilter rules persistent restrict netaddr xtables linux debian ubuntu apache nginx web server anti hack ddos firewalld ipblocks ipdeny ip ranges MaxMind ipset

152
Feb 1, 2024
RepositoryShell
maravento/blackip

IPv4 Blacklist for Ipset or Squid-Cache

116
Nov 22, 2026
RepositoryShell
rfxn/advanced-policy-firewall

iptables/netfilter firewall for Linux servers with stateful filtering, trust system, ipset block lists, SYN flood protection, VNET per-IP policies, and Docker support

116
May 22, 2026