Skip to content
TrySitePrice

CentOS / RHEL: Install ipset Administration Tool For IP Sets and IPTables

Best/Tutorial

You can install the ipset administration tool on CentOS and RHEL by using the package manager yum.

Here's how to install ipset:

  1. Update the package index:
sudo yum update
  1. Install the ipset package:
sudo yum install ipset

After the installation is complete, you can use the ipset command to manage IP sets and IPTables. For example, you can create a new IP set, add an IP address to it, and then use the set in an IPTables rule to block incoming traffic from that address:

sudo ipset create blocklist hash:iprnsudo ipset add blocklist 192.168.1.100
sudo iptables -A INPUT -m set --match-set blocklist src -j DROP

In this example, the ipset create command creates a new IP set named "blocklist" that uses the "hash:ip" type to store IP addresses. The ipset add command adds the IP address 192.168.1.100 to the set. The iptables command creates a new IPTables rule that matches incoming traffic using the "blocklist" set and drops any matching packets.