找回密码
 立即注册

QQ登录

只需一步,快速开始

查看: 11268|回复: 0

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

[复制链接]
发表于 2014-12-13 14:37:31 | 显示全部楼层 |阅读模式
开放80、22、3306端口操作iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/ f) ?: Q/ O; E0 Y; F+ }. I* jiptables -I INPUT -p tcp --dport 22 -j ACCEPT
. ?& d; ]7 B$ Y% w  m. Tiptables -I INPUT -p tcp --dport 3306 -j ACCEPT
1 f, ]% o: k( d然后保存:4 e6 e- W/ [% p) f1 e8 P
/etc/rc.d/init.d/iptables save# u. T, U8 b8 Z$ K( h+ b; e

  M( k7 r/ V* X% ]; Y" R/ J查看打开的端口:
% B" Y" c. M9 K6 N) w# _/etc/init.d/iptables status! U1 t  R2 k( B5 w6 c& p
2 ]: ?! ~; ~# `, @6 m. P# J
-------------------------------------------------------
* C3 J8 O! z2 g! o2 e8 y8 F补充说明:6 A" C' E  ^& D3 M( y7 f$ j

# A( l" M8 k. `. F) N3 y1 |6 y#关闭防火墙( }1 X/ C3 E, h
/etc/init.d/iptables stop* ^! U* |9 d! \, A8 M9 A' z
service iptables stop # 停止服务
5 ~0 R6 O. D7 m% G3 \* o; M, ^#查看防火墙信息0 e3 d5 L3 W& f# E# H
/etc/init.d/iptables status, _- ~+ y7 C/ _1 v* _4 N1 w' \& }$ S

( K8 S8 _& }8 [9 _* l#开放端口:80804 |- u% M; {& X3 M* w, }
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
2 y+ [0 W/ i/ E9 G; `6 I  [* |#重启防火墙以便改动生效或者直接重启系统)
. g  E* D) I! w# k" Y/etc/init.d/iptables restart; P$ R- z( `0 c0 [
#将更改进行保存
5 G$ a1 p4 `; \) `* t9 ^2 \/etc/rc.d/init.d/iptables save$ w5 V  c- P- x+ E1 S5 D
; r5 A2 K- l8 |; m
另外直接在/etc/sysconfig/iptables中增加一行:
4 W4 d( f- H2 U5 C6 H) k-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT
3 L+ s7 G7 D- a( m, k5 _#永久关闭防火墙3 H$ S6 o' R# n- T& X- w+ X9 l+ d
chkconfig –level 35 iptables off2 w+ T* B) \2 |5 v! I. ~5 ?

2 I8 K  g% e4 U  v2 h! f
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

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

GMT+8, 2026-8-6 02:45 , Processed in 0.065520 second(s), 20 queries .

Powered by Discuz! X3.5

© 2001-2026 Discuz! Team.

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