Static IP assignments via file

Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions
Author Message
MysticGold04
DD-WRT User


Joined: 20 Apr 2018
Posts: 174
Location: Somewhere remote

PostPosted: Mon Mar 29, 2021 19:20    Post subject: Static IP assignments via file Reply with quote
Can anyone provide me some help?

I'd like to build a text file that includes all of my static mappings, and apply them on bootup instead of assigning them manually via the GUI.

Does anyone have an example or maybe point me in the right direction? I'm sure it has to do with dhcpd options, but I'm unsure how to format the file and where to place it on the router so it picks it up.

Thanks in advance!

_________________
ASUS RT-AC3100 AP Merlin 386.12_4
ASUS RT-AC68U Media Bridge/Merlin 386.12_4 (x2)
ASUS RT-AC68U AP r54604
ASUS RT-AC68U Gateway/AP r54604
Edgerouter-4, v2.0.9-hotfix7
Sponsor
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9157

PostPosted: Mon Mar 29, 2021 21:51    Post subject: Reply with quote
If you mean static leases, you can use ssh/telnet to export the underlying DNSMasq directives (dhcp-host) from the GUI as a starting point.

Code:
grep dhcp-host /tmp/dnsmasq.conf


You could even write them to a file, say in JFFS (which has to first be enabled).

Code:
grep dhcp-host /tmp/dnsmasq.conf > /jffs/dnsmasq.custom


Then add the following directive to Additional DNSMasq Options on the Services page.

Code:
conf-file=/jffs/dnsmasq.custom

_________________
ddwrt-ovpn-split-basic.sh (UPDATED!) * ddwrt-ovpn-split-advanced.sh (UPDATED!) * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-remote-access.sh * ddwrt-ovpn-client-backup.sh * ddwrt-mount-usb-drives.sh * ddwrt-blacklist-domains.sh * ddwrt-wol-port-forward.sh * ddwrt-dns-monitor.sh (NEW!)
MysticGold04
DD-WRT User


Joined: 20 Apr 2018
Posts: 174
Location: Somewhere remote

PostPosted: Tue Mar 30, 2021 0:38    Post subject: Reply with quote
Thanks! I have the file built on /jffs but the router is not reading the file, and I have put the line in the Additional DNSMasq options area. If I do a cat /tmp/dnsmasq.conf, the configs are not listed. How does this work? In the dnsmasq.conf file there is a line that reads dhcp-leasefile=/tmp/dnsmasq.leases Do I need to edit that file as well???

Is there a way to see if the router has imported the file? or does it just check once that client joins?

Thanks for the help with this.

_________________
ASUS RT-AC3100 AP Merlin 386.12_4
ASUS RT-AC68U Media Bridge/Merlin 386.12_4 (x2)
ASUS RT-AC68U AP r54604
ASUS RT-AC68U Gateway/AP r54604
Edgerouter-4, v2.0.9-hotfix7
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9157

PostPosted: Tue Mar 30, 2021 1:08    Post subject: Reply with quote
My suggestions assume you have at least one or more static leases defined in the GUI that can be exported. If you do, and issue the following command ...

Code:
grep dhcp-host /tmp/dnsmasq.conf


... you should see one or more dhcp-host directives dumped to the command line.

If this the case?

_________________
ddwrt-ovpn-split-basic.sh (UPDATED!) * ddwrt-ovpn-split-advanced.sh (UPDATED!) * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-remote-access.sh * ddwrt-ovpn-client-backup.sh * ddwrt-mount-usb-drives.sh * ddwrt-blacklist-domains.sh * ddwrt-wol-port-forward.sh * ddwrt-dns-monitor.sh (NEW!)
MysticGold04
DD-WRT User


Joined: 20 Apr 2018
Posts: 174
Location: Somewhere remote

PostPosted: Tue Mar 30, 2021 1:29    Post subject: Reply with quote
eibgrad wrote:
My suggestions assume you have at least one or more static leases defined in the GUI that can be exported. If you do, and issue the following command ...

Code:
grep dhcp-host /tmp/dnsmasq.conf


... you should see one or more dhcp-host directives dumped to the command line.

If this the case?


Yes. I was able to follow the directions you sent previously to export what I had, then added to the file, and saved to /jffs/dnsmasq.custom.

_________________
ASUS RT-AC3100 AP Merlin 386.12_4
ASUS RT-AC68U Media Bridge/Merlin 386.12_4 (x2)
ASUS RT-AC68U AP r54604
ASUS RT-AC68U Gateway/AP r54604
Edgerouter-4, v2.0.9-hotfix7
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9157

PostPosted: Tue Mar 30, 2021 1:33    Post subject: Reply with quote
Then if you add the following to Additional DNSMasq Options the following ...

Code:
conf-file=/jffs/dnsmasq.custom


.. you should see that directive (NOT the dhcp-host directives) in /tmp/dnsmasq.conf once dnsmasq is restarted. And DNSMasq should be using the static leases at that point.

Of course, you'll probably have to reboot both the router and affected clients to see the effects.

