【问题标题】:debian buster/10 iptables raw TRACE, no logsdebian buster/10 iptables raw TRACE,没有日志
【发布时间】:2020-09-10 13:35:01
【问题描述】:

我有一个新安装的 debian buster/10,我想检查 iptables TRACE 日志,所以我添加了 iptables 的原始 TRACE 规则:

iptables -t raw -A PREROUTING -j TRACE

我根据this page设置这个:

modprobe nf_log_ipv4
sysctl net.netfilter.nf_log.2=nf_log_ipv4

但我在 syslog、kern.log 或消息中仍然没有 TRACE 日志,-j LOG 有效。并且“xtables-monitor -t”可以显示TRACE包。

# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:    Debian GNU/Linux 10 (buster)
Release:        10
Codename:       buster

# uname -a
Linux debian 4.19.0-10-amd64 #1 SMP Debian 4.19.132-1 (2020-07-24) x86_64 GNU/Linux

# iptables --version
iptables v1.8.2 (nf_tables)

# lsmod | grep xt_
xt_LOG                 16384  0
xt_TRACE               16384  0
xt_mark                16384  3
xt_TPROXY              16384  2
nf_tproxy_ipv6         16384  1 xt_TPROXY
nf_tproxy_ipv4         16384  1 xt_TPROXY
xt_nat                 16384  5
nf_nat                 36864  2 nf_nat_ipv4,xt_nat
xt_addrtype            16384  2
xt_tcpudp              16384  10
xt_conntrack           16384  3
nf_conntrack          172032  6 xt_conntrack,nf_nat,ipt_MASQUERADE,nf_nat_ipv4,xt_nat,nf_conntrack_netlink
nf_defrag_ipv6         20480  2 nf_conntrack,xt_TPROXY
nf_defrag_ipv4         16384  2 nf_conntrack,xt_TPROXY
x_tables               45056  11 xt_conntrack,nft_compat,xt_TRACE,xt_LOG,xt_tcpudp,ipt_MASQUERADE,xt_addrtype,xt_nat,xt_TPROXY,ip_tables,xt_mark

# lsmod | grep log
nft_log                16384  0
nfnetlink_log          20480  0
nf_log_ipv4            16384  0
nf_log_common          16384  1 nf_log_ipv4
nf_tables             143360  303 nft_chain_route_ipv4,nft_compat,nft_log,nft_chain_nat_ipv4,nft_counter
nfnetlink              16384  5 nft_compat,nf_conntrack_netlink,nf_tables,nfnetlink_log

我错过了什么?谢谢。

【问题讨论】:

    标签: debian trace iptables debian-buster raw


    【解决方案1】:

    正如here 所说,debian buster 默认使用 nftables 作为后端:

    注意:从 Debian Buster 开始,iptables 将被 nftables 取代

    当前状态

    注意:Debian Buster 默认使用 nftables 框架。

    从 Debian Buster 开始,nf_tables 是默认后端 使用 iptables,通过 iptables-nft 层(即,使用 iptables 语法与 nf_tables 内核子系统)。这也是 影响 ip6tables、arptables 和 ebtables。

    #debian 频道上的 somiaj@freenode 建议使用 nft,我试过了,效果很好,规则来自 iptables 包装器:

    chain OUTPUT {
            type filter hook output priority -300; policy accept;
            meta l4proto udp udp dport 53 counter packets 10526 bytes 658659 nftrace set 1
    }
    

    nft 监控跟踪

    # nft monitor trace
    trace id 802a6813 ip raw OUTPUT packet: oif "eth0" ip saddr 192.168.0.88 ip daddr 208.67.222.222 ip dscp cs0 ip ecn not-ect ip ttl 64 ip id 32950 ip length 75 udp sport 54299 udp dport domain udp length 55 @th,64,96 4657996495637740913470472193
    trace id 802a6813 ip raw OUTPUT rule meta l4proto udp udp dport 53 counter packets 10694 bytes 669129 nftrace set 1 (verdict continue)
    trace id 802a6813 ip raw OUTPUT verdict continue
    trace id 802a6813 ip raw OUTPUT
    ......
    trace id 8c561cef ip mangle POSTROUTING mark 0x000000ff
    trace id 8c561cef ip nat POSTROUTING verdict continue mark 0x000000ff
    trace id 8c561cef ip nat POSTROUTING mark 0x000000ff
    

    更多请参考https://wiki.nftables.org/wiki-nftables/index.php/Ruleset_debug/tracing

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-04
      • 1970-01-01
      • 2023-01-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-04-08
      相关资源
      最近更新 更多