添加\禁止端口
修改配置文件命令:
vim /etc/sysconfig/iptables
添加:
iptables -A INPUT -p tcp –dport 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