OpenWrt Forum Archive

Topic: I can not automatically receive their network settings

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

I want to use dhcp server.

but do not run function.


[/etc/config/network]

config 'interface' 'loopback'
        option 'ifname' 'lo'
        option 'proto' 'static'
        option 'ipaddr' '127.0.0.1'
        option 'netmask' '255.0.0.0'

config 'interface' 'lan_l'
        option 'type' 'bridge'
        option 'ifname' 'eth0.0'
        option 'proto' 'static'
        option 'ipaddr' '192.168.200.11'
        option 'netmask' '255.255.255.0'
        option 'gateway' '192.168.200.1'
        option 'defaultroute' '0'
        option 'peerdns' '0'

config 'interface' 'lan_r'
        option 'type' 'bridge'
        option 'ifname' 'eth0.1'
        option 'proto' 'dhcp'
        option 'ipaddr' '192.168.200.11'
        option 'netmask' '255.255.255.0'
        option 'dns' ''

[/etc/config/dhcp]

config 'dnsmasq'
        option 'domainneeded' '1'
        option 'boguspriv' '1'
        option 'localise_queries' '1'
        option 'domain' 'lan'
        option 'expandhosts' '1'
        option 'authoritative' '1'
        option 'readethers' '1'
        option 'leasefile' '/tmp/dhcp.leases'
        option 'resolvfile' '/tmp/resolv.conf.auto'
        option 'local' '/lan_l/'

config 'dhcp'
        option 'interface' 'lan_l'
        option 'start' '100'
        option 'limit' '150'
        option 'leasetime' '12h'
        option 'dynamicdhcp' '1'

I have similar problem, but I don't like luci,uci, webif, therefore only manual settings for me.

My interesting is about this dnsmaq option:

    --dhcp-hostsfile=<filename>     Read DHCP host specs from file

Where I set this? In /etc/config/dhcp?
What is the correct syntax of <filename>?

I have wgt634u with 8.09.
Thanks, Luca.

lucapost wrote:

My interesting is about this dnsmaq option:

    --dhcp-hostsfile=<filename>     Read DHCP host specs from file

Where I set this? In /etc/config/dhcp?
What is the correct syntax of <filename>?

You could either set this in /etc/dnsmasq.conf with a line saying "dhcp-hostsfile=/path/to/your/file" (there are no double dashes in front of the option when it appears in that config file) or in /etc/config/dhcp in the "config dnsmasq" section with a line like

    option    dhcphostsfile    /path/to/your/file

(note the absence of a dash)

I would probably prefer setting it in /etc/config/dhcp, since that is more openwrt-like and can easily be operated on with uci.

Concerning the syntax, http://www.thekelleys.org.uk/dnsmasq/do … q-man.html says it is the same as what you would put after the --dhcp-host= option, one entry per line.

But pondering on that, if you don't really need an extra file and if you also don't need any of the fancier features of the --dhcp-host option, you should probably consider not using the dhcphostfile option at all and just put all the hosts into /etc/config/dhcp. You do that by creating one section for each host you want to define. Like that:

config host
    option name    foobar
    option mac    00:01:23:ab:cd:ef
    option ip    192.168.1.45
    option dhcp_option    42,192.168.1.1

Option mac and option ip are mandatory. Option name and option dhcp_option are optional, but name is required if you want any of your dhcp_option lines in that section to have an effect.

Since I for myself only need to map mac addresses to hostnames (the hostnames are mapped to ip addresses in my /etc/hosts file), I don't even need that possibility, I just use an /etc/ethers file instead.


Regards,
Niels Böhm

thanks you very much for complete details!

LP

I have another question about dnsmasq config. In my /etc/config/dhcp i have this options

config dnsmasq
       ...
       option expandhosts    1
       ...


config host
        option name             pippo
        option mac              XX:XX:XX:XX:XX:XX
        option ip               192.168.1.2

I think that expandhost setting read only /etc/hosts, and not "config host".
In my client and router i have only "127.0.0.1 localhost" in /etc/hosts, and if I ping my router (it name is openwrt) i get:

#> ping openwrt
ping: unknown host openwrt

Is correct this behaviour? the only way for resolv the name of my clients is insert there in /etc/hosts in my router?

The discussion might have continued from here.