找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 8582|回复: 0

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

[复制链接]
发表于 2014-12-13 14:37:31 | 显示全部楼层 |阅读模式
开放80、22、3306端口操作iptables -I INPUT -p tcp --dport 80 -j ACCEPT
9 C: ~8 n6 _5 I* f) {7 W- n0 W5 qiptables -I INPUT -p tcp --dport 22 -j ACCEPT
  I$ L# A  U; I/ ]+ Qiptables -I INPUT -p tcp --dport 3306 -j ACCEPT
: X( D4 b# a( Q+ c" ^1 j: u6 }然后保存:
/ n" Q. F) |4 t; ^2 m" r/ N/etc/rc.d/init.d/iptables save# t2 s! \( `7 C7 n+ C
! {1 c$ [! i7 I! c
查看打开的端口:
" K- }: r- ^! p8 e$ y3 G/etc/init.d/iptables status
# S5 A5 M' T/ e* g& A  `0 I% I% t7 [, U! Q0 t/ P
-------------------------------------------------------
- R. g6 E" _* k' m补充说明:1 h( q6 i) l5 J; ^/ I" ^4 P
. B& `; G4 a0 i& s$ Q
#关闭防火墙
5 i# V$ X- b2 T- C6 Q$ b/etc/init.d/iptables stop
& ]  A+ K& `8 G) H3 xservice iptables stop # 停止服务
6 t* T/ p3 Y- S# ^#查看防火墙信息
. D5 ]: z% k) o' t/etc/init.d/iptables status* _$ A; h" w6 ^3 P, _
, Z; A5 A: e! T7 ?$ P0 {
#开放端口:8080: z/ p" T- q; M) A6 }
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
  @! {, w: |* B; J; I# C#重启防火墙以便改动生效或者直接重启系统)
6 o( v4 e& q% E; m' W4 }0 D/etc/init.d/iptables restart- h: C) ^7 q2 J- X
#将更改进行保存
( f8 L/ m2 B: X2 Z8 I+ V/etc/rc.d/init.d/iptables save
7 _4 a1 {+ w3 [% s  I% x+ U- q. {% H1 U/ X# C
另外直接在/etc/sysconfig/iptables中增加一行:- O7 {+ K( A) q  V
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT
. j  e+ ~3 C0 t* W. \#永久关闭防火墙
5 n0 |+ ]* k0 z: fchkconfig –level 35 iptables off
2 \$ r5 u3 [8 c; {
4 B4 W8 X2 z' }1 _; s
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-9-10 10:44 , Processed in 0.061550 second(s), 19 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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