歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux編程 >> Linux編程 >> Linux文件系統使用udhcpc動態獲取ip配置

Linux文件系統使用udhcpc動態獲取ip配置

日期:2017/3/1 11:15:05   编辑:Linux編程

簡介
系統環境:
Loongson1B開發板、Linux3.0.0內核、Busybox1.19.2

BusyBox各版本下載見 http://www.linuxidc.com/Linux/2011-08/40704.htm

相關閱讀:移植Busybox與構建根文件系統 http://www.linuxidc.com/Linux/2011-10/44886.htm

編譯環境:
Ubuntu 10.04、gcc-3.4.6-2f

1.配置過程

1.1、配置Linux內核使能DHCP相關選項:
[*]Networking support -->
Networking support
Networking options -->
[*]Packet socket
[*]IP:kernel level autoconfiguration
[*] IP:DHCP support
[*]Network packet filtering framework(Netfilter) --> //下層子選項可不作配置
如下圖:

1.2、配置Busybox,使能以下選項:
Networking Utilities
[*]udhcp server (udhcpd)
[*] dhcprelay
[*] Lease display utility (dumpleases)
[*]udhcp client (udhcpc)
[*] Verify that the offered address is free,using ARP ping
如下圖:

1.3、使用Busybox下的simple.script
進入busybox目錄:busybox1.19.2/example/udhcp/,拷貝文件simple.script到根文件系統的/usr/share/udhcpc/目錄下,更名為default.simple,再將default.script中RESOLV_CONF=”/etc/resolv.conf”更改為RESOLV_CONF=”/tmp/resolv.conf”。
(說明:由於測試使用Cramfs文件系統,etc目錄不可寫,運行udhcpc無法在/etc目錄下創建resolv.conf文件。)

1.4、拷貝工具
重新編譯安裝busybox,將安裝文件拷至根文件系統目錄,運行udhcpc即可動態獲取IP。

Copyright © Linux教程網 All Rights Reserved