|
开放80、22、3306端口操作iptables -I INPUT -p tcp --dport 80 -j ACCEPT
. r' T" @# O. E% j2 |iptables -I INPUT -p tcp --dport 22 -j ACCEPT+ E& v) ] x- C1 [& s/ B
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
9 N* q# Z2 X: t1 C- Z: E+ c然后保存:+ f2 T& F& ]4 C& W3 p
/etc/rc.d/init.d/iptables save
% D- ] f/ O! Y0 N: d1 Y/ c/ B7 j
3 w9 x( M5 a0 P# [5 f查看打开的端口:
A) a( `* a8 D0 p2 y# l+ y- P/etc/init.d/iptables status& i1 @ |+ x, |4 Z
* ^5 p+ W8 c+ t* Z8 j( X. g
-------------------------------------------------------
/ o- E+ i6 e0 D, ^: C补充说明:$ L0 ^' Z( u# G
: A$ L5 c/ s. L- r. ?$ D, ~
#关闭防火墙
/ C9 T, Y t9 Y3 ]5 j/etc/init.d/iptables stop4 g. _# a/ y# F* q4 G1 J
service iptables stop # 停止服务7 N$ x' ?3 h* ]0 |* V, t1 e
#查看防火墙信息
5 M5 m1 v" C: S7 R/etc/init.d/iptables status7 ~8 @# ]' ]5 c# A
3 r; B* h! c$ K; D$ X+ t. B
#开放端口:8080
3 f7 ~0 i- u: A/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT4 N% |; S9 P$ z% N' G( K8 {( h
#重启防火墙以便改动生效或者直接重启系统)) X% }3 e( l9 }' y. M- |+ K' S& l
/etc/init.d/iptables restart; A4 t5 r4 @/ [
#将更改进行保存0 @/ E. @- K* V! U% L; G
/etc/rc.d/init.d/iptables save
1 M: T7 r( U" y; W# r p! d4 Y0 E% y% x; A8 c7 t* D$ S
另外直接在/etc/sysconfig/iptables中增加一行:) }# X H$ G5 I
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT
7 m& T1 E# m3 {% s#永久关闭防火墙4 v/ k n. G8 B8 m; J/ U. k
chkconfig –level 35 iptables off1 m6 c3 }3 N _ f: C3 M
, B+ D3 R2 Q4 @0 j1 ^/ q |
|