openwrt - dnsmasq

最後更新: 2018-03-07



dnsmasq 設定檔位置:


/etc/init.d/dnsmasq restart ==> /etc/config/dhcp + /etc/dnsmasq.conf ==> /var/etc/dnsmasq.conf


config dnsmasq
        option domainneeded     1

        # Reject reverse lookups to private IP ranges where no corresponding entry exists in /etc/hosts
        option boguspriv        1

        option filterwin2k      0  # enable for dial on demand
        option localise_queries 1
        option rebind_protection 1  # disable if upstream must serve RFC1918 addresses
        option rebind_localhost 1  # enable for RBL checking and similar services
        #list rebind_domain example.lan  # whitelist RFC1918 responses for domains
        option local            '/lan/'
        option domain           'lan'
        option expandhosts      1

        # Default 得 150 ...
        option cachesizecachesize        2048
        option nonegcache       0

        # Force dnsmasq into authoritative mode. This speeds up DHCP leasing.
        option authoritative    1

        option readethers       1
        option leasefile        '/tmp/dhcp.leases'
        option resolvfile       '/tmp/'
        #list server            '/mycompany.local/'
        #option nonwildcard     1
        #list interface         br-lan
        #list notinterface      lo
        #list bogusnxdomain     ''


# DHCP Server

config dhcp lan
        option interface        lan
        option start            100
        option limit            150
        option leasetime        12h
        # Forces DHCP serving on the specified interface
        option force            1

config dhcp wan
        option interface        wan
        # dnsmasq should ignore this pool
        option ignore           1


# Static Leases

config host
        option ip       ''
        option mac      '11:22:33:44:55:66,aa:bb:cc:dd:ee:ff'
        option name     'mylaptop'


# Custom Domain

config 'domain'
    option 'name' 'typhoon'
    option 'ip'   ''






The client broadcasts messages on the network subnet using the destination address or the specific subnet broadcast address.

A DHCP client may also request its last-known IP address.

If the client remains connected to the same network, the server may grant the request.

Otherwise, it depends whether the server is set up as authoritative or not.

An authoritative server denies the request, causing the client to issue a new request.

A non-authoritative server simply ignores the request, leading to an implementation-dependent timeout for the client to expire the request and ask for a new IP address.