Static DHCP conf file

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


Joined: 26 Dec 2015
Posts: 147

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 Novice


Joined: 17 Oct 2016
Posts: 40

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 Novice


Joined: 17 Oct 2016
Posts: 40

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: 147

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 Novice


Joined: 17 Oct 2016
Posts: 40

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: 147

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 Novice


Joined: 17 Oct 2016
Posts: 40

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: 147

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 Novice


Joined: 03 Jun 2016
Posts: 48

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: 147

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 Novice


Joined: 17 Oct 2016
Posts: 40

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 Novice


Joined: 03 Jun 2016
Posts: 48

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.
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum 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