- 打开端口:
[root@host ~]# /sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
[root@host ~]# /etc/init.d/iptables save
[root@host ~]# service iptables restart
- 关闭端口
[root@host ~]# /sbin/iptables -I INPUT -p tcp --dport 8080 -j DROP
[root@host ~]# /etc/init.d/iptables save
[root@host ~]# service iptables restart
- 查看端口打开状态
[root@host ~]# service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8080
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
Chain OUTPUT (policy ACCEPT)
num target prot opt source destinationn
本文介绍如何使用iptables命令来打开和关闭指定端口(如8080端口),并提供了检查端口状态的方法。
5510

被折叠的 条评论
为什么被折叠?



