如何查找要编译的内核模块

首先找到模块的名字,然后去源码中x86/x86_build/output/build/linux-4.0找到模块对应的iptable_nat.c文件
在x86/x86_build/output/build/linux-4.0/目录下grep -rn "iptable_nat.o"找到
x86/x86_build/output/build/linux-4.0/net/ipv4/netfilter/Makefile52: \
obj-$(CONFIG_IP_NF_NAT) \+= iptable_nat.o
得到配置变量是CONFIG_IP_NAT
继续在linux4.0下grep -rn "IP_NAT"
找到x86/x86_build/output/build/linux-4.0/output/build/linux-4.0/net/ipv4/netfilter/Kconfig:248:config IP_NF_NAT

config IP_NF_NAT
    tristate "iptables NAT support"   //即是内核中的开启该选项的地方
    depends on NF_CONNTRACK_IPV4      //注意这些depend选项必须先打开才能看到你想要打开的选项
    default m if NETFILTER_ADVANCED=n
    select NF_NAT
    select NF_NAT_IPV4
    select NETFILTER_XT_NAT
    help
    This enables the `nat' table in iptables. This allows masquerading,
    port forwarding and other forms of full Network Address Port
    Translation.
    
    To compile it as a module, choose M here.  If unsure, say N.
    
if IP_NF_NAT

你可能感兴趣的:(如何查找要编译的内核模块)