banner



How To Change Dhcp Lease Time On Router

See as well: DNS and DHCP examples, dnsmasq, odhcpd

OpenWrt uses dnsmasq and odhcpd to serve DNS/DHCP and DHCPv6 past default.

Roles Ports Packages Configuration
DNS 53/UDP, 53/TCP dnsmasq /etc/config/dhcp
DHCP 67/UDP, 68/UDP
DHCPv6 547/UDP odhcpd-ipv6only

Dnsmasq serves as a downstream caching DNS server advertizement itself to DHCP clients. This allows better operation and management of DNS functionality on your local network. Every received DNS query not currently in cache is forwarded to the upstream DNS servers.

Possible section types of the dhcp configuration file are divers below. Not all types may appear in the file and almost of them are merely needed for special configurations. The mutual ones are the Common Options, the DHCP Pools and Static Leases.

The default configuration contains one common section to specify DNS and daemon related options and one or more DHCP pools to define DHCP serving on network interfaces.

Sections of the type dnsmasq specify per dnsmasq instance the values and options relevant to the overall functioning of the dnsmasq instance and the DHCP options on all interfaces served. The following table lists all available options, their default value, as well as the corresponding dnsmasq command line pick. Meet the dnsmasq man page for further details.

These are the default settings for the common options:

            # uci -Due north show dhcp.@dnsmasq[0]            dhcp.@dnsmasq[            0            ]=dnsmasq dhcp.@dnsmasq[            0            ].domainneeded='ane'            dhcp.@dnsmasq[            0            ].boguspriv='1'            dhcp.@dnsmasq[            0            ].filterwin2k='0'            dhcp.@dnsmasq[            0            ].localise_queries='1'            dhcp.@dnsmasq[            0            ].rebind_protection='1'            dhcp.@dnsmasq[            0            ].rebind_localhost='ane'            dhcp.@dnsmasq[            0            ].local='/lan/'            dhcp.@dnsmasq[            0            ].domain='lan'            dhcp.@dnsmasq[            0            ].expandhosts='1'            dhcp.@dnsmasq[            0            ].nonegcache='0'            dhcp.@dnsmasq[            0            ].authoritative='1'            dhcp.@dnsmasq[            0            ].readethers='i'            dhcp.@dnsmasq[            0            ].leasefile='/tmp/dhcp.leases'            dhcp.@dnsmasq[            0            ].resolvfile='/tmp/resolv.conf.d/resolv.conf.auto'            dhcp.@dnsmasq[            0            ].nonwildcard='one'            dhcp.@dnsmasq[            0            ].localservice='1'          

Options:

