[心缘地方]同学录
首页 | 功能说明 | 站长通知 | 最近更新 | 编码查看转换 | 代码下载 | 常见问题及讨论 | 《深入解析ASP核心技术》 | 王小鸭自动发工资条VBA版
登录系统:用户名: 密码: 如果要讨论问题,请先注册。

[备忘]CentOS 开放端口,查看端口占用

上一篇:[转帖]No Route to Host error and solution
下一篇:[备忘]概要设计书中的接口设计

添加日期:2013/7/24 22:33:19 快速返回   返回列表 阅读10976次
从网上抄的~~



--------------------------------------
netstat -ano | find "8080"
可查出PID,假设为3668

tasklist | find "3668",可查到进程。

--------------------------------------
Centos查看端口占用情况命令,比如查看80端口占用情况使用如下命令:

lsof -i tcp:80
---------------------------------------

列出所有端口

netstat -ntlp
---------------------------------------
查看80端口
#netstat -an |grep 80

彻底删除占用80端口的所有程序
# lsof -i :80|grep -v "PID"|awk '{print "kill -9",$2}'|sh
---------------------------------------

CentOS 防火墙打开80,22,3306端口操作

vi /etc/sysconfig/iptables
 
添加:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 2222 -j ACCEPT

或者
#/sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT
#/sbin/iptables -I INPUT -p tcp –dport 22 -j ACCEPT
#/sbin/iptables -I INPUT -p tcp –dport 3306 -j ACCEPT

然后保存:
#/etc/rc.d/init.d/iptables save

查看打开的端口:
# /etc/init.d/iptables status
---------------------------------------------------------
好吧,G一下网上有说是防火墙的问题,敲入
/etc/init.d/iptables stop

关闭之后再次查看114.80.*.*:8080(即ip:8080)发现果然成功。但是貌似安全隐患大大增加……

使用
/etc/init.d/iptables status
查看防火墙信息,可以看到打开的端口。

那么我们把需要使用的端口打开应该是一个比较可行的办法了,命令如下:
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT #8080为指定端口
/etc/rc.d/init.d/iptables save #将更改进行保存
/etc/init.d/iptables restart #重启防火墙以便改动生效,当然如果不觉得麻烦也可重启系统(命令:reboot)

当然了,还有另外直接在 /etc/sysconfig/iptables中增加一行:
-A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 8080 -j ACCEPT

永久关闭防火墙
chkconfig –level 35 iptables off 
-------------------------------------------------------------
 

评论 COMMENTS
没有评论 No Comments.

添加评论 Add new comment.
昵称 Name:
评论内容 Comment:
验证码(不区分大小写)
Validation Code:
(not case sensitive)
看不清?点这里换一张!(Change it here!)
 
评论由管理员查看后才能显示。the comment will be showed after it is checked by admin.
CopyRight © 心缘地方 2005-2999. All Rights Reserved