Generally, iptables is included in the Linux release.
Run iptables -- version to check whether iptables is installed.
Start iptables:
Service iptables start
View the iptables rule set:
Iptables -- list
The following figure shows the iptables when no planning is defined:
Chain input (Policy accept)
Target prot opt source destination
Chain forward (Policy accept)
Target prot opt source destination
Chain output (Policy accept)
Target prot opt source destination
How to enable/disable a specified port, for example:
Enable port 81:
Iptables-I input-I eth0-P TCP -- dport 81-J accept
Iptables-I output-O eth0-P TCP -- Sport 81-J accept
Close port 81:
Iptables-I input-I eth0-P TCP -- dport 81-J Drop
Iptables-I output-O eth0-P TCP -- Sport 81-J Drop
Then save:
/Etc/rc. d/init. d/iptables save
Restart Firewall:
Service iptables restart
View port status:
Service iptables status
You can use the lsof command to check whether a port is open. Check whether the port can be used in this way.
Take port 81 as an example:
Lsof-I: 81
If there is a display description, it is already open. If there is no display description, it is not open.