Proper name Blazon Default Option Description
add_local_domain boolean i Add the local domain as search directive in resolv.conf.
add_local_hostname boolean 1 Add A, AAAA, and PTR records for this router only on DHCP served LAN.
:!: enhanced function available on Trunk with selection add_local_fqdn
add_local_fqdn integer 1 Add A, AAAA, and PTR records for this router just on DHCP served LAN.
:!: add_local_fqdn on Trunk but non 17.01.0
0 : Disable.
1 : Hostname on Primary Accost.
2 : Hostname on All Addresses.
3 : FDQN on All Addresses.
4 : iface.host.domain on All Addresses.
:!: add_local_fqdn on Body simply non 17.01.0
add_wan_fqdn integer 0 Labels WAN interfaces like add_local_fqdn instead of your Internet access provider assigned default which may be obscure. WAN is inferred from config dhcp sections with option ignore 1 fix, and so they practise not demand to exist named WAN
:!: add_wan_fqdn on Torso but not 17.01.0
addnhosts listing of file paths (none) -H Additional host files to read for serving DNS responses. Syntax in each file is the aforementioned as /etc/hosts
authoritative boolean 1 -Chiliad Strength dnsmasq into authoritative mode. This speeds upward DHCP leasing. Used if this is the only server on the network
bogusnxdomain listing of IP addresses (none) -B IP addresses to convert into NXDOMAIN responses (to annul "helpful" upstream DNS servers that never return NXDOMAIN).
boguspriv boolean 1 -b Pass up reverse lookups to private IP ranges where no respective entry exists in /etc/hosts
cachelocal boolean i When ready to 0, use each network interface's dns accost in the local /etc/resolv.conf. Normally, simply the loopback address is used, and all queries go through dnsmasq.
cachesize integer 150 -c Size of dnsmasq query cache.
dbus boolean 0 -1 Enable DBus messaging for dnsmasq.
:!: Standard builds of dnsmasq on OpenWrt practise not include DBus support.
dhcp_boot string (none) --dhcp-boot Specifies BOOTP options, in nearly cases just the file name. You lot tin can besides use: "file name, tftp server name, tftp ip address"
dhcphostsfile file path (none) --dhcp-hostsfile Specify an external file with per host DHCP options
dhcpleasemax integer 150 -Ten Maximum number of DHCP leases
dnsforwardmax integer 150 -0 (zero) Maximum number of concurrent connections
domain domain name (none) -s DNS domain handed out to DHCP clients
domainneeded boolean i -D Tells dnsmasq never to forward queries for apparently names, without dots or domain parts, to upstream nameservers. If the name is not known from /etc/hosts or DHCP so a "not found" reply is returned
dnssec boolean 0 --dnssec Validate DNS replies and cache DNSSEC information.
:!: Requires the dnsmasq-total package.
dnsseccheckunsigned boolean 0 --dnssec-check-unsigned Cheque the zones of unsigned replies to ensure that unsigned replies are allowed in those zones. This protects against an attacker forging unsigned replies for signed DNS zones, but is slower and requires that the nameservers upstream of dnsmasq are DNSSEC-capable.
:!: Requires the dnsmasq-full package.
:!: Caution: If you employ this option on a device that doesn't have a hardware clock, dns resolution may interruption after a reboot of the device due to an incorrect arrangement fourth dimension.
ednspacket_max integer 1232 -P Specify the largest EDNS.0 UDP packet which is supported past the DNS forwarder
enable_tftp boolean 0 --enable-tftp Enable the builtin TFTP server
expandhosts boolean 1 -E Add the local domain part to names found in /etc/hosts
filterwin2k boolean 0 -f Do not forward requests that cannot exist answered past public proper name servers.
Make sure information technology is disabled if y'all demand to resolve SRV records or apply SIP phones.
fqdn boolean 0 --dhcp-fqdn Practise not resolve unqualifed local hostnames. Needs domain to be set up.
interface list of interface names (all interfaces) -i List of interfaces to listen on. If unspecified, dnsmasq will listen to all interfaces except those listed in notinterface. Note that dnsmasq listens on loopback by default.
ipset list of strings (none) --ipset The syntax is: list ipset '/instance.com/example.org/example_ipv4,example_ipv6'
:!: Requires the dnsmasq-full package.
leasefile file path (none) -l (lowercase "L") Shop DHCP leases in this file
local cord (none) -S Look up DNS entries for this domain from /etc/hosts. This follows the same syntax as server entries, see the man page.
localise_queries boolean 1 -y Cull IP address to match the incoming interface if multiple addresses are assigned to a host proper noun in /etc/hosts. Initially disabled, but even so enabled in the config past default. :!: Notation well the spelling of this option.
localservice boolean ane --local-service Take DNS queries only from hosts whose address is on a local subnet, ie a subnet for which an interface exists on the server.
local_ttl integer 0 --local-ttl Default TTL for locally administrative answers.
localuse boolean ane Employ dnsmasq as a local system resolver. Initially disabled, but still enabled via the default noresolv and resolvfile options.
logfacility string DAEMON --log-facility=<facility> Gear up the facility to which dnsmasq will send syslog entries. Come across the dnsmasq man page for available facilities.
logqueries boolean 0 --log-queries=extra Log the results of DNS queries, dump enshroud on SIGUSR1, include requesting IP
nodaemon boolean 0 -d Don't daemonize the dnsmasq process
nohosts boolean 0 -h Don't read DNS names from /etc/hosts
nonegcache boolean 0 -N Disable caching of negative "no such domain" responses
noresolv boolean 0 -R Don't read upstream servers from /etc/resolv.conf which is linked to resolvfile by default
notinterface listing of interface names (none) -I (uppercase "i") Interfaces dnsmasq should not listen on.
nonwildcard boolean ane --demark-dynamic Demark only configured interface addresses, instead of the wildcard address.
port port number 53 -p Listening port for DNS queries, disables DNS server functionality if set up to 0
queryport integer (none) -Q Use a stock-still port for outbound DNS queries
readethers boolean 0 -Z Read static lease entries from /etc/ethers, re-read on SIGHUP
rebind_protection boolean one --terminate-dns-rebind Enables DNS rebind attack protection by discarding upstream RFC1918 responses
rebind_localhost boolean 1 --rebind-localhost-ok Allows upstream 127.0.0.0/viii responses, required for DNS based blacklist services, only takes effect if rebind protection is enabled
rebind_domain list of domain names (none) --rebind-domain-ok List of domains to allow RFC1918 responses for, merely takes outcome if rebind protection is enabled. The correct syntax is: listing rebind_domain '/example.com/'
resolvfile file path /tmp/resolv.conf.d/resolv.conf.auto -r Specifies an alternative resolv file
server list of strings (none) -S Listing of DNS servers to frontward requests to. See the dnsmasq man page for syntax details.
rev_server list of strings (none) --rev-server List of network range with a DNS server to frontwards contrary DNS requests to. Run across the dnsmasq man page for syntax details.
strictorder boolean 0 -o Obey social club of DNS servers in /etc/resolv.conf
tftp_root directory path (none) --tftp-root Specifies the TFTP root directory
minport integer 0 --min-port Dnsmasq picks random ports equally source for outbound queries. When this selection is given, the ports used will always exist larger than or equal to the specified minport value (min valid value 1024). Useful for systems behind firewalls.
maxport integer 0 --max-port Dnsmasq picks random ports every bit source for outbound queries. When this option is given, the ports used will ever be smaller than or equal to the specified maxport value (max valid value 65535). Useful for systems behind firewalls.
noping boolean 0 --no-ping By default dnsmasq checks if an IPv4 address is in use before allocating it to a host by sending ICMP repeat request (aka ping) to the accost in question. This parameter allows to disable this check.
allservers boolean 0 --all-servers By default, when dnsmasq has more than one upstream server available, it will ship queries to just one server. Setting this parameter forces dnsmasq to send all queries to all available servers. The answer from the server which answers first volition be returned to the original requeser.
quietdhcp boolean 0 --tranquillity-dhcp Suppress logging of the routine operation of DHCP. Errors and bug volition withal exist logged
sequential_ip boolean 0 --dhcp-sequential-ip Dnsmasq is designed to choose IP addresses for DHCP clients using a hash of the customer's MAC address. This normally allows a client's address to remain stable long-term, fifty-fifty if the client sometimes allows its DHCP charter to elapse. In this default mode IP addresses are distributed pseudo-randomly over the entire available address range. There are sometimes circumstances (typically server deployment) where it is more than user-friendly to have IP addresses allocated sequentially, starting from the lowest available address, and setting this parameter enables this fashion. Note that in the sequential mode, clients which allow a charter to expire are much more likely to movement IP accost; for this reason information technology should not be by and large used.
addmac [0,one,base64,text] 0 --add-mac Add together the MAC address of the requester to DNS queries which are forwarded upstream; this may be used to practise DNS filtering by the upstream server.
The MAC address can but exist added if the requester is on the same subnet every bit the dnsmasq server. Note that the mechanism used to attain this (an EDNS0 option) is not nonetheless standardised, and so this should be considered experimental. Also notation that exposing MAC addresses in this way may have security and privacy implications.
logdhcp boolean 0 --log-dhcp Enables actress DHCP logging; logs all the options sent to the DHCP clients and the tags used to determine them
dhcpscript cord (none) --dhcp-script Run a custom script upon DHCP charter add / renew / remove actions
confdir directory path /tmp/dnsmasq.d --conf-dir Directory with boosted configuration files
max_ttl integer (none) --max-ttl limit the ttl in the DNS respond to this value
min_cache_ttl integer (none) --min-cache-ttl set the minimum time-to-live of DNS answers, fifty-fifty when the ttl in the answer is lower
max_cache_ttl integer (none) --max-cache-ttl the maximum time-to-live for any DNS answer, even if higher

