Static DHCP conf file

Post new topic   Reply to topic    DD-WRT Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.)
Goto page 1, 2  Next
Author Message
Brewder
DD-WRT User


Joined: 26 Dec 2015
Posts: 178

PostPosted: Sun Mar 19, 2017 13:25    Post subject: Static DHCP conf file Reply with quote
Hello,

I'm looking to re-setup my network but don't want to type in all of the MAC/dns names/IP's for each of my devices that have an existing static DHCP address.

Where is the conf file stored so I can copy/paste/replace after I re-do everything?

I found hosts but it doesn't include the MAC address reservations for DHCP.

//Brew
Sponsor
artyddwrt
DD-WRT User


Joined: 17 Oct 2016
Posts: 57

PostPosted: Mon Mar 20, 2017 1:59    Post subject: Re: Static DHCP conf file Reply with quote
Brewder wrote:
Hello,

I'm looking to re-setup my network but don't want to type in all of the MAC/dns names/IP's for each of my devices that have an existing static DHCP address.

Where is the conf file stored so I can copy/paste/replace after I re-do everything?

I found hosts but it doesn't include the MAC address reservations for DHCP.

//Brew



Not sure about the config file, but you can specify all the static hosts by command instead of using the GUI. I've got mine setup in an excel file that then generates the required commands into a single excel cell that I then paste into the command window.

.
artyddwrt
DD-WRT User


Joined: 17 Oct 2016
Posts: 57

PostPosted: Mon Mar 20, 2017 2:22    Post subject: Reply with quote
I had to use single quotes for the command to work for me.

http://www.dd-wrt.com/wiki/index.php/Static_DHCP
Brewder
DD-WRT User


Joined: 26 Dec 2015
Posts: 178

PostPosted: Mon Mar 20, 2017 10:38    Post subject: Re: Static DHCP conf file Reply with quote
artyddwrt wrote:
Brewder wrote:
Hello,

I'm looking to re-setup my network but don't want to type in all of the MAC/dns names/IP's for each of my devices that have an existing static DHCP address.

Where is the conf file stored so I can copy/paste/replace after I re-do everything?

I found hosts but it doesn't include the MAC address reservations for DHCP.

//Brew


I actually used the nvram set static_leases command but I was thinking they would then show up in the GUI... but they have not. I need to a bit more testing!


Not sure about the config file, but you can specify all the static hosts by command instead of using the GUI. I've got mine setup in an excel file that then generates the required commands into a single excel cell that I then paste into the command window.

.
artyddwrt
DD-WRT User


Joined: 17 Oct 2016
Posts: 57

PostPosted: Mon Mar 20, 2017 10:45    Post subject: static dhcp commands Reply with quote
.
They show up in the GUI the way I do it. I'll see about posting the commands in a day or so.
.
Brewder
DD-WRT User


Joined: 26 Dec 2015
Posts: 178

PostPosted: Mon Mar 20, 2017 11:46    Post subject: Re: static dhcp commands Reply with quote
artyddwrt wrote:
.
They show up in the GUI the way I do it. I'll see about posting the commands in a day or so.
.


I definitely would appreciate that! thank you.

//Brew
artyddwrt
DD-WRT User


Joined: 17 Oct 2016
Posts: 57

PostPosted: Tue Mar 21, 2017 1:42    Post subject: static dhcp - alternate option to manually entering via web Reply with quote
The settings I am using are as follows:

Setup > Basic Setup - Network Address Server Settings (DHCP)
- DHCP Type: DHCP Server
- DHCP Server: Enable
- Use DNSMasq for DHCP: checked
- Use DNSMasq for DNS: checked
- DHCP-Authoritative: checked
- Recursive DNS Resolving: checked
- Forced DNS Redirection: checked

Setup > Services - DHCP Client
- all blank settings here

Setup > Services - DHCP Server
- all blank settings here except for "Used Domain" (set to "LAN & WAN")

Setup > Services - Static Leases
- the static lease details auto populate here in the web GUI for me, reflective of what I enter as last static lease command (see further down)

