預備知識(轉): iptable有三種隊列(表)規則,mangle queue, filter queue, nat queue。
1。The first is the mangle table which is responsible for the alteration of quality of service bits in the TCP header.
2。The second table is the filter queue which is responsible for packet filtering.
* Forward chain: Filters packets to servers protected by the firewall.
* Input chain: Filters packets destined for the firewall.
* Output chain: Filters packets originating from the firewall.
3。The third table is the nat queue which is responsible for network address translation. It has two built-in chains; these are:
* Pre-routing chain: NATs packets when the destination address of the packet needs to be changed.
* Post-routing chain: NATs packets when the source address of the packet needs to be changed
個人總結:
iptables執行規則時,是從從規則表中從上至下順序執行的,如果沒遇到匹配的規則,就一條一條往下執行,如果遇到匹配的規則後,那麼就執行本規則,執行後根據本規則的動作(accept, reject, log等),決定下一步執行的情況,後續執行一般有三種情況。
1。一種是繼續執行當前規則隊列內的下一條規則。比如執行過Filter隊列內的LOG後,還會執行Filter隊列內的下一條規則。
2。一種是中止當前規則隊列的執行,轉到下一條規則隊列。比如從執行過accept後就中斷Filter隊列內其它規則,跳到nat隊列規則去執行
3。一種是中止所有規則隊列的執行。