OpenWrt Forum Archive

Topic: dnsmasq: how to set IP range?

The content of this topic has been archived on 21 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

hey,
I'm using kamikaze 7.07 on wrt54gl.
I want dnsmasq to serve IP addresses in a range from 192.168.0.150 to 192.168.0.200 inside my private network.

here is my /etc/config/dhcp

config dhcp
        option interface        lan
        option start     150
        option limit     200
        option leasetime        12h

but logread says the following:

Sep  2 15:54:01 OpenWrt daemon.info dnsmasq[492]: started, version 2.38 cachesize 150
Sep  2 15:54:01 OpenWrt daemon.info dnsmasq[492]: compile time options: IPv6 GNU-getopt ISC-leasefile no-DBus no-I18N TFTP
Sep  2 15:54:01 OpenWrt daemon.info dnsmasq[492]: DHCP, IP range 192.168.0.150 -- 192.168.0.253, lease time 12h
Sep  2 15:54:01 OpenWrt daemon.info dnsmasq[492]: using local addresses only for domain lan
Sep  2 15:54:01 OpenWrt daemon.info dnsmasq[492]: reading /tmp/resolv.conf.auto
Sep  2 15:54:01 OpenWrt daemon.info dnsmasq[492]: using nameserver xxx.xxx.xx.xx#53
Sep  2 15:54:01 OpenWrt daemon.info dnsmasq[492]: using nameserver xxx.xxx.xx.xx#53
Sep  2 15:54:01 OpenWrt daemon.info dnsmasq[492]: using local addresses only for domain lan
Sep  2 15:54:01 OpenWrt daemon.info dnsmasq[492]: read /etc/hosts - 1 addresses
Sep  2 15:54:01 OpenWrt daemon.err dnsmasq[492]: failed to read /etc/ethers:No such file or directory

and nvram shows:

root@OpenWrt:~# nvram show | grep dhcp
size: 3172 bytes (29596 left)
dhcp_start=150
dhcp_num=50

Is there anything I've missed??
thank you.

(Last edited by openwrt on 2 Sep 2007, 15:15)

First, Kamikaze does not use NVRAM at all. To configure you have to use UCI (or edit /etc/config/dhcp manually with a editor).

To configure a pool from 192.168.0.150-200, do this:

uci set dhcp.cfg1.start=150
uci set dhcp.cfg1.end=50
uci del dhcp.cfg1.limit
uci commit dhcp
/etc/init.d/dnsmasq restart

EDIT: There is a bug in 7.07 (which is fixed in trunk). A workaround is to use the 'end' option instead of 'limit' in the config.

Sep  2 17:00:47 OpenWrt daemon.info dnsmasq[681]: DHCP, IP range 192.168.0.150 -- 192.168.0.200, lease time 12h

(Last edited by forum2006 on 2 Sep 2007, 16:57)

Hi!

This works for me on 7.09... (wrt54g V2)

config dhcp
        option interface        lan
        option start     100
        option limit     50
        option leasetime        12h

I get DHCP range: from 192.168.1.100 to 192.168.1.150

Doesn't seem to work with option end though...

You could use /etc/dnsmasq.conf instead.  Here is an edited version of mine which should work based on the above.  It serves addresses between 192.168.1.200 and 192.168.1.250.

==== start =
# filter what we send upstream
domain-needed
bogus-priv
filterwin2k
localise-queries

# allow /etc/hosts and dhcp lookups via *.lan
local=/lan/
domain=lan
expand-hosts


# enable dhcp (start,end,netmask,leasetime)
dhcp-authoritative
dhcp-range=192.168.1.200,192.168.1.250,255.255.255.0,24h
dhcp-leasefile=/tmp/dhcp.leases

# use /etc/ethers for static hosts; same format as --dhcp-host
# <hwaddr> [<hostname>] <ipaddr>
read-ethers

# other useful options:
# default route(s): dhcp-option=3,192.168.1.1,192.168.1.2
#    dns server(s): dhcp-option=6,192.168.1.1,192.168.1.2

==== end =

I then replace /etc/init.d/dnsmasq with the following script.  It kills any running dnsmasq before starting a new dnsmasq. It isn't pretty but it works.

==== start =
#!/bin/sh /etc/rc.common

if ps | grep /usr/sbin/dnsmasq | grep -v grep >/dev/null
then
kill `ps | grep /usr/sbin/dnsmasq | grep -v grep | awk '{print $1}'`
fi

if [ -f /tmp/dhcp.leases ]
then
rm /tmp/dhcp.leases
fi

/usr/sbin/dnsmasq
==== end =

(Last edited by trigram on 18 Nov 2007, 06:57)

The discussion might have continued from here.