麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 服務器 > Linux服務器 > 正文

linux中ipset命令的使用方法詳解

2024-09-05 23:04:19
字體:
來源:轉載
供稿:網(wǎng)友

ipset介紹

iptables是在linux內(nèi)核里配置防火墻規(guī)則的用戶空間工具,它實際上是netfilter框架的一部分.可能因為iptables是netfilter框架里最常見的部分,所以這個框架通常被稱為iptables,iptables是linux從2.4版本引入的防火墻解決方案.

ipset是iptables的擴展,它允許你創(chuàng)建 匹配整個地址sets(地址集合) 的規(guī)則。而不像普通的iptables鏈是線性的存儲和過濾,ip集合存儲在帶索引的數(shù)據(jù)結構中,這種結構即時集合比較大也可以進行高效的查找.

除了一些常用的情況,比如阻止一些危險主機訪問本機,從而減少系統(tǒng)資源占用或網(wǎng)絡擁塞,IPsets也具備一些新防火墻設計方法,并簡化了配置.

官網(wǎng):http://ipset.netfilter.org/

安裝

rpm -ivh libmnl-devel-1.0.2-3.el6.x86_64.rpm libmnl-1.0.2-3.el6.x86_64.rpmtar xvf ipset-6.24.tar.bz2cd ipset-6.24./configuremakemake install

#注意:

如果在centos6.6或其他情況下安裝時候,configure報錯如下

configure: error: Invalid kernel source directory /lib/modules/2.6.32-358.el6.x86_64/source

解決:需要安裝內(nèi)核源碼包kernel-devel-2.6.32-358.el6.x86_64.rpm

創(chuàng)建ipset

ipset -n或者ipset create:

 n, create SETNAME TYPENAME [ CREATE-OPTIONS ]

SETNAME是創(chuàng)建的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的格式必須與創(chuàng)建ipset是指定的格式匹配。

$ipset creat foo hash:ip,port,ip$ipset add foo ipaddr,portnum,ipaddr$ipset list fooName: fooType: hash:ip,port,ipRevision: 2Header: family inet hashsize 1024 maxelem 65536Size in memory: 16584References: 0Members: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的所有內(nèi)容:

list [ SETNAME ] [ OPTIONS ]

導出導入

ipset save可以導出所有的ipset:

save [ SETNAME ]

ipset restore則用于將導出的內(nèi)容導入。

其它

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模塊:

setThis 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:

SETThis 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 moduleSET TARGET的所有選項。

總結

以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學習或者工作具有一定的參考學習價值,如果有疑問大家可以留言交流,謝謝大家對VEVB武林網(wǎng)的支持。

 

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 九九热在线免费观看视频 | 午夜精品福利影院 | 爱高潮www亚洲精品 欧美黄色一级片视频 | 欧美精品国产综合久久 | 7777久久香蕉成人影院 | 免费午夜视频 | 水卜樱一区二区av | 麻豆19禁国产青草精品 | 法国性xxx精品hd | 亚洲性在线视频 | 91福利国产在线观一区二区 | 欧美激情 在线播放 | 欧美中文在线 | 一区二区三区国产在线 | 中文字幕欧美一区二区三区 | 国产精品久久久久久久久久久久午夜 | 天天草天天爱 | 国产毛片在线 | 99精品国产一区二区三区 | 日韩黄色精品视频 | 欧美黄色一区 | 精品xxxx户外露出视频 | 免费观看黄色一级视频 | 欧美一极视频 | 毛片大全 | 欧美aⅴ视频| 午夜免费一区 | 最近日本电影hd免费观看 | 久久精品久久精品久久精品 | 亚洲一区二区中文 | 黄色大片网站在线观看 | www.7777在线 | 亚洲乱妇19p | 日韩黄色免费在线观看 | h视频在线播放 | 久久久久久久久久亚洲精品 | 99激情| 国产精品美女一区二区 | 欧美精品a∨在线观看不卡 午夜精品影院 | 国产一区二区三区四区在线 | 女人裸体让男人桶全过程 |