|
|
开放80、22、3306端口操作iptables -I INPUT -p tcp --dport 80 -j ACCEPT: j8 n, p% h4 E: _+ k! g8 X
iptables -I INPUT -p tcp --dport 22 -j ACCEPT
: t4 l; D4 d9 y% u. siptables -I INPUT -p tcp --dport 3306 -j ACCEPT, C+ U/ U9 u2 K! L4 Q& S. P
然后保存:8 n& T! L" o7 R# D h& s( w9 w
/etc/rc.d/init.d/iptables save5 ~/ y5 h5 e8 z
4 C2 z8 N' F& U0 i查看打开的端口:3 |& P4 o( L5 H( I
/etc/init.d/iptables status
% @% U9 c: R* O8 s/ v3 g( w) k. Z) W5 e: B# O" [
-------------------------------------------------------
& O/ a9 z2 M6 G- W补充说明:
) s& Q- e" _/ i' Q, s' F. M# @' m t. R; j5 l
#关闭防火墙$ n3 \0 y& _4 X8 n: T; m% a z7 m
/etc/init.d/iptables stop% K% i9 g0 x7 L8 b
service iptables stop # 停止服务7 J7 P& q& y3 A
#查看防火墙信息& p2 I1 O7 E1 Z" ^, g- G# ]
/etc/init.d/iptables status/ [- ]2 V: ], O8 {( }) {
- M# b2 G* }( {( B$ ?#开放端口:80803 o) C( P3 p. {, ~. a& r
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
7 J. `8 c5 i7 h2 Q* i4 s4 c#重启防火墙以便改动生效或者直接重启系统)' ?$ Y- T5 z. [
/etc/init.d/iptables restart
" q) C2 }: T! x/ W) W#将更改进行保存
; i9 Y3 j: Y( u+ v1 I6 V5 B7 s/etc/rc.d/init.d/iptables save/ W) l6 \8 W6 y; \' |/ `9 `
- F2 T; w4 o+ N+ w
另外直接在/etc/sysconfig/iptables中增加一行:6 V2 ~% v& l) Q. U
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT
% a2 F/ t4 q" H6 N! N#永久关闭防火墙0 C/ ^2 |+ g/ |5 V1 s7 }% _% c( O
chkconfig –level 35 iptables off5 ?' }& p! d Z( y7 M( u# z& U
|4 a+ T( h7 H7 ]
|
|