Skip to content

conntrack ​

conntrack 的组件名称 conntrack, 根据其文档, 它依赖于组件 iptables, 相关内核选项为

ini
# Networking support
# -> Networking options
# -> Network packet filtering framework (Netfilter)
# -> Core Netfilter Configuration
# -> Connection tracking events
CONFIG_NF_CONNTRACK_EVENTS=y

# Networking support
# -> Networking options
# -> Network packet filtering framework (Netfilter)
# -> Core Netfilter Configuration
# -> Connection tracking netlink interface
CONFIG_NF_CT_NETLINK=y

检查工具为

bash
#!/bin/bash

source ./kernel_config_utils.sh

conntrack_check() {
    is_error=false
    if ! kernel_config_check CONFIG_NF_CONNTRACK_EVENTS; then
        is_error=true
    fi
    if ! kernel_config_check CONFIG_NF_CT_NETLINK nf_conntrack_netlink; then
        is_error=true
    fi
    if [ "$is_error" == "true" ]; then
        return 1
    fi

    if ! ${CONNTRACK_CMD} -L > /dev/null 2>&1; then
        echo "conntrack list failed"
        return 1
    fi

    return 0
}