All Projects → janeczku → go-ipset

janeczku / go-ipset

Licence: Apache-2.0 license
🔥 Go bindings for the IPtables ipset http://ipset.netfilter.org userspace utility

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to go-ipset

ipset-netgear-r7000-dd-wrt
Packages and kernel modules for ipset support for the Netgear R7000 running DD-WRT firmware
Stars: ✭ 45 (-59.09%)
Mutual labels:  iptables, ipset
blackip
IP Blocklist for Ipset / Squid-Cache
Stars: ✭ 81 (-26.36%)
Mutual labels:  iptables, ipset
Piadvanced
This started as a custom install for my pihole!
Stars: ✭ 144 (+30.91%)
Mutual labels:  iptables
Mignis
Mignis is a semantic based tool for firewall configuration.
Stars: ✭ 43 (-60.91%)
Mutual labels:  iptables
Net Shield
An Easy and Simple Anti-DDoS solution for VPS,Dedicated Servers and IoT devices - Beta
Stars: ✭ 202 (+83.64%)
Mutual labels:  iptables
Easywall
Web interface for easy use of the IPTables firewall on Linux systems written in Python3.
Stars: ✭ 172 (+56.36%)
Mutual labels:  iptables
Zjl
ZJL 免流防跳脚本
Stars: ✭ 222 (+101.82%)
Mutual labels:  iptables
Vpnfailsafe
IP leak prevention for OpenVPN
Stars: ✭ 130 (+18.18%)
Mutual labels:  iptables
UnboundBL
🛑 DNSBL (adblock) on OPNsense with UnboundBL & Unbound DNS
Stars: ✭ 63 (-42.73%)
Mutual labels:  iptables
Secure Wireguard Implementation
A guide on implementing a secure Wireguard server on OVH (or any other Debian VPS) with DNSCrypt, Port Knocking & an SSH-Honeypot
Stars: ✭ 200 (+81.82%)
Mutual labels:  iptables
k8s-custom-iptables
How to add custom iptables rules to a Kubernetes cluster
Stars: ✭ 52 (-52.73%)
Mutual labels:  iptables
Ipset asus
Skynet - Advanced IP Blocking For ASUS Routers Using IPSet.
Stars: ✭ 186 (+69.09%)
Mutual labels:  iptables
Config
Various program configuration files and scripts
Stars: ✭ 173 (+57.27%)
Mutual labels:  iptables
Iptables Boilerplate
rock solid default firewall-rules for webhosts
Stars: ✭ 249 (+126.36%)
Mutual labels:  iptables
Afwall
AFWall+ (Android Firewall +) - iptables based firewall for Android
Stars: ✭ 2,024 (+1740%)
Mutual labels:  iptables
dog
A firewall management system.
Stars: ✭ 67 (-39.09%)
Mutual labels:  iptables
Kube Router
Kube-router, a turnkey solution for Kubernetes networking.
Stars: ✭ 1,814 (+1549.09%)
Mutual labels:  iptables
Ipt2socks
utility for converting iptables(redirect/tproxy) to socks5
Stars: ✭ 183 (+66.36%)
Mutual labels:  iptables
Polycube
eBPF/XDP-based software framework for fast network services running in the Linux kernel.
Stars: ✭ 217 (+97.27%)
Mutual labels:  iptables
xt NAT
Full Cone NAT module for Linux iptables
Stars: ✭ 65 (-40.91%)
Mutual labels:  iptables

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")
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].