Setup > Services - DNSMasq
- DNSMasq: Enable
- Local DNS: Enable
- No DNS Rebind: Enable
- Query DNS in Strict Order: Enable
- Add Requestor MAC to DNS Query: Enable



<<<Static Lease Command>>
Administration > Commands - Command Shell, Commands

- below is the format for the command that works for me. I cut and paste it into the command box and then hit the "Run Commands" button, and then after its done those static lease details are respectively reflected in the static lease area of the GUI (as described above). All the static leases I define in one single long chain of device definitions with no line breaks (ignore the line breaks shown below), with a single space between each device definition (after the lease minutes for one device and before the MAC address for the next device), and with a single set of quotes encasing the entire device chain definition:

nvram set static_leasenum=X nvram set static_leases='aa:bb:cc:dd:ee:ff=hostname1=ppp.qqq.rrr.sss=mm aa:bb:cc:dd:ee:ff=hostname2=ppp.qqq.rrr.sss=mm aa:bb:cc:dd:ee:ff=hostname3=ppp.qqq.rrr.sss=mm .............. aa:bb:cc:dd:ee:ff=hostnameLast=ppp.qqq.rrr.sss=mm'

---where:
- X is the number of static leases being defined within the command chain;
- device MAC addresses are defined by aa thru ff;
- hostname is self explanatory, but I try to remain consistent with how the device advertises itself;
- desired device static IP addresses are defined by ppp thru sss; and
- desired lease time (in minutes) is defined by mm

All of that I got from the earlier wiki location I provided. I don't remember why I realized I had to use single quotes (I believe the wiki says use standard double quotes). I think I read it somewhere else in the forums.



I am not actually convinced I have DHCP setup correctly between using the standard DHCP service and DNSMasq. Based on the wiki, it seems I might be using standard DHCP command format not DNSMasq format. Regardless, it seems to be working for me and gives me the result I was looking for (auto populating the static lease details GUI table based on the command chain I enter, and then those also being used for the actual static assignments and showing-up in the active clients list, etc...).

I can post the excel file later if you want. It is not rocket science but does allow me to easily work with and define individual device host names, subnets, MAC addresses and IP addresses, and then concatenates all of those together to form the single device definition command (instead of having to re-create it each time I want to add a device or change a static IP assignment).


Last edited by artyddwrt on Tue Mar 21, 2017 23:07; edited 1 time in total
Brewder
DD-WRT User


Joined: 26 Dec 2015
Posts: 178

PostPosted: Tue Mar 21, 2017 9:56    Post subject: Re: static dhcp - alternate option to manually entering via Reply with quote
artyddwrt wrote:
The settings I am using are as follows:

Setup > Basic Setup - Network Address Server Settings (DHCP)
- DHCP Type: DHCP Server
- DHCP Server: Enable
- Use DNSMasq for DHCP: checked
- Use DNSMasq for DNS: checked
- DHCP-Authoritative: checked
- Recursive DNS Resolving: checked
- Forced DNS Redirection: checked

Setup > Services - DHCP Client
- all blank settings here

Setup > Services - DHCP Server
- all blank settings here except for "Used Domain" (set to "LAN & WAN")

Setup > Services - Static Leases
- the static lease details auto populate here in the web GUI for me, reflective of what I enter as last static lease command (see further down)

Setup > Services - DNSMasq
- DNSMasq: Enable
- Local DNS: Enable
- No DNS Rebind: Enable
- Query DNS in Strict Order: Enable
- Add Requestor MAC to DNS Query: Enable



<<<Static Lease Command>>
Administration > Commands - Command Shell, Commands

- below is the format for the command that works for me. I cut and paste it into the command box and then hit the "Run Commands" button, and then after its done those static lease details are respectively reflected in the static lease area of the GUI (as described above). All the static leases I define in one single long chain of device definitions with no line breaks (ignore the line breaks shown below), with a single space between each device definition (after the lease minutes for one device and before the MAC address for the next device), and with a single set of quotes encasing the entire device chain definition:

