2021年2月4日 星期四

Busybox udhcpc 使用方法

#使用方法
udhcpc -i eth1 -p /var/run/udhcpc.pid -S -s /bin/udhcpc.sh 

更新租約(renew DHCP lease)
kill -SIGUSR1 `cat /var/run/udhcpc.pid`

釋放租約(release current release)
kill -SIGUSR2 `cat /var/run/udhcpc.pid`

#udhcpc.sh 內容
#!/bin/sh
[ -z "$interface" ]&&exit 0;
[ -z "${ip}" ]&&exit 0;
ip addr add ${ip}/${subnet} dev ${interface};
ip route add default via ${router};x='';
mkdir /etc;
for i in $dns;do x="${x}\nnameserver ${i}";done;
echo -e "${x}" >/etc/resolv.conf;set >> /etc/leases;
exit 0;

沒有留言: