OpenWrt Forum Archive

Topic: dnsmasq - how to set domain name?

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

Hi Folks,

I would like to change the domain name given out by dnsmasq via DHCP. It seems, however, to be always "lan" nevertheless what I change in my config :-(

I have tried to
- set the nvram variable "wan_domain"
- cat it's content into /proc/sys/kernel/domainname in S10boot (as already done by hostname)
- added a domain suffix to hostname, so it is now "router.mydomain"
- passed the -s option to dnsmasq:

root@router:/usb/home/root# cat /etc/init.d/S50dnsmasq
#!/bin/sh
. /etc/functions.sh

# interface to use for DHCP
iface=lan

ifname=$(nvram get ${iface}_ifname)
ipaddr=$(nvram get ${iface}_ipaddr)
netmask=$(nvram get ${iface}_netmask)

# check for existing DHCP server
udhcpc -n -q -R -s /bin/true -i $ifname >&- || {

  ipaddr=$(ip2int $ipaddr)
  netmask=$(ip2int ${netmask:-255.255.255.0})
  network=$((ipaddr&netmask))

  start=$(nvram get dhcp_start)
  start=$((network+${start:-100}))
  end=$(nvram get dhcp_num)
  end=$((start+${end:-150}))

  args="-l /var/dhcp.leases -s mydomain --log-queries --bogus-priv --filterwin2k --domain-needed -K -F $(int2ip $start),$(int2ip $end),$(int2ip $netmask),12h"
}
dnsmasq ${args}

However, dnsmasq still assumes "lan" as domain name:

<snip from log>
Aug 24 22:06:08 (none) kern.info dnsmasq[1220]: reading /etc/resolv.conf
Aug 24 22:06:08 (none) kern.info dnsmasq[1220]: using nameserver 145.253.2.203#53
Aug 24 22:06:08 (none) kern.info dnsmasq[1220]: using nameserver 195.50.140.250#53
Aug 24 22:06:08 (none) kern.info dnsmasq[1220]: using local addresses only for domain lan
Aug 24 22:06:08 (none) kern.info dnsmasq[1220]: exiting on receipt of SIGTERM
Aug 24 22:06:40 (none) kern.info dnsmasq[1435]: started, version 2.22 cachesize 150
Aug 24 22:06:40 (none) kern.info dnsmasq[1435]: DHCP, IP range 192.168.1.10 -- 192.168.1.60, lease time 12h
Aug 24 22:06:40 (none) kern.info dnsmasq[1435]: using local addresses only for domain lan
Aug 24 22:06:40 (none) kern.info dnsmasq[1435]: read /etc/hosts - 2 addresses
Aug 24 22:06:40 (none) kern.err dnsmasq[1435]: failed to read /etc/ethers:No such file or directory
Aug 24 22:06:40 (none) kern.info dnsmasq[1435]: reading /etc/resolv.conf
Aug 24 22:06:40 (none) kern.info dnsmasq[1435]: using nameserver 145.253.2.203#53
Aug 24 22:06:40 (none) kern.info dnsmasq[1435]: using nameserver 195.50.140.250#53
Aug 24 22:06:40 (none) kern.info dnsmasq[1435]: using local addresses only for domain lan
<snip>

Where the XXX does this "lan" come from and how do I change it?

Thanks a lot!

Daniel

Take a look at /etc/dnsmasq.conf wink.

(Last edited by Grimson on 24 Aug 2005, 22:02)

Grimson wrote:

Take a look at /etc/dnsmasq.conf wink.

Oh... roll

Well, that was obvious, wasn't it? Please excuse my silly question.

However, that brings me to another (silly ?) question cool

How does dnsmasq combine the options from the config file with the command line parameters?
As I understood the man page, the config file takes precdence over the command line, however, it seems that some options are still taken from the command line while others (like -s ...) have no effect.

Daniel

Hello,

simply set line in /etc/dnsmasq.conf 
domain=mydomaine.com
and eventually : expand-hosts

Bye
Marc

From the wikipedia:

<quote>
1.1.4. Static IP-Address (leases) based on the MAC-Address of the client

NOTE: There is a known bug in dnsmasq. dnsmasq can't read the /etc/ethers file because it runs as user nobody. nbd fixed that bug in versions later than "White Russian RC4" and it is already fixed in "White Russian CVS".

To get rid of this bug, just do:

ipkg -force-overwrite -force-reinstall install http://downloads.openwrt.org/people/nbd … mipsel.ipk
</quote>

I would assume this also applies to /etc/dnsmasq.conf, considering the file is also going to be owned by root. Also, you might make sure that your changes are actually getting saved... /etc/dnsmasq.conf is a link by default, and needs to be replaced with a normal file(unless you're using the jffs2 image).

Good luck,
-elph

(Last edited by elph on 31 Oct 2005, 01:52)

Hi,

Unable to download this package :

i do
ipkg -force-overwrite -force-reinstall install \
        http://downloads.openwrt.org/people/nbd/ \
        whiterussian/packages/dnsmasq_2.22-2_mipsel.ipk

and i get
An error ocurred, return value: 21.
Collected errors:
ipkg_download: ERROR: failed to unlink /tmp/ipkg-0nhCl3/: Is a directory

Any idea ? where can i found a ipkg doc ?

Thanks and good night ;-)

The "\" at the end of each line is intepreted as a new line in shell. Splitting long lines is make it a lot more readable easier in the wiki.

Try this:

ipkg -force-overwrite -force-reinstall install http://downloads.openwrt.org/people/nbd/whiterussian/packages/dnsmasq_2.22-2_mipsel.ipk

(Last edited by olli_04 on 31 Oct 2005, 08:53)

Thanks olli_04 i'am so stupid some time ;-)

The discussion might have continued from here.