nvram set static_leasenum=X nvram set static_leases='aa:bb:cc:dd:ee:ff=hostname1=ppp.qqq.rrr.sss=mm aa:bb:cc:dd:ee:ff=hostname2=ppp.qqq.rrr.sss=mm aa:bb:cc:dd:ee:ff=hostname3=ppp.qqq.rrr.sss=mm .............. aa:bb:cc:dd:ee:ff=hostnameLast=ppp.qqq.rrr.sss=mm'

---where:
- X is the number of static leases being defined within the command chain;
- device MAC addresses are defined by aa thru ff;
- hostname is self explanatory, but I try to remain consistent with how the device advertises itself;
- desired device static IP addresses are defined by ppp thru sss; and
- desired lease time (in minutes) is defined by mm

All of that I got from the earlier wiki location I provided. I don't remember why I realized I had to use single quotes (I believe the wiki says use standard double quotes). I think I read it somewhere else in the forums.

I am not actually convinced I have DHCP setup correctly between using the standard DHCP service and DNSMasq. Based on the wiki, it seems I might be using standard DHCP command format not DNSMasq format. Regardless, it seems to be working for me and gives me the result I was looking for (auto populating the static lease details GUI table based on the command chain I enter, and then those also being used for the actual static assignments and showing-up in the active clients list, etc...).

I can post the excel file later if you want. It is not rocket science but does allow me to easily work with and define individual device host names, subnets, MAC addresses and IP addresses, and then concatenates all of those together to form the single device definition command (instead of having to re-create it each time I want to add a device or change a static IP assignment).


I ran this command from a PuTTY session so maybe that's the difference for me. Tonight I'll try this from the Web UI and see what happens.

Thanks!!
//Brew
zakaron
DD-WRT User


Joined: 03 Jun 2016
Posts: 91

PostPosted: Tue Mar 21, 2017 19:16    Post subject: Reply with quote
I did mine a bit differently - not saying one way is any more correct, just want to give alternatives.

I chose to use DNSMasq for DHCP, so my static DHCP entries are not done in the "static leases" section under the Services tab, but rather in the "additional DNSMasq options" text box (under Services tab also). You will have to format your external list to the following, but it can be copy & pasted into this text box. The format is:

# hostname
dhcp-host=<mac address>,<ip>,<lease time>

Mac address is formatted as xx:xx:xx:xx:xx:xx
IP is obviously your local IP you want to assign that device.
Lease time can be in different formats such as:
8h (for 8 hours), 7d (for 7 days), 240m (for 240 minutes). It is flexible.
The # hostname is merely a comment - I use this to remind me of what host I've assigned to what IP.
Brewder
DD-WRT User


Joined: 26 Dec 2015
Posts: 178

PostPosted: Tue Mar 21, 2017 22:28    Post subject: Reply with quote
Yahtzee! Running from the command box worked... HOWERVER, I also noticed I needed to use a single quote ' instead of a double " quote.... so THAT may have been the reason it didn't work properly from PuTTY.

//Brew
artyddwrt
DD-WRT User


Joined: 17 Oct 2016
Posts: 57

PostPosted: Tue Mar 21, 2017 22:55    Post subject: Reply with quote
zakaron wrote:
I did mine a bit differently - not saying one way is any more correct, just want to give alternatives.

I chose to use DNSMasq for DHCP, so my static DHCP entries are not done in the "static leases" section under the Services tab, but rather in the "additional DNSMasq options" text box (under Services tab also). You will have to format your external list to the following, but it can be copy & pasted into this text box. The format is:

# hostname
dhcp-host=<mac address>,<ip>,<lease time>

Mac address is formatted as xx:xx:xx:xx:xx:xx
IP is obviously your local IP you want to assign that device.
Lease time can be in different formats such as:
8h (for 8 hours), 7d (for 7 days), 240m (for 240 minutes). It is flexible.
The # hostname is merely a comment - I use this to remind me of what host I've assigned to what IP.


