I. Overview of firewalls (I). Overview of firewalls refers to the combination of components set between different networks or network security domains, which can enhance the security of internal networks. It uses the access control mechanism to determine which internal services allow external access and which external requests are allowed to access internal services. It can be determined based on the type of network transmission
1. Overview of firewall
(1) Introduction to the firewall
A firewall is a combination of components set between different networks or network security domains. it enhances the security of the internal network of an organization. It uses the access control mechanism to determine which internal services allow external access and which external requests are allowed to access internal services. It determines whether an IP packet can be transmitted to or from the Intranet based on the network transmission type.
The firewall checks every data packet that passes through the review to determine whether it has matched filtering rules, and compares them one by one based on the rule sequence until one of the rules is met, then, the corresponding action is made based on the control mechanism. If none of the above conditions are met, data packets are discarded to protect network security.
You can use the firewall to implement the following functions:
It can protect vulnerable services;
Control access to network systems between intranet and internet;
Centrally manages intranet security to reduce management costs;
Improve the confidentiality and privacy of the network;
Record the network usage status to provide a basis for security planning and network maintenance.
(2) classification of firewalls
Firewall technology is divided into many types based on different defense methods and focuses, but generally it can be divided into two types: packet filtering firewall and proxy server.
(3) working principles of the firewall
1. how packet filtering firewall works
① After a packet is transmitted from the Internet to the firewall, the firewall forwards the packet to the packet inspection module for processing before the IP layer sends the packet to the TCP layer.
② First, compare it with the first filter rule.
③ If it is the same as the first module, it will be reviewed to determine whether to forward the data packet. if the review result is a data packet, the data packet will be sent to the TCP layer for processing, otherwise, it will be discarded.
④ If it is different from the first filter rule, then compare it with the second rule. if it is the same, review it. The process is the same as ③.
⑤ If it is different from the second filter rule, compare it with the next filter rule until it is compared with all the filter rules. If none of the filtering rules are met, the data packet is discarded.
2. working principle of proxy service firewall
Proxy service firewall implements the firewall function at the application layer. It provides transmission-related statuses, application-related statuses, and transmission-related information. It can also process and manage information.
II.IptablesIntroduction
Netfilter/iptables (iptables) is a packet filtering firewall on the Linux platform. like most Linux software, this packet filtering firewall is free of charge, it can replace expensive commercial firewall solutions to implement functions such as packet filtering, Packet redirection, and network address translation NAT. The Iptables/netfilter packet filtering firewall consists of two components: netfilter and iptables.
III. iptables basics
(1). rules (rules)
A rule (rules) is actually a predefined condition of the network administrator. The rule is generally defined as "if the data packet header meets this condition, it will process this packet ". Information Packet filtering table in the kernel space where rules are stored
The rules specify the source address, destination address, Transmission Protocol (such as TCP, UDP, ICMP), and service type (such as HTTP, FTP, and SMTP. When a packet matches a rule, iptables processes the packet according to the rule-defined method, such as accept, reject, and drop. The main task of configuring a firewall is to add, modify, and delete these rules.
(2). chain)
A chain is the path for packet propagation. each chain is actually a check list among many rules. each chain can have one or several rules. When a packet arrives at a chain, iptables checks the first rule in the chain to check whether the packet meets the conditions defined by the rule. If yes, the system will process the packet according to the method defined by the rule; otherwise, iptables will continue to check the next rule. if the packet does not comply with any rule in the chain, iptables is pre-determined based on the chain.