Sections of the type dhcp specify per interface lease pools and settings for serving DHCP requests. Typically there is at least i section of this type present in the /etc/config/dhcp file to cover the lan interface.

Yous tin disable a lease pool for a specific interface by specifying the ignore option in the corresponding section.

A minimal example of a dhcp section is listed below:

            # uci -Northward testify dhcp.@dhcp[0]            dhcp.@dhcp[            0            ]=dhcp dhcp.@dhcp[            0            ].interface='lan'            dhcp.@dhcp[            0            ].start='100'            dhcp.@dhcp[            0            ].limit='150'            dhcp.@dhcp[            0            ].leasetime='12h'          

Below is a listing of legal options for dhcp sections.

Name Type Required Default Description
dhcp_option list of strings no (none) The ID dhcp_option hither must exist with written with an underscore. OpenWrt will translate this to --dhcp-option, with a hyphen, as ultimately used past dnsmasq. Multiple pick values can exist given for this network-id, with a a space betwixt them and the total string betwixt "". Due east.thousand. '26,1470' or 'option:mtu, 1470' that can assign an MTU per DHCP. Your customer must take MTU by DHCP for this to work. Or "3,192.168.ane.1 six,192.168.ane.i" to give out gateway and dns server addresses. A list of options tin can be establish here here. A list of the symbolic pick names that dnsmasq recognises can be plant by running dnsmasq --help dhcp.
dhcp_option_force list of strings no (none) Exactly the aforementioned as dhcp_option (note the underscores), simply it will be translated to --dhcp-option-forcefulness, meaning that the DHCP option volition be sent regardless on whether the customer requested it.
:!: dhcp_option_force on Trunk but non 17.01.0
dynamicdhcp boolean no 1 Dynamically classify client addresses, if set to 0 only clients present in the ethers files are served
force boolean no 0 Forces DHCP serving on the specified interface even if another DHCP server is detected on the same network segment
ignore boolean no 0 Specifies whether dnsmasq should ignore this pool if set to ane
dhcpv4 string no (none) Specifies whether DHCPv4 server should be enabled (server) or disabled (disabled)
dhcpv6 string no (none) Specifies whether DHCPv6 server should be enabled (server), relayed (relay) or disabled (disabled)
ra string no (none) Specifies whether Router Advertisements should be enabled (server), relayed (relay) or disabled (disabled)
ra_default integer no 0 Default router lifetime in the RA message will be gear up if default route is present and a global IPv6 accost (0) or if default route is present merely no global IPv6 address (1) or neither of both conditions (ii)
ra_management integer no 1 RA direction mode : no M-Flag but A-Flag (0), both M and A flags (1), Grand flag merely non A flag (2)
ra_offlink bool no 0 Announce prefixes as offlink (1) in RAs
ra_preference cord no medium Announce routes with either high (high), medium (medium) or depression (depression) priority in RAs
ra_mininterval integer no 200 Minimum time interval between RAs (in seconds)
ra_maxinterval integer no 600 Maximum time interval between RAs (in seconds)
ra_lifetime integer no 1800 Advertised router lifetime (in seconds)
ra_useleasetime bool no 0 Limit the preferred and valid lifetimes of the prefixes in the RA messages to the configured DHCP leasetime
ra_hoplimit integer no 0 Advertised electric current hop limit (0-255)
ra_reachabletime integer no 0 Advertised reachable fourth dimension (in milliseconds) (0-3600000)
ra_retranstime integer no 0 Advertised NS retransmission time (in milliseconds) (0-60000)
ra_mtu integer no (none) Maximum advertised MTU
ra_dns boolean no 1 Announce DNS configuration in RA messages (RFC8106)
ndp string no (none) Specifies whether NDP should exist relayed (relay) or disabled (disabled)
ndproxy_routing bool no 1 Learn routes from NDP
ndproxy_slave bool no 0 Ignore neighbour letters on slave enabled (ane) interfaces
master boolean no 0 Specifies whether DHCPv6, RA and NDP in relay manner is a main interface or not.
interface logical interface name yes (none) Specifies the interface associated with this DHCP address pool; must be one of the interfaces divers in /etc/config/network.
leasetime string yes 12h Specifies the lease time of addresses handed out to clients, for instance 12h or 30m
limit integer yep 150 Specifies the size of the address pool (e.g. with beginning=100, limit=150, maximum address volition be .249)
networkid string no (value of interface) The dhcp functionality defined in the dhcp section is limited to the interface indicated hither through its network-id. In case omitted the organization tries to know the network-id via the interface setting in this dhcp section, through consultation of /etc/config/network. Some IDs go assigned dynamically, are non provided by network, but still can be set hither.
commencement integer yes 100 Specifies the offset from the network address of the underlying interface to calculate the minimum accost that may exist leased to clients. It may be greater than 255 to span subnets.
instance dnsmasq instance no (none) Dnsmasq instance to which the dhcp department is bound; if not specified the section is valid for all dnsmasq instances.
tag list of tag names no (none) List of tags that dnsmasq needs to match to apply with --dhcp-range.

