跳转至

Linux Mod相关命令


2015-04-28 by dongnan

举个栗子

modinfo

查看模块信息

modinfo xt_pn_nat
filename:       /lib/modules/2.6.32-279.el6.x86_64/kernel/net/netfilter/xt_pn_nat.ko
description:    Xtables: pn Session hash match
author:         xxxx  <learz@xxxx.com>
license:        GPL
srcversion:     8018FB312BD4E184EB84503
depends:
vermagic:       2.6.32-504.8.1.el6.x86_64 SMP mod_unload modversions

命令帮助

MODINFO(8)                                                          MODINFO(8)

NAME
       modinfo - program to show information about a Linux Kernel module

SYNOPSIS
       modinfo [ -0 ]  [ -F field ]  [ -k kernel ]  [ modulename|filename... ]

       modinfo -V

       modinfo -h

DESCRIPTION
       modinfo  extracts information from the Linux Kernel modules given on the command line. 
       If the module name is not a filename, then the /lib/modules/version directory is searched, 
       as done by modprobe(8).

modprobe

载入模块

modprobe xt_pn_nat
iptables -A PREROUTING -t nat -p udp -m multiport --dports 2502:3501 -m pn_nat --set-bucket 2 --set-key 1 --hash 1 -j REDIRECT --to-port 2503
iptables -A PREROUTING -t nat -p tcp --dport 80 -m pn_nat --set-bucket 2 --set-key 1 --hash 1 -j REDIRECT --to-port 81
iptables -A PREROUTING -t nat -p udp -m multiport --dports 2502:3501 -m pn_nat --set-bucket 2 --set-key 1 --hash 2 -j REDIRECT --to-port 2504
iptables -A PREROUTING -t nat -p tcp --dport 80 -m pn_nat --set-bucket 2 --set-key 1 --hash 2 -j REDIRECT --to-port 82

命令帮助

NAME
       modprobe - program to add and remove modules from the Linux Kernel

SYNOPSIS
       modprobe [ -v ]  [ -V ]  [ -C config-file ]  [ -n ]  [ -i ]  [ -q ]  [ -b ]  [ -o modulename ]  [ modulename ]  [ module parameters... ]

       modprobe [ -r ]  [ -v ]  [ -n ]  [ -i ]  [ modulename... ]

       modprobe [ -l ]  [ -t dirname ]  [ wildcard ]

       modprobe [ -c ]

       modprobe [ --dump-modversions ]

DESCRIPTION
       modprobe  intelligently adds or removes a module from the Linux kernel: 
        note that for convenience, there is no difference between _ and - in module names.  
       modprobe looks in the module directory /lib/modules/‘uname -r‘ for all the modules and other files, 
        except for the optional /etc/modprobe.conf configuration file and  /etc/modprobe.d  directory .
       modprobe will also use module options specified on the kernel command line in the form of <module>.<option>.

lsmod

查找模块

lsmod  | grep -i tg3

tg3                   161928  0
ptp                   9614  2 tg3,e1000e

模块信息

modinfo tg3

filename:       /lib/modules/2.6.32-431.el6.x86_64/kernel/drivers/net/tg3.ko
firmware:       tigon/tg3_tso5.bin
firmware:       tigon/tg3_tso.bin
firmware:       tigon/tg3.bin
version:        3.132
license:        GPL
description:    Broadcom Tigon3 ethernet driver
author:         David S. Miller (davem@redhat.com) and Jeff Garzik (jgarzik@pobox.com)
srcversion:     D3303E874FEA932D684299B

rmmod

删除模块

rmmod xt_pns_nat

depmod

产生模块依赖的映射文件

depmod -a



回到页面顶部