linux CentOS6.5 firewall (close the port in addition to providing services outside the system)

1, or can not allow a service connection ssh remote connection server (add input chain rule: Protocol TCP port 22 is open to accept operation)
# iptables -A 22 --dport the INPUT -p TCP -j ACCEPT

2, the default rule set, is disabled by default for all inbound connections, outbound connections through the discharge
(1) is provided to enter data packet is discarded. (That is, the machine does not accept any default connection, then unless the rules set in the received INPUT chain.)
# Iptables -P INPUT the DROP
(2) is provided to allow default outgoing data packet
# iptables the OUTPUT ACCEPT -P
(. 3) to set the default rules: forwarded to discard
#iptables -P fORWARD DROP

3, and then put through the ports needed to provide services, such as through the discharge port 80 (adding the input chain rule: allow port 80 open tcp agreement to accept operation)
# iptables -A 80 --dport the INPUT -p tcp -j ACCEPT

4. Save the rule
#service iptables save

5, restart iptables rules take effect
#service iptables restart

Note: The command is automatically saved to / etc / sysconfig / iptables file.

Guess you like

Origin blog.51cto.com/14413105/2434593