2021-05-12 14:32:11
Linux ipv6模組載入失敗解決
同事一個SUSE Linux Enterprise Server 11 SP3環境設定ipv6地址失敗,提示不支援IPv6,請求幫助,第一反應是應該ipv6相關核心模組沒有載入。
主要檢查內容:
ipv6地址是否存在
ifconfig |grep inet6
沒有預設inet6地址
ipv6模組是否存在
# modinfo -n ipv6
/lib/modules/3.0.101-0.47.90-default/kernel/net/ipv6/ipv6.ko
# modinfo -n ipv6_lib
/lib/modules/3.0.101-0.47.90-default/kernel/net/ipv6/ipv6_lib.ko
系統是否載入IPv6相關模組
lsmod |grep ipv6
# lsmod |grep ipv6
ipv6_lib 341467 0
只有ipv6_lib模組,沒有主模組ipv6
從上面資訊得知,ipv6模組是存在的,只是載入出現了問題,由此想到可能是設定導致的。
首先檢查模組的依賴關係是否正確:
# cat /lib/modules/`uname -r`/modules.dep |grep -w ipv6.ko:
/lib/modules/3.0.101-0.47.90-default/kernel/net/ipv6/ipv6.ko: /lib/modules/3.0.101-0.47.90-default/kernel/net/ipv6/ipv6_lib.ko
沒有問題
其次檢查modprobe設定,是否遮蔽了ipv6模組載入:
# cat /etc/modprobe.conf |grep -i ipv6
alias sit0 ipv6
最後檢查了/etc/modprobe.d/目錄下檔案,發現一個50-ipv6.conf檔案,內容如下:
# cat /etc/modprobe.d/50-ipv6.conf
install ipv6 /bin/true
這句話是什麼含義呢?通過modprobe.conf(5)文件,有如下內容:
install modulename command...
This is the most powerful primitive: it tells modprobe to run your command instead of inserting the module in the kernel as normal.
The command can be any shell command: this allows you to do any kind of complex processing you might wish.
For example, if the module "fred" works better with the module "barney" already installed (but it doesn't depend on it, so modprobe won't automatically load it), you could say "install fred /sbin/modprobe barney; /sbin/modprobe --ignore-install fred", which would do what you wanted.
Note the --ignore-install, which stops the second modprobe from running the same install command again. See also remove below.
You can also use install to make up modules which don't otherwise exist.
For example: "install probe-ethernet /sbin/modprobe e100 || /sbin/modprobe eepro100", which
will first try to load the e100 driver, and if it fails, then the eepro100 driver when you do "modprobe probe-ethernet".
If you use the string "$CMDLINE_OPTS" in the command, it will be replaced by any options specified on the modprobe command line. This can be useful because users expect "modprobe fred opt=1" to pass the "opt=1" arg to the module, even if there's an install command in the configuration file. So our above example becomes "install fred /sbin/modprobe barney; /sbin/modprobe --ignore-install fred $CMDLINE_OPTS"
比較長,關鍵的第一句我們來解釋一下:
This is the most powerful primitive: it tells modprobe to run your command
instead of inserting the module in the kernel as normal.
這句話的意思是它讓modprobe命令執行命令列裡的command命令,而不是一般情況下去載入指定的核心模組。
該怎麼理解這句話呢?我們通過兩個命令的執行來說明:
# modprobe -v -n ipv6
insmod /lib/modules/3.0.101-0.47.90-default/kernel/net/ipv6/ipv6_lib.ko
install /bin/true
-n --dry-run --show 表明不做真正的插入模組的操作
-v: 列印有關程式所做事情的資訊
所以上述輸出表明modprobe只做了載入ipv6_lib.ko模組和install /bin/true的動作,
而沒有做載入ipv6.ko模組
# modprobe --show-depends ipv6
insmod /lib/modules/3.0.101-0.47.90-default/kernel/net/ipv6/ipv6_lib.ko
install /bin/true
--show-depends 只列出模組依賴關係,以insmod開頭;
install命令也不做實際的載入操作,只列出要做的載入動作
從以上資訊可以看出,也不會做ipv6.ko模組載入。
去掉/bin/true之後,重新執行modprobe ipv6命令後檢查模組載入情況:
# modprobe -v ipv6
# lsmod |grep ipv6
ipv6 12758 1
ipv6_lib 341467 71 ipv6
# ifconfig |grep inet6
inet6 addr: fe80::9af5:37ff:fe00:9527/64 Scope:Link
inet6 addr: fe80::9af5:37ff:fee3:3ac4/64 Scope:Link
inet6 addr: ::1/128 Scope:Host
綜上,可以認為是50-ipv6.conf檔案的設定導致了ipv6載入不完整。
相關文章