添加\禁止端口

修改配置文件命令:
vim /etc/sysconfig/iptables
添加:
iptables -A INPUT -p tcp –dport portjACCEPT:iptablesAINPUTptcpdportport−jACCEPT禁止:iptables−AINPUT−ptcp–dport<script type="math/tex" id="MathJax-Element-2">port -j ACCEPT 禁止: iptables -A INPUT -p tcp –dport </script>port -j DROP

启动服务:
/etc/init.d/iptables restart

查看开放端口

netstat -nupl (UDP类型的端口)
netstat -ntpl (TCP类型的端口)

a 表示所有
n 表示不查询dns
t 表示tcp协议
u 表示udp协议
p 表示查询占用的程序
l 表示查询正在监听的程序

netstat -ntpl | grep 3306 //这个表示查找处于监听状态的,端口号为3306的进程

[root@home ~]# netstat -ntpl | grep 3306
tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      25302/mysqld   
[root@home ~]# netstat -nupl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
udp        0      0 172.18.1.143:123            0.0.0.0:*                               1526/ntpd           
udp        0      0 127.0.0.1:123               0.0.0.0:*                               1526/ntpd           
udp        0      0 0.0.0.0:123                 0.0.0.0:*                               1526/ntpd     
[root@home ~]# netstat -ntpl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:6369                0.0.0.0:*                   LISTEN      3284/beam.smp       
tcp        0      0 0.0.0.0:18083               0.0.0.0:*                   LISTEN      3284/beam.smp       
tcp        0      0 127.0.0.1:8743              0.0.0.0:*                   LISTEN      26488/java          
tcp        0      0 127.0.0.1:25                0.0.0.0:*                   LISTEN      19651/sendmail      
tcp        0      0 0.0.0.0:443                 0.0.0.0:*                   LISTEN      24538/nginx       
Logo

魔乐社区(Modelers.cn) 是一个中立、公益的人工智能社区,提供人工智能工具、模型、数据的托管、展示与应用协同服务,为人工智能开发及爱好者搭建开放的学习交流平台。社区通过理事会方式运作,由全产业链共同建设、共同运营、共同享有,推动国产AI生态繁荣发展。

更多推荐