How to use CentOS system firewall

Source: Internet
Author: User
Firewall is a mechanism for managing packets flowing through the network. it mainly analyzes the packet header to determine whether packets can flow through the local machine. generally, firewall has two implementation methods: 1 software implementation, for example, 360 has a firewall function. 2 is implemented through hardware, and it also has its own hyping system, which is used to analyze and filter packets, providing better performance. Firewalls are mainly composed of tables.

Firewall is a mechanism for managing packets flowing through the network. it mainly analyzes the packet header to determine whether packets can flow through the local machine. generally, firewall has two implementation methods: 1 software implementation, for example, 360 has a firewall function. 2 is implemented through hardware, and it also has its own hyping system, which is used to analyze and filter packets, providing better performance.

A firewall consists of table structures and links.

IptablesStructure
Table
Iptables is composed of several tables, each of which is composed of several chains. Each table is responsible for different packet processing mechanisms, and each chain is responsible for different packet directions, the specific policies are set by the rules in the chain.
Filter table: used to filter packets
Nat table: used for address translation

Chain

INPUT chain: exists in the filter table and is mainly used to process packets entering the local machine.
OUTPUT chain: exists in the filter table and is mainly used to process packets that exit the local machine.
FORWARD chain: exists in the fileter table and is mainly used to process packets passing through the local machine.
PREROUTING: exists in the nat table and is mainly used to modify the destination address (DNAT)
POSTROUTING: exists in the nat table and is mainly used to modify the source address (SNAT)

Firewall configuration save file/etc/sysconfig/iptables
Firewall configuration save command service iptables save

Firewall start/stop/restart
Service iptables start
Service iptables stop
Service iptables restart

/Etc/init. d/iptables restart

/Etc/init. d/iptables stop

/Etc/init. d/iptables start

Chkconfig? Level 35 iptables off (Firewall permanently disabled)

Specified remote host access

Iptables A input-s ip-j accept

Change the default firewall chain policy and view

Iptables-P INPUT DROP

View table chain policies

Iptables-L

Enable related ports

Iptables-I INPUT-p tcp? Dport 80-j ACCEPT

-I-link name [rule number] insert a rule

-- Dport destination port

-P protocol

-J ACCEPT: allow packets to pass without blocking
-J DROP does not allow packet passing

View port enabling status

/Etc/init. d/iptables status

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.