Basic configuration process of iptables firewall

Source: Internet
Author: User
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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.