Iptables firewall basic configuration operating system environment: CentOS5.5 I. iptables reads the inbound and outbound packet headers and compares them with the rule set, forward acceptable data packets from one network adapter to another. rejected data packets can be discarded or processed as defined. II. self-contained IPTS in CentOS5.5
IptablesBasic firewall configuration
Operating system environment: CentOS5.5
I. iptables
Read the headers of inbound and outbound data packets and compare them with the rule set to forward acceptable data packets from one network adapter to another, it can be discarded or processed as defined.
II. firewall with iptables in CentOS5.5. The path is in/etc/init. d/iptables.
3. start the firewall
A./etc/init. d/iptables start
B. by default, the firewall does nothing and any port can be connected.
IV. iptables policy
Iptables-p input drop # indicates that all incoming packets are intercepted. <例如在ssh上> , The connection will be disconnected immediately)
Iptables-p output accept # indicates that all sent data packets can be sent normally.
Iptables-p forward accept # indicates that accepted packets can be forwarded.
5. configure a firewall link
Iptables-a input-p tcp -- dport 22-j ACCEPT
Iptables-a input-p tcp-s xxx. xxx/24 -- dport 22-j ACCEPT
Iptables-a input-I lo-j ACCEPT # set the loopback address
Iptables-a output-p tcp -- sport 22-j ACCEPT
Iptables-a output-p tcp-d xxx. xxx/24 -- sport 22-jACCEPT
# INPUT stream rules, indicating whether the client can connect
# Rules of the OUTPUT stream, indicating whether the server can OUTPUT another place.
#-P tcp communication protocol
#-S xxx. xxx/24 source address (connected client)
#-D xxx. xxx/24 target address (output by the server)
# -- Dport22 destination address port
# -- Sport22 source address port
#-J ACCEPT this packet
#-J DROP reject this packet
Delete a rule
Iptables-d input-p tcp -- dport 22-j ACCEPT
6. clear the iptables list
Iptables-F: clear rules of all rule chains in the filter of the preset table
Iptables-X clear the rules in the user-defined chain in the filter of the preset table
PS: The iptables-F Command cannot clear the effects of iptables-p input drop, iptables-p outputaccept, and iptables-p forward accept.
If you want to modify the iptables-p input drop policy, you can directly iptables-p inputaccept.
7. View firewall configuration information
Iptables-L-n