linux下udhcpc的使用
linux-dash
A beautiful web dashboard for Linux
项目地址:https://gitcode.com/gh_mirrors/li/linux-dash
·
udhcpc是集成在busybox里面的,所以在编译busybox的时候加入dhcp的选项就可以了。
如果没有udhcpc的执行文件,可以手动连接一个:ln -s /bin/busybox /sbin/udhcpc
直接使用udhcpc只能分配ip地址,但是没有写入到设备中,即这个ip地址并没有生效。因为udhcpc需要一个默认的配置文件default.script,查看这个配置文件,它实际的作用就是将分配到的ip地址通过ifconfig命令写入设备中。
#!/bin/sh
# udhcpc script edited by Tim Riker <Tim@Rikers.org>
[ -z "$1" ] && echo "Error: should be called from udhcpc" && exit 1
RESOLV_CONF="/etc/resolv.conf"
[ -n "$broadcast" ] && BROADCAST="broadcast $broadcast"
[ -n "$subnet" ] && NETMASK="netmask $subnet"
case "$1" in
deconfig)
/sbin/ifconfig $interface 0.0.0.0
;;
renew|bound)
<span style="color:#ff0000;">/sbin/ifconfig $interface $ip $BROADCAST $NETMASK</span>
if [ -n "$router" ] ; then
echo "Deleting routers"
while route del default gw 0.0.0.0 dev $interface 2>/dev/null ; do
:
done
for i in $router ; do
route add default gw $i dev $interface
done
fi
echo -n > $RESOLV_CONF
[ -n "$domain" ] && echo search $domain >> $RESOLV_CONF
for i in $dns ; do
echo adding dns $i
echo nameserver $i >> $RESOLV_CONF
done
;;
esac
exit 0将这个默认的script文件拷贝到/usr/share/udhcpc/目录下,这个目录是udhcpc的默认路径
A beautiful web dashboard for Linux
最近提交(Master分支:2 个月前 )
186a802e
added ecosystem file for PM2 5 年前
5def40a3
Add host customization support for the NodeJS version 5 年前
新一代开源开发者平台 GitCode,通过集成代码托管服务、代码仓库以及可信赖的开源组件库,让开发者可以在云端进行代码托管和开发。旨在为数千万中国开发者提供一个无缝且高效的云端环境,以支持学习、使用和贡献开源项目。
更多推荐


所有评论(0)