有關Linux ipv6模塊加載失敗的問題


有關Linux ipv6模塊加載失敗的問題

  同事一個SUSE11sp3環境配置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加載不完整。
      
    在網上搜到一篇禁用ipv6的博文,也有相關說明,讀者可以參考一下。

 

  PS:

  您的支持是對博主最大的鼓勵👍,感謝您的認真閱讀。
   本文版權歸作者所有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM