busybox中udhcpc的默认script脚本地址为
#define DEFAULT_SCRIPT CONFIG_UDHCPC_DEFAULT_SCRIPT
#define CONFIG_UDHCPC_DEFAULT_SCRIPT "/usr/share/udhcpc/default.script"
我想之所以以它作为默认地址,肯定有他的道理,所以在这个地址上创建它[luther.gliethttp]
luther@gliethttp:/vobs/initramfs$ mkdir usr/share/udhcpc/ -p
luther@gliethttp:/vobs/initramfs$ cp ~/busybox-1.14.3/examples/udhcp/simple.script usr/share/udhcpc/default.script
luther@gliethttp:/vobs/initramfs$ chmod +x usr/share/udhcpc/default.script
在/etc/inittab中加入下面一行语句:
::once:"/sbin/udhcpc >/dev/null 2>&1" # udhcpc会退出,所以不能使用respawn,必须为once,1次,否则将一直出现udhcpc重启log信息
就这样简单的几行ip和dns就能自动获取了[luther.gliethttp]
其实有些东西就可以放在rcS等启动脚本中,有些可以到init脚本中去完成.
# /sbin/udhcpc
### adapter index 2
### adapter hardware address 00:00:00:00:08:36
udhcpc (v1.14.3) started
### vfork'ing and exec'ing /usr/share/udhcpc/default.script
### entering raw listen mode
### opening raw socket on ifindex 2
### got raw socket fd 5
### attached filter to raw socket fd 5
### bound to raw socket fd 5
### adding option 0x35
### adding option 0x3d
### adding option 0x3c
### adding option 0x39
Sending discover...
### Waiting on select...
### Got valid DHCP packet
### adding option 0x35
### adding option 0x3d
### adding option 0x3c
### adding option 0x32
### adding option 0x36
Sending select for 192.168.1.102...
### Waiting on select...
### Got valid DHCP packet
Lease of 192.168.1.102 obtained, lease time 172800
### vfork'ing and exec'ing /usr/share/udhcpc/default.script
deleting routers
route: SIOCDELRT: No such process
adding dns 211.161.46.84
adding dns 202.106.0.20
### entering none listen mode
#
阅读(11438) | 评论(0) | 转发(1) |