您可以修改/etc/init.d/dhcp3-server
启动脚本,以等待IP地址在上可用br0
。例如:(警告:未经测试的代码!)
# wait 5 secs between br0-ready tests
wait_time_between_probes=5
# maximum number of attempts (i.e., timeout)
max_attempts=10
log_progress_msg "Waiting for br0 to get an IP address"
for n in $(seq 1 $max_attempts); do
if /sbin/ifconfig br0 | egrep -q "inet addr:" ; then
# IP address ready on br0, exit loop
break
else
sleep $wait_time_between_probes
fi
done
if [ "$n" = "$max_attempts" ]; then
log_warning_msg "Maximum number of attempts reached, but br0 has no IP address yet"
log_warning_msg "Continuing anyway but DHCP3 server might not start correctly"
fi
case ... start)
在启动DHCP3守护程序之前,该代码段应进入该部分中的启动脚本。当然,您应该调整等待时间和尝试次数以匹配您的环境(br0最多需要多长时间才能获取IP地址?)