Coustom 鏈運作良好,但未透過「iptables -L」顯示

Coustom 鏈運作良好,但未透過「iptables -L」顯示

為了執行一些轉送作業,我使用腳本新增自訂鏈。部分程式碼在這裡(以 root 身分運行):

iptables -t nat -N v2ray_forwarder
iptables -t nat -I OUTPUT -j v2ray_forwarder
iptables -t nat -A v2ray_forwarder -p tcp -m set --match-set srv_ip dst -j RETURN
iptables -t nat -A v2ray_forwarder -d 0.0.0.0/8 -j RETURN
iptables -t nat -A v2ray_forwarder -d 10.0.0.0/8 -j RETURN
iptables -t nat -A v2ray_forwarder -d 127.0.0.0/8 -j RETURN
iptables -t nat -A v2ray_forwarder -d 192.168.0.0/16 -j RETURN
iptables -t nat -A v2ray_forwarder -p tcp -m set --match-set gfw_ip dst -j REDIRECT --to-port 1081
iptables -t nat -A v2ray_forwarder -p tcp -m set ! --match-set chn_ip dst -j REDIRECT --to-port 1081

代碼工作正常,我確信包已正確轉發。但是,當我點擊 後sudo iptables -L,它出現:

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination 

在我的路由器(OpenWRT)上,iptables -L始終顯示所有鏈都存在,但它在我的筆記型電腦上不起作用。有人可以告訴我為什麼嗎?

謝謝你!

答案1

自訂鏈綁定到表。這意味著您不能使用在表中、表格mangle的規則中建立的鏈。filternat

iptables -L指令僅顯示filter錶鍊。檢查 的輸出iptables -t nat -L。但最好使用該iptables-save -c命令列出帶有計數器的完整規則集。

相關內容