ipset基本用法 
1.创建ipset集合  
创建一个新的ipset集合:ipset create SETNAME TYPENAME  ipset create bb hash:ip  
2.向集合中添加条目  ipset add bb 2.2.2.2  ipset add bb 192.168.10.21-192.168.10.31  
3.查询条目  ipset list  ipset list aa  
4.检查目标ip是否在ipset集合中  ipset test aa 1.1.1.1  
5.删除条目  ipset del aa 1.1.1.1  
6.清空ipset中所有集合的ip条目(删条目,不删集合)  ipset flush aa  
7.删除ipset中的某个集合或者所有集合:ipset destroy [SETNAME]  ipset destroy aa  
SET TYPES 集合类型  method存储方式:  存储方式有 bitmap, hash, list;  
datatype数据类型:  支持的类型有:ip, net, mac, port, iface,即除了ip外,还可以是网络段,端口号(支持指定 TCP/UDP 协议),mac 地址,网络接口名称,或者多种。在创建的时候,指定是什么类型,在添加的时候,数据就要按照对应的格式来,不然就会报错  
hash:ip,port  ipset create aa hash:ip,port  ipset add aa 1.1.1.1,22  
需要保存配置,不然重启会失效 
ipset save a -f /root/a.ipset  /sbin/ipset restore -f /root/a.ipset #写到/etc/rc.d/rc.local中给执行权限 
                
                
                
        
    
 
 |