centos-iptables-scripts

author:headsen chentcp

date:2018-06-04  11:20:38ide

notice:This  article is created by headsen chen himself and not allowed to copy.or you will count law questions.spa

 

#啓動
service iptables start
chkconfig iptables on
狀況原先的規則
iptables -F

#容許特定網段和地址訪問
iptables -I INPUT -s 192.168.1.0/24 -j ACCEPT
iptables -I INPUT -s 121.23.45.146 -j ACCEPT

iptables -I INPUT -p tcp -s 121.23.45.146 --dport 22 -j ACCEPT
iptables -I INPUT -p tcp -s 10.0.0.0/16 --dport 22 -j ACCEPT

#內部迴環口
iptables -I OUTPUT -o eth0 -j ACCEPT
iptables -I INPUT -i lo  -j ACCEPT

#默認規則
iptables -P INPUT DROP
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP

#容許httpd服務過來訪問
iptables -A INPUT -p tcp --dport 80 -j ACCEPT

#容許ping服務
iptables -A INPUT -p icmp --icmp-type 8 -j ACCEPT

#容許長鏈接訪問(必須是tcp和udp及其餘協議都容許的,不然光tcp則不行,yum都沒法運行!!!)
iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT

#限制某個單獨ip訪問
iptables -I INPUT -p tcp -s 146.56.32.147 --dport 80 -j DROP

#保存防火牆:
service iptables save
iptables-save >/bb.txt
View Code
相關文章
相關標籤/搜索
本站公眾號
   歡迎關注本站公眾號,獲取更多信息