|
开放80、22、3306端口操作iptables -I INPUT -p tcp --dport 80 -j ACCEPT6 f& T% {' k/ ?, l
iptables -I INPUT -p tcp --dport 22 -j ACCEPT
/ t' L5 m* W) ~( l5 tiptables -I INPUT -p tcp --dport 3306 -j ACCEPT
" S4 F: W% ]' b然后保存:
2 X2 G0 l+ G- a' d! d% K, j P' E/etc/rc.d/init.d/iptables save7 A! E( A. X9 H' A( U- Q+ e1 I
; H; c: ^3 U; B" D" u! V6 s
查看打开的端口: H4 R& \- I, X! P! [; [
/etc/init.d/iptables status
" a9 O+ t3 w2 \9 y) h# W# J: \) {" }; W# I4 }# O& ~0 T. p' D
-------------------------------------------------------1 F, O% c3 [9 x& n" K1 ]
补充说明:3 f) G! w: u" t8 v0 N
' j3 f. V- Z i' J9 V. M#关闭防火墙
! p, }$ P5 l( V0 S/etc/init.d/iptables stop
% a/ [& J- S" p% S) _9 Cservice iptables stop # 停止服务5 d1 a- c" ?+ p) ~/ c2 A h7 W' E: _
#查看防火墙信息; ^1 M6 ]0 x4 b- ]! c2 l. ~
/etc/init.d/iptables status3 B3 Y. D; |1 T5 B2 s4 F
/ j1 \* m- R. b3 a% ?% ~#开放端口:80800 B* K- `! ^& M/ L8 A o! i& ~
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT0 ? v, i: D: M
#重启防火墙以便改动生效或者直接重启系统)
: l" f L" |# Q2 b, R, t' R% ~/etc/init.d/iptables restart
, h8 Q# Y1 R i" b( V U) E" p#将更改进行保存
" W B; d5 j5 J; q) U4 I/etc/rc.d/init.d/iptables save. a# W6 `( x" Z* W# B# j0 }
* V" F( N- W; r8 o2 `& j
另外直接在/etc/sysconfig/iptables中增加一行:, w& g3 T) [5 V6 Z/ v- @% \1 Z
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT
4 m6 G( ~7 o" J0 f7 [# x2 Q#永久关闭防火墙* `) |" Z2 q- B x5 ^
chkconfig –level 35 iptables off
$ J9 }% I( u& \. G& b. y! ^0 M1 n% u
|
|