Notes:

This departs from ifname and network as used in /etc/config/network and in /etc/config/wireless, and then double check!

You can assign fixed IP addresses to hosts on your network, based on their MAC (hardware) address using the host department. The configuration options in this section are used to construct a -G option for dnsmasq.

Name Blazon Required Default Description
ip string no (none) the IP address to be used for this host, or ignore to ignore any DHCP request from this host
mac string no (none) The hardware address(es) of this host, separated past spaces.
hostid cord no (none) The IPv6 interface identifier (address suffix) as hexadecimal number (max. 8 chars)
duid string no (none) The DHCPv6-DUID of this host.
name string no (none) Optional hostname to assign.
tag cord no (none) Set the given tag for matching hosts.
match_tag listing of strings no (none) If specified the department will apply just to requests having all the tags; incoming interface name is ever car-assigned, other tags can be added by vendorclass/userclass/etc. sections
dns boolean no 0 Add static forward and contrary DNS entries for this host.
circulate boolean no 0 Force broadcast DHCP response.
leasetime cord no (none) Host-specific charter time, due east.g. 2m, 3h, 5d. Notation: introduced by r48801 in trunk
instance dnsmasq instance no (none) Dnsmasq instance to which the host department is bound; if not specified the department is valid for all dnsmasq instances.

