|
开放80、22、3306端口操作iptables -I INPUT -p tcp --dport 80 -j ACCEPT
# V. }4 ^9 V; O& f+ V) wiptables -I INPUT -p tcp --dport 22 -j ACCEPT
" t- C3 m4 ~2 w7 b5 uiptables -I INPUT -p tcp --dport 3306 -j ACCEPT* {& P' x8 |1 V% R8 O4 `; S; G
然后保存:/ K1 N! ^; ?( {% Z" }
/etc/rc.d/init.d/iptables save# O$ N1 S! A s4 {) W" P
5 W& a# r0 r; T7 c8 c
查看打开的端口:- T, `+ g) D X! C& {, v" e; z
/etc/init.d/iptables status6 R6 P& @$ C" _* `: O' ~! i @
( n. q5 q* _9 s8 ^, r; |-------------------------------------------------------9 A9 [7 o$ V4 n6 Q. E
补充说明:
; m% L: _; k! R4 p( H. t7 E5 ~- U. E$ x- ]7 V
#关闭防火墙0 J/ K; P' o/ E- m
/etc/init.d/iptables stop. Z3 L. E& `2 F
service iptables stop # 停止服务& J3 B2 d; e& I7 `
#查看防火墙信息
4 I p) B9 I! z2 v/etc/init.d/iptables status
0 z+ C9 K& e' w! Y y8 y- Y
# K1 j m" r5 }7 [* u0 ?#开放端口:8080- H# Y$ ^0 A7 H5 d, @ a/ L! u
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
2 O) i- E% a$ U- }0 w#重启防火墙以便改动生效或者直接重启系统)* L! u% A8 g- R# d! U
/etc/init.d/iptables restart+ Y$ ]1 z. i5 S7 h, g3 \) N& k
#将更改进行保存
# G4 @4 S. e. @$ L7 i$ V* W4 W. q9 b& X/etc/rc.d/init.d/iptables save" A% s6 V2 d+ m' V
x& l7 @7 e: b: K# c2 r另外直接在/etc/sysconfig/iptables中增加一行:# W6 Z' |: x% _* x2 l" ?' J
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT: k& V1 D7 P( f |3 ]
#永久关闭防火墙
/ a4 M$ X) P+ Dchkconfig –level 35 iptables off7 N, D$ f5 u# Y
( @. u& X5 t# e- t; c# [4 H( t; n7 ] |
|