欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

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

 更新時(shí)間:2017年11月04日 10:24:31   作者:lijiaocn  
ipset是linux kernel的一個(gè)功能,可以將ip等組合成一個(gè)ipset,在iptables中可以直接指定ipset。下面這篇文章主要給大家介紹了關(guān)于linux中ipset命令的使用方法,文中介紹的非常詳細(xì),需要的朋友們下面來(lái)一起學(xué)習(xí)學(xué)習(xí)吧。

ipset介紹

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

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

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

官網(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.rpm
tar xvf ipset-6.24.tar.bz2
cd ipset-6.24
./configure
make
make install

#注意:

如果在centos6.6或其他情況下安裝時(shí)候,configure報(bào)錯(cuò)如下

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約定了每個(gè)entry的格式。

可以使用的method:

bitmap, hash, list

可以使用的datatype:

ip, net, mac, port, iface

添加記錄

ipset add用于在ipset中添加記錄:

add SETNAME ADD-ENTRY [ ADD-OPTIONS ]

向ipset中添加entry的時(shí)候,加入的entry的格式必須與創(chuàng)建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可以檢查目標(biāo)entry是否在ipset中:

test SETNAME TEST-ENTRY [ TEST-OPTIONS ]

ipset list可以查看ipset的所有內(nèi)容:

list [ SETNAME ] [ OPTIONS ]

導(dǎo)出導(dǎo)入

ipset save可以導(dǎo)出所有的ipset:

save [ SETNAME ]

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

其它

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 moduleSET TARGET的所有選項(xiàng)。

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,如果有疑問(wèn)大家可以留言交流,謝謝大家對(duì)腳本之家的支持。

相關(guān)文章

  • Ubuntu修改密碼及密碼復(fù)雜度策略設(shè)置方法

    Ubuntu修改密碼及密碼復(fù)雜度策略設(shè)置方法

    這篇文章主要介紹了Ubuntu修改密碼及密碼復(fù)雜度策略設(shè)置,方法,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2020-08-08
  • 優(yōu)化Apache服務(wù)器性能的方法小結(jié)

    優(yōu)化Apache服務(wù)器性能的方法小結(jié)

    盡管Apache是一個(gè)高可定制的功能強(qiáng)大且相當(dāng)復(fù)雜的服務(wù)器軟件,我們很有興趣的注意到即使是Apache的標(biāo)準(zhǔn)安裝也可以得到不錯(cuò)的性能。
    2010-12-12
  • 利用lynis如何進(jìn)行l(wèi)inux漏洞掃描詳解

    利用lynis如何進(jìn)行l(wèi)inux漏洞掃描詳解

    這篇文章主要給大家介紹了關(guān)于利用lynis如何進(jìn)行l(wèi)inux漏洞掃描的相關(guān)資料,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2018-06-06
  • VirtualBox 錯(cuò)誤:This kernel requires the following features not present on the CPU

    VirtualBox 錯(cuò)誤:This kernel requires the following features no

    這篇文章主要介紹了VirtualBox 錯(cuò)誤:This kernel requires the following features not present on the CPU的相關(guān)資料,希望通過(guò)本文能幫助到大家,解決這樣的問(wèn)題,需要的朋友可以參考下
    2017-10-10
  • Linux下gdb調(diào)試打印字符串方式

    Linux下gdb調(diào)試打印字符串方式

    這篇文章主要介紹了Linux下gdb調(diào)試打印字符串方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-09-09
  • Linux上如何安裝配置hive

    Linux上如何安裝配置hive

    本文詳細(xì)介紹了如何在Linux系統(tǒng)下安裝和配置Hive,包括安裝前的準(zhǔn)備工作(如確保已安裝Hadoop和MySQL),以及具體的下載、上傳、解壓、配置環(huán)境變量和修改配置文件等步驟,還涉及到了可能遇到的問(wèn)題如驅(qū)動(dòng)引擎缺失和MySQL連接錯(cuò)誤的解決方法
    2024-09-09
  • 6種查看Linux進(jìn)程占用端口號(hào)的方法詳解

    6種查看Linux進(jìn)程占用端口號(hào)的方法詳解

    對(duì)于 Linux 系統(tǒng)管理員來(lái)說(shuō),清楚某個(gè)服務(wù)是否正確地綁定或監(jiān)聽(tīng)某個(gè)端口,是至關(guān)重要的,本文為大家分享6種查看Linux進(jìn)程占用端口號(hào)的方法分別是:ss,netstat,lsof fuser,nmap,systemctl
    2018-10-10
  • 記一次入侵Linux服務(wù)器和刪除木馬程序的經(jīng)歷

    記一次入侵Linux服務(wù)器和刪除木馬程序的經(jīng)歷

    這篇文章主要介紹了記一次入侵Linux服務(wù)器和刪除木馬程序的經(jīng)歷的相關(guān)資料,需要的朋友可以參考下
    2016-02-02
  • 利用apache?ftpserver搭建ftp服務(wù)器的方法步驟

    利用apache?ftpserver搭建ftp服務(wù)器的方法步驟

    本文主要介紹了利用apache?ftpserver搭建ftp服務(wù)器的方法步驟,文中通過(guò)示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2022-05-05
  • linux輸入輸出重定向使用詳解

    linux輸入輸出重定向使用詳解

    linux中使用重定向符號(hào)可以實(shí)現(xiàn)輸出輸入重定向,默認(rèn)條件下,標(biāo)準(zhǔn)輸出和錯(cuò)誤輸出都是終端,用重定向符號(hào)可以把標(biāo)準(zhǔn)輸出和錯(cuò)誤內(nèi)容進(jìn)行重定向,例如把標(biāo)準(zhǔn)輸出重定向到文件,看下面的詳細(xì)解釋
    2014-01-01

最新評(píng)論