找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 8922|回复: 0

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

[复制链接]
发表于 2014-12-13 14:37:31 | 显示全部楼层 |阅读模式
开放80、22、3306端口操作iptables -I INPUT -p tcp --dport 80 -j ACCEPT
$ I3 K1 @7 d: {! v9 Iiptables -I INPUT -p tcp --dport 22 -j ACCEPT
. o  s9 f: \! V  ?" w4 Aiptables -I INPUT -p tcp --dport 3306 -j ACCEPT5 s& A5 X- h) O( R! X$ Z( C) m
然后保存:# s; f9 X( V% l. ^
/etc/rc.d/init.d/iptables save
8 H+ {' Z! \0 v( E1 T+ d8 K' `' ]4 p' t; W
查看打开的端口:$ n! ?% u5 q  M0 d# [
/etc/init.d/iptables status; C1 u+ B3 L/ d
; y- U! f7 F  u" H) [: H+ P
-------------------------------------------------------
' [- o+ g' L$ s9 L0 S补充说明:! \: W% r. ]  Z: T/ N( W0 Z2 X7 Y
7 V/ L7 K# H2 U# A4 G
#关闭防火墙
. ]) j4 Z) e9 d9 d( C/etc/init.d/iptables stop
4 @; T8 A0 W7 ]: }service iptables stop # 停止服务; E/ Q  N6 `& p! ], z; N2 f  m: S& Q
#查看防火墙信息, {# V5 a: K6 s" K! ]0 m5 r7 \' B
/etc/init.d/iptables status
3 Y; ~# n( I. l2 b3 g
+ }) ~( i+ Z0 c$ b" P#开放端口:8080" P# {! h0 I' B
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT) I& U* Y4 L. J" J6 B! U
#重启防火墙以便改动生效或者直接重启系统)! t! p3 g& M$ S  k+ {
/etc/init.d/iptables restart
! D0 s- ~0 ?0 J#将更改进行保存
$ G0 B, A; N2 o, i( K3 Z/etc/rc.d/init.d/iptables save' `7 W$ b" h2 s$ p1 n0 ^

2 _5 z2 e6 g+ F另外直接在/etc/sysconfig/iptables中增加一行:! o/ g. A, `; h/ g3 H& O
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT& v. @$ g# L% ?& c5 o
#永久关闭防火墙& V0 n. A1 a' m, B- f- ^
chkconfig –level 35 iptables off0 m4 y8 I+ v0 {  \( d8 P1 m0 d

9 w6 i$ K9 ^5 ^4 D
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-11-5 00:53 , Processed in 0.062214 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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