linux 2.0 ipfs/firewalld
linux 2.2 ipchain/firewall
linux 2.4 iptables/netfilter (iptables 是在使用者空間寫規則的,neifilter工作在核心空間放置規則的位置)
netfilter是核心的乙個資料報處理模組,具有如下功能:
網路位址轉換
資料報內容修改
資料報過濾的防火牆功能
五個鉤子函式:input output,forward,pre_routing,post_routing
表:mangle表:對資料進行修改,包含5條鏈
raw表:,prerouting,output
filter表:過濾 input,output,forward
nat表:prerouting,postouting
目標位址轉換是發生在路由決策前,剛進入本機的時候,源位址轉換是在出去的時候。
防火牆處理資料報的方式
accept,drop,reject,snat,dnat
網路資料報由底層資料報的網絡卡接收,通過資料鏈路層的捷報之後(去除資料鏈路層幀頭),就進入了tcp/ip協議棧(本質上就是乙個處理網路資料報的核心驅動)和netfilter混合的資料報的處理流程中了。
總結一下規律:
1)當乙個資料報進入網絡卡的時候,資料報首先進入prerouting鏈,在prerouting鏈中我們有機會修改資料報的目的ip,然後核心的路由模組根據資料報的目的ip判斷是否需要轉出去
2)如果資料報就是進入本機的,資料報就會沿著圖向下移動,到達input鏈,資料報到達input鏈後。任何程序都會收到它
3)本機上執行的程式傳送資料報經過output鏈,然後經過postrouting鏈輸出
4)如果資料報是要**出去的,且核心允許**,資料報就會香油移動,經過forward鏈,然後到達postrouting鏈輸出。
-f 清除規則
-x 清除鏈
-t filter 指定表
-p tcp/udp
-j drop/reject/accept/
-s源位址
-d 目的位址
-i eth0 從網路介面eth0進來
-o eth0 從網路介面eth0出去
--sport 源埠
--dportz 目的埠
iptable防火牆詳解
一.基本格式 1.iptable t 表 命令選項 連名 匹配條件 j 動作 2.常用命令選項如下 二.舉例 iptable t filter f 清空filter表中所有規則 iptable t filter z 清空filter表中的計數器值 iptable t filter x 清除filte...
iptable防火牆詳解
一.基本格式 1.iptable t 表 命令選項 連名 匹配條件 j 動作 2.常用命令選項如下 二.舉例 iptables t filter f 清空filter表中所有規則 iptables t filter z 清空filter表中的計數器值 iptables t filter x 清除fi...
iptable防火牆詳解
iptable防火牆詳解 一.基本格式 1.iptable t 表 命令選項 連名 匹配條件 j 動作 2.常用命令選項如下 二.舉例 iptable t filter f 清空filter表中所有規則 iptable t filter z 清空filter表中的計數器值 iptable t fil...