What are the rest of your DHCP related settings? Is DHCP under Services actually enabled or disabled? I think I read somewhere folks speculating that DHCP (standard DHCP daemon not DNSMasq) needs to actually be disabled in the GUI in order to be using DNSMasq for DHCP, and then to set the static leases as you have indicated using the DNSMasq command format. However, I have not been able to get it to work and suspect my setup is actually still using the standard DHCP daemon as opposed to DNSMasq, even though I have DNSMasq checked for DHCP.

I am interested in using DNSMasq properly for DHCP to see if I can get the router away from having to issue dynamic addresses within the same CDIR notation range as the router's LAN IP address (as specified in the GUI), so I can make better use of access restrictions and QOS by IP range (using CDIR notation range to discriminate between groups of devices). Right now for me, all / any dynamic assignments always end-up being in the same range as the actual router's LAN IP address, so it's kind of hard to assign that group of devices lower QOS or choke them off using access restrictions (since those controls would also impact the router's LAN IP).

Do your static assignments (defined using DNSMasq assignment command format as you have indicated) also show - up in the GUI table for static leases? What command are you using for defining the dynamic lease range and are you able to set that differently from the router's LAN IP address?
zakaron
DD-WRT User


Joined: 03 Jun 2016
Posts: 91

PostPosted: Wed Mar 22, 2017 16:56    Post subject: Reply with quote
Yes, I do have DHCP disabled under Setup --> Basic Setup. The only boxes I have checked are:
"Use DNSMasq for DHCP" and "Use DNSMasq for DNS"
I did this because I already have a DHCP server on a Solaris machine that takes care of LAN requests. Only way I could figure out how to not include the LAN network was to disable DHCP on the Basic Setup tab. I was then free to use DNSMasq for DHCP service on my wireless networks (I have a private WLAN and guest WLAN each under different address ranges).

If we look under Setup --> Networking tab, I have a bridge interface configured for the 2.4 & 5Ghz radios for private WLAN (br1) and another brdge for the guest WLAN. This is where I define the IP segment for each bridge, then in the bottom under "Multiple DHCP Server", I define the DHCP properties for each bridge.

Now if we go to Services tab, I do have "Use JFFS2 for client lease DB" checked, "used domain" is LAN & WLAN, and LAN domain is filled in with my local domain name. Nothing is in the "Additional DHCP options" box. Under the DNSMasq heading, I have DNSMasq enabled, Local DNS enabled, No DNS rebind enabled. The strict order and MAC to DNS query are both disabled. I then have a few options in the text box for "Additional DNSMasq options", including my static DHCP leases for the wireless devices I want assigned to a static address on the private WLAN.

In short, using DNSMasq, I am able to use DHCP services for 2 of the 3 networks I have and can statically set addresses on them.

Network segments:
LAN - no DHCP provided by DD-WRT

Private WLAN - DHCP provided by DNSMasq with static leases configured in "Additional DNSMasq options"

Guest WLAN - DHCP provided by DNSMasq

All 3 of these networks are controlled tightly by IPtables rules so that I only allow certainly access between them.
vvume
DD-WRT Novice


Joined: 05 Jun 2010
Posts: 10

PostPosted: Sun Dec 16, 2018 22:27    Post subject: Reply with quote
Sorry to resurrect a thread that is more than a year old, but I would love to use this dhcp-host approach given that I have 70+ reservations, but it didn't work for me. Can you clarify the settings I would need to set on the Setup/Services pages for a regular router (single device for both router/dhcp) setup instead of the alternate DHCP setup that you had?

zakaron wrote:
I did mine a bit differently - not saying one way is any more correct, just want to give alternatives.

I chose to use DNSMasq for DHCP, so my static DHCP entries are not done in the "static leases" section under the Services tab, but rather in the "additional DNSMasq options" text box (under Services tab also). You will have to format your external list to the following, but it can be copy & pasted into this text box. The format is:

# hostname
dhcp-host=<mac address>,<ip>,<lease time>

