Iptables is a firewall under Linux and is also the service name.
Service iptables Status View firewall state
Service iptables start to turn on the firewall
Service iptables Stop shutting down the firewall
Service 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 the firewall
Serivce iptables Save
View Iptables rules and numbers
IPTABLES-NL--line-number
Turn off all input FORWARD (forwards) output for all ports
Iptables-p INPUT DROP
Iptables-p FORWARD DROP
Iptables-p OUTPUT DROP
Open only 22 ports
Iptables-a input-p TCP--dport 22-j ACCEPT
Iptables-a output-p TCP--sport 22-j ACCEPT
Parameter explanation:
The –A parameter is seen as adding a rule
–P specifies what protocol we commonly use for the TCP protocol, and of course there are UDP, such as 53-port DNS
–dport is the destination port, when the data goes from outside to the server as the destination port
–sport data goes out of the server, it is used for the data source port
–J is designated as Accept-receive or DROP not receive
Disable an IP access
Iptables-a input-p tcp-s 192.168.1.2-j DROP
–s parameter is source (i.e. 192.168.1.2)
The back rejection is drop.
Delete Rule
Iptables-d INPUT 2
Delete the input chain number 2 rule
This article is from "_xiaohan" blog, please make sure to keep this source http://yingmeng.blog.51cto.com/5365464/1588697
Linux Firewall Open specific ports (iptables)