Author
Message
evan DD-WRT Novice Joined: 17 Jun 2012 Posts: 2
Posted: Sun Jun 17, 2012 7:17 Post subject: Adding internal host names to DNS or /etc/hosts [SOLVED]
I want to add some local host names for my local network.
I tried adding them to /etc/hosts in my DD-WRT, which works, but the changes are lost on restart.
Is there anyway to do more permanently?
Thanks Last edited by evan on Fri Jun 22, 2012 3:46; edited 1 time in total
Back to top
Sponsor
Luniz2k1 DD-WRT Guru Joined: 04 Oct 2007 Posts: 1258 Location: Ohio USA
Posted: Mon Jun 18, 2012 14:02 Post subject: Re: Adding internal host names to DNS or /etc/hosts
evan wrote: I want to add some local host names for my local network.
I tried adding them to /etc/hosts in my DD-WRT, which works, but the changes are lost on restart.
Is there anyway to do more permanently?
Thanks
Administration -> Commands, Command shell box put:
Code: echo '' > /etc/hosts
echo '127.0.0.1 localhost' >> /etc/hosts
echo '192.168.1.1 some.local.hostname' >> /etc/hosts
Then click Save Startup _________________(05/02/17) std - 31924
Linksys WRT400N
Buffalo WHR-G300N
Got OpenDNS?
Back to top
evan DD-WRT Novice Joined: 17 Jun 2012 Posts: 2
Posted: Fri Jun 22, 2012 3:45 Post subject:
Thanks, that almost did the job.
Didn't need the "echo '' > /etc/hosts" to clobber the initial file. Just wanted to append to it.
Also, need to add "restart_dns" after the echo commands to make it reload and the changes to take effect.
So my startup script looks like:
Code:
echo '192.168.1.1 some.local.hostname' >> /etc/hosts
echo '192.168.1.2 another.local.hostname' >> /etc/hosts
restart_dns
E.
Back to top
volitation DD-WRT User Joined: 30 Dec 2011 Posts: 91
Posted: Mon Jun 25, 2012 10:33 Post subject:
This can be done in dnsmasq also (Services > Additional DNSMasq Options ).
Code:
address=/some.local.hostname/192.168.1.1
address=/another.local.hostname/192.168.1.2
addn-hosts=/some/file/somewhere
Then create /some/file/somewhere and add the following
Code:
192.168.1.1 some.local.hostname
192.168.1.2 another.local.hostname
My addn-hosts file is saved on the USB stick. It should also be possible to put it on jffs if you don't have a USB port.
This way your local hostnames will resolve to their IPs, and those IPs will also reverse resolve into your local hostnames.
Note: addn-hosts is optional.
Back to top
rjt DD-WRT Novice Joined: 10 Aug 2006 Posts: 22 Location: Omaha
Posted: Sun Jul 29, 2012 20:19 Post subject:
Thank you, this worked for saving aliased dns names across reboots without an extra hosts file!
address=/uranos/uranos.my.ip.net./192.168.1.139
address=/mythtv/mythtv.my.ip.net./192.168.1.6
address=/firewall/firewall.my.ip.net/192.168.1.1
Back to top
stepram DD-WRT Novice Joined: 13 May 2019 Posts: 2
Back to top