Adding internal host names to DNS or /etc/hosts [SOLVED]

Post new topic   Reply to topic    DD-WRT Forum Forum Index -> General Questions
Author Message
evan
DD-WRT Novice


Joined: 17 Jun 2012
Posts: 2

PostPosted: Sun Jun 17, 2012 7:17    Post subject: Adding internal host names to DNS or /etc/hosts [SOLVED] Reply with quote
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
Sponsor
Luniz2k1
DD-WRT Guru


Joined: 04 Oct 2007
Posts: 1250
Location: Ohio USA

PostPosted: Mon Jun 18, 2012 14:02    Post subject: Re: Adding internal host names to DNS or /etc/hosts Reply with quote
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

_________________
(12/24/13) mega - 23204
4x WRT54G-TM

(12/24/13) std - 23204
1x WHR-G300N

(04/15/13) nokaid - 14929
1x WRT54GL v1.1

(07/24/13) micro - 22118
1x WG602v3

Got OpenDNS?
evan
DD-WRT Novice


Joined: 17 Jun 2012
Posts: 2

PostPosted: Fri Jun 22, 2012 3:45    Post subject: Reply with quote
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.
volitation
DD-WRT User


Joined: 30 Dec 2011
Posts: 91

PostPosted: Mon Jun 25, 2012 10:33    Post subject: Reply with quote
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.
rjt
DD-WRT Novice


Joined: 10 Aug 2006
Posts: 22
Location: Omaha

PostPosted: Sun Jul 29, 2012 20:19    Post subject: Reply with quote
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
Display posts from previous:    Page 1 of 1
Post new topic   Reply to topic    DD-WRT Forum 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