1. 程式人生 > >CentOS開啟關閉埠方法

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