_________________
ddwrt-ovpn-split-basic.sh (UPDATED!) * ddwrt-ovpn-split-advanced.sh (UPDATED!) * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-remote-access.sh * ddwrt-ovpn-client-backup.sh * ddwrt-mount-usb-drives.sh * ddwrt-blacklist-domains.sh * ddwrt-wol-port-forward.sh * ddwrt-dns-monitor.sh (NEW!)
MysticGold04
DD-WRT User


Joined: 20 Apr 2018
Posts: 174
Location: Somewhere remote

PostPosted: Tue Mar 30, 2021 1:41    Post subject: Reply with quote
eibgrad wrote:
Then if you add the following to Additional DNSMasq Options the following ...

Code:
conf-file=/jffs/dnsmasq.custom


.. you should see that directive (NOT the dhcp-host directives) in /tmp/dnsmasq.conf once dnsmasq is restarted. And DNSMasq should be using the static leases at that point.

Of course, you'll probably have to reboot both the router and affected clients to see the effects.


Okay. Thats how I have it configured, but only had one client plugged in. I guess we'll see what happens when I add the other clients back in. Thanks for the help!!

Edit: just another thought. I also have other commands as well... would that make any difference?

No-resolv and preferred dns servers...

_________________
ASUS RT-AC3100 AP Merlin 386.12_4
ASUS RT-AC68U Media Bridge/Merlin 386.12_4 (x2)
ASUS RT-AC68U AP r54604
ASUS RT-AC68U Gateway/AP r54604
Edgerouter-4, v2.0.9-hotfix7
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9157

PostPosted: Tue Mar 30, 2021 2:08    Post subject: Reply with quote
The file pointed to by conf-file can contain any DNSMasq directives you want. In fact, you can have *multiple* conf-file directives pointing to other files as well.

Code:
conf-file=/jffs/dnsmasq.custom
conf-file=/jffs/dnsmasq.custom2
conf-file=/jffs/dnsmasq.custom3


Why anyone would do this for their own purposes, I have no idea. But sometimes you'll see this when other parts of the system decide they want to add their own customizations as well.

_________________
ddwrt-ovpn-split-basic.sh (UPDATED!) * ddwrt-ovpn-split-advanced.sh (UPDATED!) * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-remote-access.sh * ddwrt-ovpn-client-backup.sh * ddwrt-mount-usb-drives.sh * ddwrt-blacklist-domains.sh * ddwrt-wol-port-forward.sh * ddwrt-dns-monitor.sh (NEW!)
MysticGold04
DD-WRT User


Joined: 20 Apr 2018
Posts: 174
Location: Somewhere remote

PostPosted: Tue Mar 30, 2021 15:35    Post subject: Reply with quote
So let me ask this -

does the custom config replace /tmp/dnsmasq.conf? - should I copy the contents into the /jffs/dnsmasq.custom and then add my leases?

_________________
ASUS RT-AC3100 AP Merlin 386.12_4
ASUS RT-AC68U Media Bridge/Merlin 386.12_4 (x2)
ASUS RT-AC68U AP r54604
ASUS RT-AC68U Gateway/AP r54604
Edgerouter-4, v2.0.9-hotfix7
eibgrad
DD-WRT Guru


Joined: 18 Sep 2010
Posts: 9157

PostPosted: Tue Mar 30, 2021 17:25    Post subject: Reply with quote
MysticGold04 wrote:
does the custom config replace /tmp/dnsmasq.conf?


No.

By default, dnsmasq will use /etc/dnsmasq.conf for the configuration file. But you can override it w/ the -C/--conf-file argument on the command line, as dd-wrt does.

Code:
3047 root     dnsmasq -u root -g root -C /tmp/dnsmasq.conf


But dnsmasq also allows any config file to include references to other config files using the same option. That's what you're doing when you add your own conf-file directive to Additional DNSMasq Options.

IOW, you can nest configuration files as you see fit.

_________________
ddwrt-ovpn-split-basic.sh (UPDATED!) * ddwrt-ovpn-split-advanced.sh (UPDATED!) * ddwrt-ovpn-client-killswitch.sh * ddwrt-ovpn-client-watchdog.sh * ddwrt-ovpn-remote-access.sh * ddwrt-ovpn-client-backup.sh * ddwrt-mount-usb-drives.sh * ddwrt-blacklist-domains.sh * ddwrt-wol-port-forward.sh * ddwrt-dns-monitor.sh (NEW!)
MysticGold04
DD-WRT User


Joined: 20 Apr 2018
Posts: 174
Location: Somewhere remote

PostPosted: Thu Apr 01, 2021 15:44    Post subject: Reply with quote
Everything is working a-ok! Thanks for the help I really appreciate it.

Cheers!

_________________
ASUS RT-AC3100 AP Merlin 386.12_4
ASUS RT-AC68U Media Bridge/Merlin 386.12_4 (x2)
ASUS RT-AC68U AP r54604
ASUS RT-AC68U Gateway/AP r54604
Edgerouter-4, v2.0.9-hotfix7
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum Index -> General Questions 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 can attach files in this forum
You can download files in this forum