根据给定的IP,配置dhcp服务为相应的网段,比如服务器的ip为192.168.1.1,则dhcp服务配置为192.168.1.2 到 192.168.1.255
#!/bin/sh
startdhcpserver() {
AP_IPADDR=192.168.1.1
dhcpstart=`echo $AP_IPADDR | cut -d . -f 4`
dhcpstart=`expr $dhcpstart + 1`
dhcpstart=`echo $AP_IPADDR | cut -d . -f 1-3`.$dhcpstart
dhcpend=`echo $AP_IPADDR | cut -d . -f 1-3`.255
echo "dhcp server $dhcpstart $dhcpend"
echo -e "
start $dhcpstart
end $dhcpend
interface br0
max_leases 150
auto_time 5
lease_file /tmp/udhcpd.lease
opt dns $AP_IPADDR
option subnet 255.255.255.0
opt router $AP_IPADDR
opt wins $AP_IPADDR
option dns 129.219.13.81
option domain local
option lease 864000
" >/tmp/dhcpd.conf
sync;
echo "start dhcp server"
udhcpd /tmp/dhcpd.conf
}