|
|
开放80、22、3306端口操作iptables -I INPUT -p tcp --dport 80 -j ACCEPT
1 }; h2 x6 J4 T# viptables -I INPUT -p tcp --dport 22 -j ACCEPT6 n+ D2 \7 w' u5 `
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
8 f# x7 M- Z, m5 W- j然后保存:
0 Q( `7 Z/ g, s: Z( f/etc/rc.d/init.d/iptables save
0 m- B+ [' D9 i. U) J, L( q* w3 ~& Y$ t1 L( \
查看打开的端口:1 I# |$ f* \7 S0 y# s& ?/ c
/etc/init.d/iptables status& `% p# A; p( f3 L/ r' H; n6 L
6 _4 _2 N. K j) @! F; V* J( |-------------------------------------------------------9 X3 t( b4 u4 ]
补充说明:1 J, d% k0 y) }
8 x" ~6 z7 \" m1 l( f2 a#关闭防火墙
/ l( w, ? O3 @: e9 t4 w3 o3 }/etc/init.d/iptables stop' M4 D( p- k$ o" d+ B
service iptables stop # 停止服务
/ _1 z- G; {- [; i#查看防火墙信息
, d7 q# D* J0 L; y& X d1 y/etc/init.d/iptables status
' `. Q. b& ~% z7 J: n6 |6 x. Q2 E" \3 F; r" y! A
#开放端口:8080
, t2 \+ J, q* L/ v/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT( q8 L& I' k% y" r
#重启防火墙以便改动生效或者直接重启系统)
5 {/ ]7 Z- N# j# b r/etc/init.d/iptables restart
5 H$ ~; l8 e0 G6 l( I. \3 d#将更改进行保存
. H d" X$ A9 x; {7 q/etc/rc.d/init.d/iptables save) m0 L5 U: ~. F# n1 i+ F7 ^+ p
$ U6 c" Y5 m" h
另外直接在/etc/sysconfig/iptables中增加一行:
]7 u% q3 R H: L: W: u-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT& v9 p) V# }( e+ m/ z
#永久关闭防火墙. u$ O" z0 d7 V* H! Y4 s* A
chkconfig –level 35 iptables off3 w; {7 }( I/ m+ l3 m& _
; `1 Q- H b4 C. K& q |
|