|
|
开放80、22、3306端口操作iptables -I INPUT -p tcp --dport 80 -j ACCEPT ]* K2 T: G$ S- u+ |" O
iptables -I INPUT -p tcp --dport 22 -j ACCEPT
/ ]5 p9 |, }( Qiptables -I INPUT -p tcp --dport 3306 -j ACCEPT
' I, a) U: j- p+ y然后保存:% }5 J6 r% S, o7 R/ |
/etc/rc.d/init.d/iptables save: }/ P y7 n6 R% M
! b1 |( Z v6 H查看打开的端口:
+ h2 Z0 w$ n3 S" w l1 D/etc/init.d/iptables status" u4 L# z7 }/ _9 D" C4 T M1 F
$ T$ [. E7 Z& y# B-------------------------------------------------------/ I2 B9 Y8 R3 w( L4 L- m
补充说明:
# p& c1 g. x! N& D. m( g5 i& W1 _! J. t% h* ]* x
#关闭防火墙* x- ^/ O1 v; v! S" j
/etc/init.d/iptables stop
* ]7 }& G5 W6 s. [$ Z+ [service iptables stop # 停止服务
3 d& ?! @4 P c3 B, M1 e#查看防火墙信息- U$ G5 y+ H, \: m, b2 L+ M
/etc/init.d/iptables status
# a. B8 G$ W( r% `: d4 V5 b/ }. W j( o. @+ e( r6 t5 c$ F: {/ V
#开放端口:8080
4 {( s6 x2 F* p+ s6 O# X7 C) {/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
( [ x) ~& ~* y* G7 M9 y( A# x#重启防火墙以便改动生效或者直接重启系统)! S: T& I9 e; i) p- S/ K$ ]' N
/etc/init.d/iptables restart
9 ~0 s# `# J% Z- j6 Y7 W) _5 X( z7 F#将更改进行保存
) T" S3 a7 p0 \) m/ a/etc/rc.d/init.d/iptables save+ r. J3 r, n* h* c8 l7 A0 B
* V- q' H# d3 Z K* i: @
另外直接在/etc/sysconfig/iptables中增加一行:! t* ~2 r1 \5 a: ` j S) N
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT
! |% A# ^9 N: q! ]5 D9 Z& |#永久关闭防火墙
, U F9 H U1 A4 S2 F& c zchkconfig –level 35 iptables off/ n% o" a+ H$ O8 @' a" g
9 _4 m. X m9 |* p: x |
|