Note: i of mac (can use wildcards), duid or proper name must be specified.

You can also enable the readethers option in the dnsmasq section and add together entries to the /etc/ethers file.

Some hosts support booting over the network (PXE booting). Sections of the type boot specify how DHCP/BOOTP is used to tell the host which file to kicking and the server to load it from. Each client can merely receive one set of filename and server address options. If unlike hosts should boot different files, or boot from different servers, you can use network-ids to map options to each client.

Usually, you need to ready additional DHCP options (through dhcp_option) for further stages of the kicking process. See the dnsmasq man page for details on the syntax of the O option.

The configuration options in this section are used to construct a -M pick for dnsmasq.

*Notation*: odhcp currently lacks support root-path specification. If you need this functionality, disable odhcpd and use dnsmasq instead.

Name Type Required Default Description
dhcp_option list of strings no (none) Additional options to be added for this network-id. :!: If you specify this, you too demand to specify the network-id.
filename string yes (none) The filename the host should asking from the kicking server.
networkid string no (none) The network-id these boot options should utilise to. Applies to all clients if left unspecified.
serveraddress string aye (none) The IP accost of the boot server.
servername string yes (none) The hostname of the kick server.
force bool no (none) dhcp_option volition always be sent, fifty-fifty if the client does non ask for it in the parameter asking list. This is sometimes needed, for example when sending options to PXELinux.
instance dnsmasq case no (none) Dnsmasq instance to which the kicking section is leap. If not specified the department is valid for all dnsmasq instances.

DHCP tin provide the client with numerous options, such as the domain name, NTP servers, network booting options, etc. While some settings are applicable to all hosts in a network segment, other are more specific and apply only to a grouping of hosts, or even only a unmarried one. dnsmasq offers to group DHCP options and their values past a network-id, an alphanumeric identifier, and sending options just to hosts which accept been tagged with that network-id.