Mac address is formatted as xx:xx:xx:xx:xx:xx
IP is obviously your local IP you want to assign that device.
Lease time can be in different formats such as:
8h (for 8 hours), 7d (for 7 days), 240m (for 240 minutes). It is flexible.
The # hostname is merely a comment - I use this to remind me of what host I've assigned to what IP.
WENED
DD-WRT Guru


Joined: 30 May 2017
Posts: 582
Location: Rural Manitoba

PostPosted: Sun Dec 16, 2018 23:44    Post subject: Staic DHCP file Reply with quote
I have 99 static reserves which I load using putty and Telnet. The file I use is contained on a USB stick which I originally created from within Telnet but am able to edit it offline if I wish.

Although I do not have 99 devices, I have assigned MAC addresses of 0's with a spare description to many of the addresses. In this way I have my various devices categorized to specific address sequences, ie. Routers to 1 through 10, computers 11 through 20, etc.

I do enter the static count though GUI command but because the actual static list exceeds 255 it is necessary to input the list as a file using the SH FILE.EX command in Telnet. Just remember the original file must be created within the Telnet interface as Telnet will not recognize a file created by notepad. Ironically once the file is created, it can be edited by notepad and will still work within the telnet interface.
I set this up two years ago and don't remember the Telenet program I used to create the file but it is a common text editor and information is widely available.
As indicate in some of the prior posts you may experience some difficulty with format, single vs double quotes, I use double and it works fine for me on my WRT's

Hope this solves your problem as it did for me.

_________________
Starlink & DSL -> TPLink TL-R470T+
->
WRT3200acm Master WDS 5GHz 80Mhz CH 100 (+6) r55819
Ath1 2.4Ghz Disabled
99 Static Leases
ExpressVPN

WRT3200acm r55819 WDS Station 5Ghz
Ath1 AP N/G Mixed Channel 11 HT40

WRT1900Ac V1 5Ghz r55819 WDS Station
(Defective, no 2.4Ghz but 5Ghz works great)

WRT1900AC V1 5Ghz AC 80Mhz WDS Station r55819
2.4Ghz AP Ch1 HT20 Mixed

WRT1900ACS SPARE r54914
WRT1900AC SPARE r54914
WRT1900AC V1 5Ghz AC 80Mhz WDS-AP r55819
2.4Ghz AP Ch1 HT20 Mixed

WRT54G DD-WRT v3.0-r37305 micro AP CH 6 Mixed - Not in use

3200 Master -> LAN -> 1900ACS -> WDS 5Ghz -> 1900 V1
3200 Master -> WDS -> 3200 Slave & 1900V1
cgigate
DD-WRT User


Joined: 03 May 2007
Posts: 183

PostPosted: Thu Feb 24, 2022 17:13    Post subject: Re: Staic DHCP file Reply with quote
WENED wrote:
I have 99 static reserves which I load using putty and Telnet. The file I use is contained on a USB stick which I originally created from within Telnet but am able to edit it offline if I wish.

Although I do not have 99 devices, I have assigned MAC addresses of 0's with a spare description to many of the addresses. In this way I have my various devices categorized to specific address sequences, ie. Routers to 1 through 10, computers 11 through 20, etc.

I do enter the static count though GUI command but because the actual static list exceeds 255 it is necessary to input the list as a file using the SH FILE.EX command in Telnet. Just remember the original file must be created within the Telnet interface as Telnet will not recognize a file created by notepad. Ironically once the file is created, it can be edited by notepad and will still work within the telnet interface.
I set this up two years ago and don't remember the Telenet program I used to create the file but it is a common text editor and information is widely available.
As indicate in some of the prior posts you may experience some difficulty with format, single vs double quotes, I use double and it works fine for me on my WRT's

Hope this solves your problem as it did for me.

which file you should edit ?

_________________
Goto page 1, 2  Next Display posts from previous:    Page 1 of 2
Post new topic   Reply to topic    DD-WRT Forum Index -> Marvell MVEBU based Hardware (WRT1900AC etc.) All times are GMT

Navigation

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You cannot download files in this forum