找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 10578|回复: 0

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

[复制链接]
发表于 2014-12-13 14:37:31 | 显示全部楼层 |阅读模式
开放80、22、3306端口操作iptables -I INPUT -p tcp --dport 80 -j ACCEPT8 Q* J8 O; U, M5 p
iptables -I INPUT -p tcp --dport 22 -j ACCEPT6 y# D3 f4 s1 E. L/ c& T
iptables -I INPUT -p tcp --dport 3306 -j ACCEPT" ?# W# R) v% @: H9 r
然后保存:
' G- y1 m! N* E& X' z$ o/etc/rc.d/init.d/iptables save
7 f) T  n9 t# h# \5 [7 t/ {. A0 Z7 ]
查看打开的端口:
' Y4 D( G8 m+ a; D/etc/init.d/iptables status
3 K7 f$ x& D8 R+ x2 M5 U7 O4 J  l0 e. R
-------------------------------------------------------3 b- s# ^* I6 P4 x
补充说明:; o9 w; [$ {8 ~* V4 v
4 ]# X) I  n( f3 A" y6 j
#关闭防火墙
7 \: J. D5 n# f9 t! P/etc/init.d/iptables stop1 C9 W# ]8 d- e+ x: Z1 R
service iptables stop # 停止服务
: l. t; B- z& S; C4 ~& t  }; X#查看防火墙信息
9 p: o! }5 o& l' K) [- }/etc/init.d/iptables status" T# _1 Z0 \4 U% d1 |

2 W% {+ D/ t2 t2 U1 ?' J. A#开放端口:8080$ t$ u5 k( D( f$ E! I9 w3 x
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
# d: B! ?1 [% g# A4 E#重启防火墙以便改动生效或者直接重启系统)
2 r. B; U# a+ e6 u, W* A/etc/init.d/iptables restart3 @6 a( `& r& {
#将更改进行保存+ b+ H. G5 j8 {9 n, g0 U2 N% O
/etc/rc.d/init.d/iptables save
/ K0 p% U( V% {) g( L+ h1 [$ T
- P* s0 n  w! f, h4 ~5 ?5 b另外直接在/etc/sysconfig/iptables中增加一行:
5 f. B1 Y8 i$ _7 m1 J! z-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT
( f. P& L3 Z6 x+ g#永久关闭防火墙8 l' h% A9 ?+ N6 s  g
chkconfig –level 35 iptables off
- x, k% a! i' l; Z
2 d2 o: h: F$ `# ]
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-5-16 20:25 , Processed in 0.065395 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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