找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 8862|回复: 0

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

[复制链接]
发表于 2014-12-13 14:37:31 | 显示全部楼层 |阅读模式
开放80、22、3306端口操作iptables -I INPUT -p tcp --dport 80 -j ACCEPT$ \% }4 w% Y  z
iptables -I INPUT -p tcp --dport 22 -j ACCEPT  r2 q- x" f! A3 V& Z& N
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
4 a. q3 ]# ]# C: |2 q/ U然后保存:
/ x" N& S/ D3 M0 ?9 m- C- S/etc/rc.d/init.d/iptables save( l6 [5 x: C2 m, h# I5 D$ F" P
0 l/ o/ q+ k% J4 O: t6 c7 {  j" E
查看打开的端口:  A1 j9 V4 `9 w: Y# T( e
/etc/init.d/iptables status9 l0 U1 I% i: e7 m
% ?% }5 r) i4 t6 _9 V. C7 B
-------------------------------------------------------& }) u8 |9 ?/ p$ n  j0 \
补充说明:9 Y  O4 m* V2 ?0 x/ T

$ S8 w1 ?& J% U- m; |4 a#关闭防火墙2 t1 x8 g! P: `( R5 t
/etc/init.d/iptables stop
. I) x' v; N. z8 v, @! U4 p( ?service iptables stop # 停止服务
6 U; u3 n' g% i+ h2 \5 i#查看防火墙信息$ v% u) r' X: v' v# `8 r
/etc/init.d/iptables status
0 C) S# m, t$ {( r/ |0 t
) f- l! O/ ?( E. H& {#开放端口:8080
/ Z- D$ k" y; t  C+ H/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
+ b# o9 ^; c# H- `; _#重启防火墙以便改动生效或者直接重启系统): V  }: ^9 V# M. m% o% I, D
/etc/init.d/iptables restart" ?5 D) P0 X" [/ G* N1 I$ a
#将更改进行保存
! p# P; n& b% V2 Y; Z9 t. g/etc/rc.d/init.d/iptables save
. @' A( @6 \. b) [0 D  N% i) C4 h" G, Q3 |7 R
另外直接在/etc/sysconfig/iptables中增加一行:# T- U- L4 I( g. t% a1 q
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT
& F, s6 U! O$ l0 \; h* G8 `#永久关闭防火墙. l6 d; W- `3 d+ l' S7 s
chkconfig –level 35 iptables off
  h0 T2 \+ m0 n5 q; o3 i( B
, }/ U. n8 i0 e. X
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2025-10-29 07:46 , Processed in 0.066780 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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