What's new
  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Static DHCP DNS without MAC Address Possible?

Debu

Occasional Visitor
Hi,

On tomato, I can go to the "Static DHCP/ARP/IPT" and assign an IP to a Hostname without a Mac Address.
Since I do a lot of VM testing, this is great because I can resolve DNS via Hostname and know the IP of the guest and not have to worry what mac gets assigned.

I can't seem to find a way to replicate that in the May 2017 update on Merlin for the RT-AC5300.

I notice that /etc is mounted on /tmp/etc
I saw that I can edit the hosts.dnsmasq and was like cool!
But it didn't survive the reboot. I don't know where the real file is residing.

I assume Merlin will just add the domain.
192.168.1.4 verizon

Where in tomato /tmp/etc/dnsmasq/hosts has the following stanza
192.168.1.4 verizon.home

Any help would be great so I can retire my Tomato router that is just serving DNS at the moment :(

Thanks
 
I started to think a little bit more here....If I have to use a mac, then how do you set a virtual IP?
 
OK, I tried to add /jffs2/configs/hosts.dnsmasq and it didn't copy over after a reboot :(
You need to use a /jffs/configs/hosts.add file.

You also need to enable custom configs.
Starting with 378.50, this functionality is disabled by default. To enable it, go to Administration -> System, then enable it under the JFFS section.
 
Yeah, but that is for the router itself to resolve hostname with ip.

Doesn't this have to go into the hosts.dnsmaq file in /tmp/etc ?


For example when I select LAN->DHCP Server -> Manually Assigned IP around the DHCP

I have a verizion network extender that has a mac on it. So I select it and it adds it to
hosts.dnsmasq

192.168.1.4 verizon

When I create /jffs/configs/hosts.dnsmasq.add with other ip and hostname it won't add it after a reboot.
 
Last edited:
I would create a dnsmasq.postconf script to manipulate your hosts.dnsmasq file whenever dnsmasq gets restarted.
 
I would create a dnsmasq.postconf script to manipulate your hosts.dnsmasq file whenever dnsmasq gets restarted.
I was actually thinking along the same lines. Maybe just have the script go and copy over the file that the firmware creates.

Also, is there a way to restart dns masq without rebooting the router?
 
Yeah, but that is for the router itself to resolve hostname with ip.
No. dnsmasq will use both /etc/ hosts and /etc /hosts.dnsmasq

You could add your entry to either of these.

Doesn't this have to go into the hosts.dnsmaq file in /tmp/etc ?


For example when I select LAN->DHCP Server -> Manually Assigned IP around the DHCP

I have a verizion network extender that has a mac on it. So I select it and it adds it to
hosts.dnsmasq

192.168.1.4 verizon
The "Manually Assigned IP" list populates the hosts.dnsmaq file.

When I create /jffs/configs/hosts.dnsmasq.add with other ip and hostname it won't add it after a reboot.
That's because that is not on the list of valid custom files, but hosts.add is.

Or you could write a script as RMerlin suggested.
 
Small update!

Thank you guys for helping me with the dnsmaq stuff. It is kind of a mystery to me how it all works.
I just need to really sit down and read more about it. So thank you again for helping me and pointing me in the right direction.

Got all my IP's in my hosts.add file and everything is resolving.
I also had to add a reverse DNS for an application on the network.
This was put as an add to dnsmasq.conf.add and works great.

It is nice now since I can add a VM, give it an IP and not have to write a MAC address.
Very happy.

I wanted to sort my hosts file so I thought I'd share my very simple script...I'm not a script guru by any means.

What is neat is that I can retire my old Netgear guy running tomato and lose that small hop.
I also now can have a guest network at home since DNS and DHCP resides in the Asus!
This is good when my kid has friends over.

VPN is working great, somehow feels a bit zippier. I have to do some more testing.

Also, are all the services that can be restarted listed?
I assume it is in a directory or something.


#!/bin/bash
sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 hosts.add > hosts.working
mv hosts.working hosts.add
 
Also, are all the services that can be restarted listed?
I assume it is in a directory or something.

There's no list, as this relies on internal commands for the rc super daemon. You have to look at the source code to see which parameters are allowed.
 
#!/bin/bash
The bash shell doesn't exist on the router unless you have added it through something like entware. Even then you shouldn't rely on it being present unless bash is providing something the default shell can't.

You should use the following instead:

#!/bin/sh
 
The bash shell doesn't exist on the router unless you have added it through something like entware. Even then you shouldn't rely on it being present unless bash is providing something the default shell can't.

You should use the following instead:

#!/bin/sh
Oooo! Thanks! I'll update the script. I've put it in the configs directory. That should stay on reboot right?
 
Oooo! Thanks! I'll update the script. I've put it in the configs directory. That should stay on reboot right?
Yes it does.
 
Hi All,

Here is a recap of what I did to get this to work the way I needed it to function.
NOTE: I use all the same domains. I just placed that in the field in the GUI under LAN->DHCP Server.

/jffs/configs/hosts.add
/jffs/configs/dnsmasq.conf.add
/jffs/configs/sort_ip.sh

hosts.add
Contains just IPs that I either need to have static or are place holders for VMs that I will bring up with a static IP. Also I a Server Pool File system that uses a Virtual IP and this seems to be the only way to just create an IP and hostname.
I have about 50 or so IPs in here, but here is a short example of a few.
Code:
192.168.1.3 cisco
192.168.1.4 verizon
192.168.1.5 basement

dnsmasq.conf.add
Contains IPs that dhcp will bind to specific Mac addresses. Useful where a device is using DHCP and you want to control it's IP from a central location
Code:
##Hardcoded Mac Address for Static DHCP##
##VM 1 ##
dhcp-host=00:11:22:33:44:55,192.168.1.148

sort_ip.sh
Used to just go and place the IPs in hosts.add in numerical order. It also restarts dnsmasq. I use this after I add an IP and hostname to hosts.add.
Code:
#!/bin/sh

sort -n -t . -k 1,1 -k 2,2 -k 3,3 -k 4,4 hosts.add > hosts.working
mv hosts.working hosts.add
service restart_dnsmasq

I'm not sure there is a better way to do this. But in the GUI with LAN->DHCP Server, when I use the pull down, it won't just let me add an IP and hostname. It makes me have to either place a mac address or pick a mac address. The problem is that sometimes I don't have a mac yet since it isn't generated at that moment. Also I need a few Virtual IPs for some applications.

I hope this helps others that are using this router in a lab environment. It isn't the ideal solution, but you work with what you have :)

Thanks again to everyone for the help.
 
Last edited:

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!

Staff online

Back
Top