压在透明的玻璃上c-国产精品国产一级A片精品免费-国产精品视频网-成人黄网站18秘 免费看|www.tcsft.com

iptables 范例

  1、語法:

  Usage:

  iptables -t [table] -[AD] chain rule-specification[options]

  2、基本的處理行為:

    ACCEPT(接受)、DROP(丟棄)、REJECT(拒絕)

  3、匹配指定協(xié)議外的所有協(xié)議

  iptables -A INPUT -p ! tcp

  匹配主機(jī)源IP

  iptables -A INPUT -s 10.0.0.14

  iptables -A INPUT -s ! 10.0.0.14

  匹配網(wǎng)段

  iptables -A INPUT -s 10.0.0.0/24

  iptables -A INPUT -s ! 10.0.0.0/24

  匹配單一端口

  iptables -A INPUT -p tcp –sport 53

  iptables -A INPUT -p udp –dport 53

  4、封端口:

  iptables -t filter -A INPUT -p tcp –dport 80 -j DROP

  (–sports 源端口)

  (22:80 端口范圍)

  iptables -t filter -A INPUT -p tcp -m multiport  –dport 222,323 -j ACCEPT

  (-m multiport 列元素 222,323)

  5、 封ip :

  iptables -t filter -A    INPUT   -i eth0 -s 10.0.0.105 -j DROP

  -s 源地址

  -i 進(jìn)  -o 出 指定網(wǎng)絡(luò)接口

  6、禁ping

  iptables -t filter -A INPUT -p icmp –icmp-type 8   ! -s 10.10.70.0/24 -j DROP

  (!非)

  iptables -t filter -I INPUT  2 -p icmp –icmp-type any  -s 10.10.70.0/24 -j DROP            (any 所有類型)

  ( -I 2 指定位置)

  7、匹配網(wǎng)絡(luò)狀態(tài):

  iptables -A INPUT  -m state –state ESTABLISHED,RELATED -j ACCEPT

  iptables -A OUTPUT -m state –state ESTABLISHED,RELATED -j ACCEPT

  -m state –state:允許關(guān)聯(lián)的狀態(tài)包通過

  NEW:已經(jīng)或?qū)有碌倪B接

  ESTABLISHED:已建立的連接

  RELATED:正在啟動新連接

  INVALID:非法或無法識別的

  8、本機(jī)地址:

    
    172.16.14.1,允許172.16.0.0/16網(wǎng)絡(luò)ping本機(jī),但限制每分鐘請求不能超過20,每次并發(fā)

  不能超過6個.

  iptables -A INPUT -s 172.16.0.0/16 -d 172.16.14.1 -p icmp –icmp-type 8 -m limit –limit 20/min –limit-burst 6 -j ACCEPT

  iptables -A OUTPUT -s 172.16.14.1 -d 172.16.0.0/16 -p icmp –icmp-type 0 -j ACCEPT

  -m limit

  –limit n/{second/minute/hour}:指定時間內(nèi)的請求速率"n"為速率,后面為時間分別為:秒、分、時

  –limit-burst [n]:在同一時間內(nèi)允許通過的請求"n"為數(shù)字,不指定默認(rèn)為5

  9、自定義鏈處理syn攻擊

  iptables -N syn-flood

  iptables -A INPUT -i eth0 -syn -j syn-flood

  iptables -A syn-flood -m limit -limit 5000/s -limit-burst 200 -j RETURN

  iptables -A syn-flood -j DROP

  10、網(wǎng)關(guān)服務(wù)器配置端口地址轉(zhuǎn)換

  iptables -t nat -A PREROUTING -d 192.168.1.9 -p tcp –dport 80 -j DNAT –to-destination 10.10.70.60:9000

  11、配置網(wǎng)關(guān):

  server 1 :eht0 10.10.70.60 eth1 192.168.1.10

  server 2 : eth0 192.168.1.9

  開啟路由轉(zhuǎn)發(fā):

  sed -n "s/net.ipv4.ip_forward = 0/net.ipv4.ip_forward = 1/g" /etc/sysctl.conf

  sysctl  -p

  清除配置:

  iptables -F

  iptables -Z

  iptables -X

  開啟FORWORD  :  iptables -P    FORWARD ACCEPT

  查看是否有配置內(nèi)核模塊:lsmod | grep nat,如無,請加載。

  配置:

  iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -o eth0-j SNAT –to-source 10.10.60.10

  或:

  iptables -t nat -A POSTROUTING -s 192.168.1.0/24 -j MASQUERADE  偽裝

  12、映射多個外網(wǎng)IP上網(wǎng)

  iptables -t nat -A POSTROUTING -s 10.0.0.0/255.255.240.0 -o eth0 -j SNAT –to-source 124.42.60.11-124.42.60.16

  iptables -t nat -A POSTROUTING -s 172.16.1.0/255.255.255.0 -o eth0 -j SNAT –to-source 124.42.60.103-124.42.60.106

    文章來源:http://hiboyandhigirl.blog.51cto.com/9150052/1598252

上一篇:安卓防火墻 PS DroidWall

下一篇:使用GnuPG進(jìn)行數(shù)據(jù)加密