Analysis of dport and sport and iptablesdport in iptables
First, let's talk about the concepts of dport and sport:
Dport -------- destination port
Sport -------- Source Port
It is important to note that it is related to the flow behavior of our data packets, that is, the INPUT or OUTPUT.
For example, iptables-a input-p tcp -- dport 80-j ACCEPT here is the INPUT parameter, so this indicates that our data packet is in the operation, then the dport address here is 80, that is, to access port 80 on my local device. This packet can be described as follows:
(1) This is a data entry from the external to the internal local server.
(2) the destination address of the data packet is 80, which is to access the local port 80.
(3) Allow the above data to pass
For example, iptables-a output-p tcp -- dport 80-j ACEPT indicates the OUTPUT parameter. Therefore, this indicates that the outbound operation is performed for this data packet. This data packet can be described as follows:
(1) This is a piece of internal data.
(2) the destination port is 80.
(3) Allow the above data behavior.
Input behavior Summary: dport refers to local and sport refers to external.
Output behavior Summary: dport refers to external, sport refers to local