Centos view port usage and enable port command

  

Centos view port occupancy command. For example, to view port 80 occupancy, use the following command:

lsof -i tcp:80

list All ports

netstat -ntlp

1, open port (take port 80 as an example)

Method one:

/sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT Write modification

/etc/init.d/iptables save Save changes

service iptables restart Restart the firewall, the changes take effect

Method 2:

vi /etc/sysconfig/iptables Open the configuration file and add the following statement:

-A INPUT -p tcp -m state –state NEW -m tcp –dport 80 - j ACCEPT Restart the firewall, modify the completion

2, close the port

Method one:

/sbin/iptables -I INPUT -p tcp –dport 80 -j DROP write Into the modification

/etc/init.d/iptables save Save changes

service iptables restart Restart the firewall, the changes take effect

Method 2:

vi /Etc/sysconfig/iptables Open the configuration file and add the following statement:

-A INPU T -p tcp -m state –state NEW -m tcp –dport 80 -j DROP Restart the firewall, modify the completion

3, view the port status

/etc/init.d/Iptables status

Copyright © Windows knowledge All Rights Reserved