ipset介绍
iptables是在linux内核里配置防火墙规则的用户空间工具,它实际上是netfilter框架的一部分.可能因为iptables是netfilter框架里最常见的部分,所以这个框架通常被称为iptables,iptables是linux从2.4版本引入的防火墙解决方案.
ipset是iptables的扩展,它允许你创建 匹配整个地址sets(地址集合) 的规则。而不像普通的iptables链是线性的存储和过滤,ip集合存储在带索引的数据结构中,这种结构即时集合比较大也可以进行高效的查找.
除了一些常用的情况,比如阻止一些危险主机访问本机,从而减少系统资源占用或网络拥塞,IPsets也具备一些新防火墙设计方法,并简化了配置.
官网:http://ipset.netfilter.org/
安装
rpm -ivh libmnl-devel-1.0.2-3.el6.x86_64.rpm libmnl-1.0.2-3.el6.x86_64.rpm tar xvf ipset-6.24.tar.bz2 cd ipset-6.24 ./configure make make install
#注意:
如果在centos6.6或其他情况下安装时候,configure报错如下
configure: error: Invalid kernel source directory /lib/modules/2.6.32-358.el6.x86_64/source
解决:需要安装内核源码包kernel-devel-2.6.32-358.el6.x86_64.rpm
创建ipset
ipset -n或者ipset create:
n, create SETNAME TYPENAME [ CREATE-OPTIONS ]
SETNAME是创建的ipset的名称,TYPENAME是ipset的类型:
TYPENAME := method:datatype[,datatype[,datatype]]
method指定ipset中的entry存放的方式,随后的datatype约定了每个entry的格式。
可以使用的method:
bitmap, hash, list
可以使用的datatype:
ip, net, mac, port, iface
添加记录
ipset add用于在ipset中添加记录:
add SETNAME ADD-ENTRY [ ADD-OPTIONS ]
向ipset中添加entry的时候,加入的entry的格式必须与创建ipset是指定的格式匹配。
$ipset creat foo hash:ip,port,ip $ipset add foo ipaddr,portnum,ipaddr $ipset list foo Name: foo Type: hash:ip,port,ip Revision: 2 Header: family inet hashsize 1024 maxelem 65536 Size in memory: 16584 References: 0 Members: 192.168.1.2,tcp:80,192.168.1.3
删除记录
ipset del用于从ipset中删除记录:
del SETNAME DEL-ENTRY [ DEL-OPTIONS ]
查询记录
ipset test可以检查目标entry是否在ipset中:
test SETNAME TEST-ENTRY [ TEST-OPTIONS ]
ipset list可以查看ipset的所有内容:
list [ SETNAME ] [ OPTIONS ]
导出导入
ipset save可以导出所有的ipset:
save [ SETNAME ]
ipset restore则用于将导出的内容导入。
其它
flush [ SETNAME ] Flush all entries from the specified set or flush all sets if none is given. e, rename SETNAME-FROM SETNAME-TO Rename a set. Set identified by SETNAME-TO must not exist. w, swap SETNAME-FROM SETNAME-TO Swap the content of two sets, or in another words, exchange the name of two sets. The referred sets must exist and identical type of sets can be swapped only. help [ TYPENAME ] Print help and set type specific help if TYPENAME is specified. version Print program version. - If a dash is specified as command, then ipset enters a simple interactive mode and the commands are read from the standard input. The interactive mode can be finished by entering the pseudo-command quit.
在iptables中使用ipset
在iptables中可以使用-m set
启用ipset模块,例如。
-A POSTROUTING -m set --match-set felix-masq-ipam-pools src -m set ! --match-set felix-all-ipam-pools dst -j MASQUERADE
iptables的set模块:
set This module matches IP sets which can be defined by ipset(8). [!] --match-set setname flag[,flag]... where flags are the comma separated list of src and/or dst specifications and there can be no more than six of them. Hence the command iptables -A FORWARD -m set --match-set test src,dst ...
在TARGET中也可以操作ipset:
SET This module adds and/or deletes entries from IP sets which can be defined by ipset(8). --add-set setname flag[,flag...] add the address(es)/port(s) of the packet to the set --del-set setname flag[,flag...] delete the address(es)/port(s) of the packet from the set where flag(s) are src and/or dst specifications and there can be no more than six of them. ...
在man iptables-extensions
中可以找到set module
和SET TARGET
的所有选项。
总结
以上就是这篇文章的全部内容了,希望本文的内容对大家的学习或者工作具有一定的参考学习价值,如果有疑问大家可以留言交流,谢谢大家对的支持。
免责声明:本站文章均来自网站采集或用户投稿,网站不提供任何软件下载或自行开发的软件! 如有用户或公司发现本站内容信息存在侵权行为,请邮件告知! 858582#qq.com
RTX 5090要首发 性能要翻倍!三星展示GDDR7显存
三星在GTC上展示了专为下一代游戏GPU设计的GDDR7内存。
首次推出的GDDR7内存模块密度为16GB,每个模块容量为2GB。其速度预设为32 Gbps(PAM3),但也可以降至28 Gbps,以提高产量和初始阶段的整体性能和成本效益。
据三星表示,GDDR7内存的能效将提高20%,同时工作电压仅为1.1V,低于标准的1.2V。通过采用更新的封装材料和优化的电路设计,使得在高速运行时的发热量降低,GDDR7的热阻比GDDR6降低了70%。
更新日志
- [ABC]安娜-胆麦发烧女声[6N纯银镀膜][2016[低速原抓WAV+CUE]
- 任天堂今晚举行直面会!第三方及独立游戏展示
- 《哆啦A梦的铜锣烧店物语》发售!开罗公式+哆啦A梦
- 任天堂公布《塞尔达传说》系列时间线:野炊与王泪独立在外
- 五条人.2012-一些风景2CD【刀马旦】【WAV+CUE】
- 陈奕迅.2013-Easons.Life演唱会2CD(2024环球红馆40复刻系列)【环球】【WAV+CUE】
- 许美静.1995-遗憾(新马版)【上华】【WAV+CUE】
- 《叶倩文 歌声情缘》[WAV+CUE][410MB]
- 《张国荣 首首动听经典不容错过 追忆的风 2CD》[WAV+CUE][870MB]
- 《腾格尔 容中尔甲 亚东 高原三星 男人篇 3CD》[WAV/分轨][1GB]
- 命运圣契公测实测可用兑换码大全 命运圣契最新兑换码分享
- 黑神话悟空上品疾蝠精魄获取方法一览|上品疾蝠精魄收集攻略
- 《七龙珠电光炸裂!ZERO》GT角色预告片曝光,15位新角色登场
- [ABC]安娜-胆麦发烧女声[6N纯银镀膜][2016[低速原抓WAV+CUE]
- NewViennaOctetViennaWindSoloists-TheDeccaRecordings(2024)18CD[24-48][FLAC]-7