| 主機參考:VPS測評參考推薦/專注分享VPS服務器優惠信息!若您是商家可以在本站進行投稿,查看詳情!此外我們還提供軟文收錄、PayPal代付、廣告贊助等服務,查看詳情! |
| 我們發布的部分優惠活動文章可能存在時效性,購買時建議在本站搜索商家名稱可查看相關文章充分了解該商家!若非中文頁面可使用Edge瀏覽器同步翻譯!PayPal代付/收錄合作 |
IPTABLES四張表五條鏈
iptables具有Filter, NAT, Mangle, Raw四種內建表。
IPTABLES數據包流程
數據包先經過PREOUTING,由該鏈確定數據包走向:? 目的地址是本地,則發送到INPUT,讓INPUT決定是否接收下來送到用戶空間,流程為①---gt;②;? 若滿足PREROUTING的nat表上的轉發規則,則發送給FORWARD,然后再經過POSTROUTING發送出去,流程為: ①---gt;③---gt;④---gt;⑥;? 主機發送數據包時,流程則是⑤---gt;⑥;? 其中PREROUTING和POSTROUTING指的是數據包的流向,如上圖所示POSTROUTING指的是發往公網的數據包,而PREROUTING指的是來自公網的數據包。
Linux下IPtables下Filter表Filter表示iptables的默認表,因此如果你沒有自定義表,那么就默認使用filter表,它具有以下三種內建鏈:? INPUT鏈 – 處理來自外部的數據;? OUTPUT鏈 – 處理向外發送的數據;? FORWARD鏈 – 將數據轉發到本機的其他網卡設備上。
Linux下IPtables下NAT表NAT (網絡地址轉換) 技術在平時是很多見的,如家庭中在使用路由器共享上網時,一般用的就是 NAT 技術,它可以實現眾多內網 IP 共享一個公網 IP 上網。NAT 的原理,簡單的說就是當內網主機訪問外網時,當內網主機的數據包要通過路由器時,路由器將數據包中的源內網 IP 地址改為路由器上的公網 IP 地址,同時記錄下該數據包的消息;外網服務器響應這次由內而外發出的請求或數據交換時,當外網服務器發出的數據包經過路由器時,原本是路由器上的公網 IP 地址被路由器改為內網 IP 。SNAT 和 DNAT 是 iptables 中使用 NAT 規則相關的的兩個重要概念。如上圖所示,如果內網主機訪問外網而經過路由時,源 IP 會發生改變,這種變更行為就是 SNAT;反之,當外網的數據經過路由發往內網主機時,數據包中的目的 IP (路由器上的公網 IP) 將修改為內網 IP,這種變更行為就是 DNAT 。NAT表有三種內建鏈:? PREROUTING鏈 – 處理剛到達本機并在路由轉發前的數據包。它會轉換數據包中的目標IP地址(destination ip address),通常用于DNAT(destination NAT)。? POSTROUTING鏈 – 處理即將離開本機的數據包。它會轉換數據包中的源IP地址(source ip address),通常用于SNAT(source NAT)。? OUTPUT鏈 – 處理本機產生的數據包。
Iptables four tables five chains
Iptables has four built-in tables: filter, NAT, mangle and raw.
Iptables package process
The data packet is first routed through preouting, and then it is determined by the chain: if the destination address is local, it will be sent to input, and the input will decide whether to receive it and send it to the user space. The process is ① -- gt; ②; if the forwarding rules on the NAT table of preouting are met, it will be sent to forward, and then it will be sent out through posting, and the process is ① -- gt; ③ -- gt; ④ --- gt; ⑥; - when the host sends data packets, the process is ⑤ -- gt; ⑥; - among which pre routing and post routing refer to the flow direction of data packets, as shown in the figure above, post routing refers to the data packets sent to the public network, while pre routing refers to the data packets from the public network.
The filter table in iptables under Linux represents the default table of iptables. Therefore, if you do not have a custom table, the filter table is used by default. It has three types of built-in chains: input chain - processing data from external sources; output chain - processing data sent out; forward chain - forwarding data to other network card devices of the machine.
NAT (network address translation) technology of NAT table under iptables under Linux is often seen. For exle, when a router is used to share the Internet in the home, NAT technology is generally used. It can realize that many intranet IP share a public IP to access the Internet. The principle of NAT is simply that when the intranet host accesses the external network, when the packet of the intranet host needs to pass through the router, the router will change the source IP address of the packet to the public IP address of the router Address, and record the message of the packet; when the external server responds to the request or data exchange sent from the inside out, when the packet sent by the external server passes through the router, the original public IP address on the router is changed to the internal IP address by the router. SNAT and DNAT are two important concepts related to the use of NAT rules in iptables. As shown in the figure above, if the internal network host accesses the external network and passes through the route, the source IP will change, and this change behavior is SNAT; otherwise, when the data of the external network is routed to the internal network host, the destination IP in the data packet (the public IP on the router) will be changed to the internal IP, and this change behavior is DNAT. There are three types of built-in chains in NAT tables: i.e. prerouting chain - which processes packets just arriving at the local machine and before routing and forwarding. It translates the destination IP address in the packet, which is usually used for DNAT (destination NAT). ? posting chain - processes packets that are about to leave the machine. It translates the source IP address in the packet, which is usually used for SNAT. ? output chain - processes packets generated locally.
--------------------------------------------------------------
主機參考,收集國內外VPS,VPS測評,主機測評,云服務器,虛擬主機,獨立服務器,國內外服務器,高性價比建站主機相關優惠信息@www.k2270.com
詳細介紹和測評國外VPS主機,云服務器,國外服務器,國外主機的相關優惠信息,商家背景,網絡帶寬等等,也是目前國內最好的主機云服務器VPS參考測評資訊優惠信息分享平臺
這幾篇文章你可能也喜歡:
- TMHHOST香港/洛杉磯Cloud Server支付RMB 188,雙ISP住宅IP,CN2 - GIA/CUII/4837(洛杉磯CERA Server)
- Yinyun Korea的雙ISP IP VPS重新裝修$ 6 $ 6,長期以來享受50%的折扣,升級為電信的雙向CN2,中國Unicom Mobile Direct Connection,3個網絡延遲100!
- 寶塔虛擬機配置SLB獨立IP(寶塔虛擬機)
- win10電腦如何更改IP地址
- #圣誕節+新年#VMISS香港VPS,40折,91元/年,1核/1G/10G SSD/月流量500M@1T
本文由主機參考刊發,轉載請注明:IPtables概念和功能 http://www.k2270.com/12317.html
主機參考

















評論前必須登錄!
注冊