linux命令行查看端口情况

查看端口的使用的情况

lsof 命令
  • 1

比如查看80端口的使用的情况。

lsof -i tcp:80
  • 1

列出所有的端口

netstat -ntlp
  • 1

查看端口的状态

 /etc/init.d/iptables status
  • 1

开启端口 
开启端口以开启端口80为例。 
1 用命令开启端口:

iptables -I INPUT -p tcp --dport 80 -j accpet --写入要开放的端口
/etc/init.d/iptables save --保存修改
/etc/sysconfig/iptables restart -- 重启防火墙
或者用命令:service iptables restart重启防火墙
  • 1
  • 2
  • 3
  • 4

2 修改/etc/sysconfig/iptables文件。 
这里写图片描述 
保存文件重启防火墙。 
关闭端口 
用命令修改

iptables -I INPUT -p tcp --dport 80 -j DROP--写入修改
/etc/init.d/iptables save --保存修改
service iptables restart --重启防火墙
  • 1
  • 2
  • 3

修改配置文件 vi /etc/sysconfig/iptables:

 -A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j DROP   重启防火墙,修改完成
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值