找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 10831|回复: 0

CentOS开放80、22、3306端口操作

[复制链接]
发表于 2014-12-13 14:37:31 | 显示全部楼层 |阅读模式
开放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
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|第一站论坛 ( 蜀ICP备06004864号-6 )

GMT+8, 2026-6-16 10:53 , Processed in 0.052101 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

快速回复 返回顶部 返回列表