1、語法:
成都創(chuàng)新互聯(lián)長期為上千客戶提供的網(wǎng)站建設(shè)服務(wù),團(tuán)隊(duì)從業(yè)經(jīng)驗(yàn)10年,關(guān)注不同地域、不同群體,并針對(duì)不同對(duì)象提供差異化的產(chǎn)品和服務(wù);打造開放共贏平臺(tái),與合作伙伴共同營造健康的互聯(lián)網(wǎng)生態(tài)環(huán)境。為會(huì)同企業(yè)提供專業(yè)的網(wǎng)站建設(shè)、成都網(wǎng)站制作,會(huì)同網(wǎng)站改版等技術(shù)服務(wù)。擁有十余年豐富建站經(jīng)驗(yàn)和眾多成功案例,為您定制開發(fā)。
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 -ieth0 -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ū)?dòng)新的連接
ESTABLISHED:已建立的連接
RELATED:正在啟動(dòng)新連接
INVALID:非法或無法識(shí)別的
8、本機(jī)地址:172.16.14.1,允許172.16.0.0/16網(wǎng)絡(luò)ping本機(jī),但限制每分鐘請(qǐng)求不能超過20,每次并發(fā)
不能超過6個(gè).
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}:指定時(shí)間內(nèi)的請(qǐng)求速率"n"為速率,后面為時(shí)間分別為:秒、分、時(shí)
--limit-burst [n]:在同一時(shí)間內(nèi)允許通過的請(qǐng)求"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 -d192.168.1.9 -p tcp --dport 80 -j DNAT --to-destination10.10.70.60:9000
12、配置網(wǎng)關(guān):
server 1 :eht0 10.10.70.60 eth2 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,如無,請(qǐng)加載。
配置:
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 偽裝
13、映射多個(gè)外網(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
當(dāng)前名稱:iptable范例
本文鏈接:http://muchs.cn/article30/gpgppo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供標(biāo)簽優(yōu)化、、網(wǎng)站建設(shè)、網(wǎng)站營銷、面包屑導(dǎo)航、搜索引擎優(yōu)化
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)