CentOS開啓關閉端口方法

  • 打開端口:
[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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章