CentOS / RHEL: Install ipset Administration Tool For IP Sets and IPTables
You can install the ipset administration tool on CentOS and RHEL by using the package manager yum.
Here's how to install ipset:
- Update the package index:
sudo yum update- Install the
ipsetpackage:
sudo yum install ipsetAfter 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 DROPIn 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.
