歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux綜合 >> 學習Linux >> iptables,iptables配置

iptables,iptables配置

日期:2017/3/6 8:55:22   编辑:學習Linux

iptables,iptables配置

iptables,iptables配置


一、在服務器上打開 22、80、9011端口:

iptables -A INPUT -p tcp --dport 9011 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 9011 -j ACCEPT

iptables -A INPUT -p tcp --dport 22 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 22 -j ACCEPT

iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT

二:關閉所有其他的端口:

iptables -P INPUT DROP
iptables -P FORWARD DROP
iptables -P OUTPUT DROP

三:查看iptables:

iptables -L -n --line-number

---------------------------------

num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:9011
2 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:22
3 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp spt:80

四:刪除第三條規則:

iptables -D INPUT 3

iptables -D OUTPUT 3

http://xxxxxx/Linuxjc/1158105.html TechArticle

Copyright © Linux教程網 All Rights Reserved