Iptables is a firewall under Linux and is also the service name. Service iptables Status View firewall stateService iptables start to turn on the firewallservice iptables Stop shutting down the firewallService iptables Restart Restart firewall
firewalls Open specific ports:① file/etc/sysconfig/iptables② Add:-A rh-firewall-1-input-m State--state new-m tcp-p TCP--dport 8080-j ACCEPT★ The number 8080 for open 8080 port, can also be changed to other ports ★③ Restart the firewall
================================================================ Save settings for firewall Serivce iptables save View iptables rules and numbers IPTABLES-NL--line-number close all input FORWARD (forwards) output all ports iptables-p input dropiptables-p FORWARD DRO Piptables-p OUTPUT DROP only opens 22 ports iptables-a input-p TCP--dport 22-j acceptiptables-a output-p tcp--sport 22-j AC CEPT parameter explanation: –A parameter is to add a rule –p specify what protocol, we commonly used TCP protocol, of course, there is UDP, for example, 53 port Dns–dport is the target port, when the data from the outside into the server for the destination port –sport data from the server out, Use –J for the data source port is either accept-receive or DROP does not receive prohibit an IP access iptables-a input-p tcp-s 192.168.1.2-j drop–s parameter is the source (that is, 192.168.1.2) after rejecting It's a drop. Delete rule iptables-d Input 2 Delete the rule with input chain number 2
Linux Firewall Open specific ports (iptables)