最近项目需要支持ebtables,从官网(http://ebtables.netfilter.org/)下载源码,交叉编译,然后放在设备上运行,
执行 ebtables -L 时出现问题,提示错误:
modprobe: could not parse modules.dep
The kernel doesn't support the ebtables 'filter' table.。
按照提示,应该是kernel模块没有加载导致,
lsmod命令查看已经加载的模块,发现没有 ebtables相关的模块,
于是手动加载了 ebtables.ko提示错误:
/lib/modules # insmod ebtables.ko
insmod: cannot insert `ebtables.ko': Unknown symbol in module (-1): No such file or directory
查看内核日志:
#dmesg -c
ebtables: Unknown symbol xt_find_match
ebtables: Unknown symbol xt_check_match
ebtables: Unknown symbol xt_register_target
ebtables: Unknown symbol xt_check_target
ebtables: Unknown symbol xt_find_target
ebtables: Unknown symbol xt_unregister_target
未知的符号:xt_find_match
于是乎,去内核的源码编译目录,查找符号xt_find_match依赖的内核模块:
linux/kernels/mips-linux-2.6.31$ cat Module.symvers |grep xt_check_match
0x00000000 xt_check_match net/netfilter/x_tables EXPORT_SYMBOL_GPL
xt_find_match依赖的x_tables模块
查看设备上的确没有加载x_tables模块
copy /linux/kernels/mips-linux-2.6.31/net/netfilter/x_tables.ko到设备上
insmod /lib/modules /x_tables.ko
然后加载ebtables相关的内核模块:
insmod ebt_802_3.ko
insmod ebtable_filter.ko
insmod ebtables.ko
insmod ebt_arp.ko
insmod ebt_dnat.ko
insmod ebt_limit.ko
insmod ebt_mark.ko
insmod ebt_nflog.ko
insmod ebt_redirect.ko
insmod ebt_stp.ko ebt_vlan.ko
insmod ebtable_broute.ko
insmod ebtable_nat.ko
insmod ebt_among.ko
insmod ebt_arpreply.ko
insmod ebt_ip.ko
insmod ebt_log.ko
insmod ebt_mark_m.ko
insmod ebt_pkttype.ko
insmod ebt_snat.ko
insmod ebt_ulog.ko
车看ebtables -L命令执行。正常,ebtables可以使用了
~ # ebtables -L
Bridge table: filter
Bridge chain: INPUT, entries: 0, policy: ACCEPT
Bridge chain: FORWARD, entries: 0, policy: ACCEPT
Bridge chain: OUTPUT, entries: 0, policy: ACCEPT
~ #
总结:
加载模块的时候 dmesg提示:Unknown symbol xxxx时,是相应的内核模块没有加载导致,应去内核的编译目录查找相应的依赖库(Module.symvers )。