In OpenWrt, you can tag hosts past the DHCP range they're in (section dhcp), or a number of options the client might send with their DHCP asking. In each of these sections, yous tin utilize the dhcp_option list to add DHCP options to be sent to hosts with this network-id.

You lot can employ the following classifying sections:

Name Description
mac Hardware address of the client.
tag An alphanumeric label which marks the network.
vendorclass String sent past the customer representing the vendor of the client. dnsmasq performs a substring match on the vendor class string using this value.
userclass String sent by the client representing the user of the client. dnsmasq performs a substring match on the user class string using this value.
circuitid Matches the circuit ID as sent by the relay agent, as defined in RFC3046.
remoteid Matches the remote ID as sent past the relay agent, as defined in RFC3046.
subscrid Matches the subscriber ID equally sent past the relay amanuensis, as defined in RFC3993.

Each classifying section has ii configuration options: the value of the DHCP option used to distinguish clients, and the network-id that matching clients will be tagged with.

Name Type Required Default Description
<classifier> string yes (none) Utilize section type equally option proper noun and classifying filter equally option value.
networkid string aye (none) The tag that matching clients will get assigned.
dhcp_option list of strings no (none) Boosted options to be added for this network-id.
force bool no false Whether to ship the additional options from dhcp_option list to the clients that didn't request them.

Section tag must exist named and doesn't require option classifier . Make sure _all_ sections accept unique names, or else uci show dhcp volition render uci: Parse mistake… and odhcpd will ignore the whole config.

:!: Requires the dnsmasq-total bundle.

dnsmasq tin can automatically populate Netfilter IP sets with resolved addresses of the specified domains. This feature tin be enabled using ipset option in the dnsmasq section, or, with a more than user-friendly syntax, using a dedicated ipset section. Every ipset section contains names of the IP sets to populate (name, multiple IP set up names can be specified in 1 department), and domains whose resolved addresses should be added to the specified IP sets (domain). Case:

            # uci -N prove dhcp.@ipset[0]            dhcp.@ipset[            0            ]=ipset dhcp.@ipset[            0            ].proper name='ss_rules_dst_forward'            'ss_rules6_dst_forward'            dhcp.@ipset[            0            ].domain='telegram.org'            'linkedin.com'          

If yous are routing betwixt two interfaces (i.e. they are not bridged) then y'all volition find that clients on the far end of the network sending DHCP requests get no response, equally the DHCP broadcast cannot exist routed between interfaces.

This can be solved without setting up an independent DHCP server for the far subnet by configuring dnsmasq to act as a DHCP relay. In this configuration it listens for DHCP requests as normal, frontward them to a remote DHCP server, so any response information technology receives it broadcasts back in the original subnet.

This configuration allows a single DHCP server to handle accost assignments across a large network broken up into multiple subnets.

As of October 2021 LuCI does non take an interface for this so the configuration file must be manually edited.

Add the post-obit section to /etc/config/dhcp:

config relay 'id'         pick interface 'lan'         option local_addr '1.1.1.1'         pick server_addr 'two.two.ii.2'
Name Blazon Required Default Description
id string yes (none) A unique proper noun for the section, which must be different to every other section's proper noun.
interface string yep (none) OpenWRT interface name (Not network device proper name) where the destination DHCP server is located.
local_addr string yeah (none) This OpenWRT device'due south own IP address on the far subnet, where it will mind for DHCP requests.
server_addr cord yep (none) IP address of the upstream DHCP server attainable through the network given by the interface choice. DHCP responses picked upwardly on the far subnet will be relayed to this server. This accost must be routed correctly (i.e. yous tin can ping it successfully from the OpenWRT command line).

Restart dnsmasq subsequently making the change with /etc/init.d/dnsmasq restart.

Source: https://openwrt.org/docs/guide-user/base-system/dhcp

Posted by: russbrisiong.blogspot.com

0 Response to "How To Change Dhcp Lease Time On Router"

Post a Comment

Iklan Atas Artikel

Iklan Tengah Artikel 1

Iklan Tengah Artikel 2

Iklan Bawah Artikel