Page 1 of 2

Setting up a host name for development server on LAN

Posted: Sat Feb 24, 2007 2:15 pm
by Ollie Saunders
I've now running a development server on my company LAN and I'm using Samba to set a netbios name so that any windows PC can get access to the server simply by typing "dev" in the address bar :). Problem is this doesn't work for Macs. I don't particularly want to set things in the /etc/hosts file. What do I need to do? I tried running DHCP server with some success but I couldn't find a way to do this and concluded that it wasn't really the correct thing to use.

By now I'm probably showing my ignorance in this area and I would like to brush up. Can anyone recommend a book that explains how common networking protocols work? Something that summarises and gives examples and won't bore me senseless.

Posted: Sat Feb 24, 2007 3:31 pm
by nickvd
There may be something "mac'ish" that will work, but running your own internal dns system will definitely work, though it will take much more to properly setup.

Is there a reason you wanted to avoid using /etc/hosts? (this is it's intended purpose)

Posted: Sat Feb 24, 2007 4:35 pm
by Chris Corbyn
Run your own DNS. I recommend powerdns (pdns), but any recursing DNS server will work well.

Posted: Sat Feb 24, 2007 4:39 pm
by Ollie Saunders
Can you recommend any good tutorials / books for configuring that?

Posted: Sat Feb 24, 2007 5:48 pm
by Chris Corbyn
If you're going to set up pnds, it's easy. Install pdns from whatever package manager you have. On a debian system, that would be:

Code: Select all

apt-get install pdns-server
Once you hgave it install, open up /etc/powerdns/pdns.conf and set (at least) the following:

Code: Select all

allow_recursion (set this to your own network)
launch=bind
bind_config=/etc/named.conf

lazy_recursion=yes

recursor=<your ISPS nameservers>
Now, you're using BIND as the backend, which basically mean zone files. So create a named.conf at /etc/named.conf (mine looks like this, but it's basic named config if you want to look it up):

Code: Select all

options {
        recursion yes;
        notify yes;
        directory "/var/named";
};

zone "." IN {
        type hint;
        file "named.ca";
};

zone "localhost" IN {
        type master;
        file "localhost.zone";
        allow-update { none; };
};

zone "w3style.co.uk" IN {
        type master;
        file "w3style.zone";
        allow-update { none; };
};

zone "w3style.org" IN {
        type master;
        file "w3style.org.zone";
        allow-update { none; };
};

zone "andrewrose.co.uk" IN {
        type master;
        file "andrewrose.zone";
        allow-update { none; };
};

zone "swiftmailer.org" IN {
        type master;
        file "swiftmailer.zone";
        allow-update { none; };
        allow-transfer { any; };
};

zone "marshies21st.com" IN {
        type master;
        file "marshies21st.zone";
        allow-update { none; };
        allow-transfer { any; };
};

zone "chriscorbyn.co.uk" IN {
        type master;
        file "chriscorbyn.zone";
        allow-update { none; };
};

zone "markymarky.co.uk" IN {
        type master;
        file "markymarky.zone";
        allow-update { none; };
};

zone "markcorbyn.com" IN {
        type master;
        file "markcorbyn.zone";
        allow-update { none; };
};

zone "117.94.147.217.in-addr.arpa" IN {
        type master;
        file "117.94.147.217.in-addr.arpa";
        allow-update { none; };
};
Then create the relevant zone files in /var/named/*.zone. If your DNS server finds a relvent zone it will answer, otherwsie, it will ask your ISPs nameservers.

Posted: Sat Feb 24, 2007 7:28 pm
by RobertGonzalez
Hey d, can you post a copy of a zone file for any one of the hosted domains you list here? I may have found the problem I was having (that was similar to this one) and seeing a zone file in use might help me patch this thing up finally.

Posted: Sun Feb 25, 2007 12:13 am
by Kieran Huggins
If you're behind a NAT router with decent firmware (like a WRT54GL) it might let you add your own custom DNS entries to return instead of forwarding the request to the ISP's DNS servers.

That way it would work for everyone inside the network, not just your machine.

Posted: Sun Feb 25, 2007 3:30 am
by Ollie Saunders
Hey d, can you post a copy of a zone file for any one of the hosted domains you list here?
Yes. Please.
f you're behind a NAT router with decent firmware (like a WRT54GL) it might let you add your own custom DNS entries to return instead of forwarding the request to the ISP's DNS servers.
Yeah I checked that. Our router is an old netgear that seems pretty crappy. It has crashed on me on a couple of occasions.
That way it would work for everyone inside the network, not just your machine.
That's the whole point of doing this for me. If you run your own DHCP as well and turn off the one on the router you can point it to the DNS on the dev server. Is that right?

Posted: Sun Feb 25, 2007 4:51 am
by Chris Corbyn

Code: Select all

$TTL   3600
@               IN      SOA     ns1.w3style.co.uk.     admin.w3style.co.uk. (
                        2005121907      ; serial
                        28800           ; refresh
                        7200            ; retry
                        604800          ; expire
                        86400           ; default_ttl
                        )
@               IN      MX      5       mail
@               IN      NS      ns1.w3style.co.uk.
@               IN      NS      ns2.w3style.co.uk.
@               IN      A       217.147.94.70


;Yes yes I know but it helps ATM
localhost               IN      A       127.0.0.1

;Servers etc
www             IN      A       217.147.94.70
mail            IN      A       217.147.94.70
ftp             IN      CNAME   www
smtp            IN      A       217.147.94.117
Make sure you use tabs, not spaces!

EDIT | Just to keep anyone quiet about the lone MX record. I don't use that domain for email... it's the swiftmailer domain and I test with it.

Posted: Sun Feb 25, 2007 5:08 am
by Ollie Saunders
OK and now I need someone to run through what all that means :D
Thanks for all the help so far d.

Posted: Sun Feb 25, 2007 5:32 am
by Chris Corbyn

Code: Select all

$TTL   3600
@               IN      MX      5       mail
@               IN      NS      ns1.w3style.co.uk.
@               IN      NS      ns2.w3style.co.uk.
@               IN      A       217.147.94.70


;Yes yes I know but it helps ATM
localhost               IN      A       127.0.0.1

;Servers etc
www             IN      A       217.147.94.70
mail            IN      A       217.147.94.70
ftp             IN      CNAME   www
smtp            IN      A       217.147.94.117

Code: Select all

$TTL   3600
Other machines will cache your server's response. TTL is time-to-leave and tells remote machines how long to hold cached data for. It's 1 hour here. Some people have this at 1 day or whatever. Don't set it too low if you're runnng DNS for a busy site as you will want to keep the number of reuests as low as you can.

Code: Select all

@               IN      SOA     ns1.w3style.co.uk.     admin.w3style.co.uk. (
                        2005121907      ; serial
                        28800           ; refresh
                        7200            ; retry
                        604800          ; expire
                        86400           ; default_ttl
                        )
Note, in zone files, if you want to give a domain name you need to add a dot at the end. If I want to put http://www.google.com in a zone file I need to write it "www.google.com.". The reason for that is that without the dot, it assumes that you're referring to a subdomain - so if the zone file is for swiftmailer.org it would look for http://www.google.com.swiftmailer.org without that trailing dot.

The @ sign means that the line which follows applies to the base domain (so here, in named.conf it was defined as swiftmailer.org, so the @ basically means "swiftmailer.org"). IN is the keyword you use to specify which type of record you're defined (i.e. IN A, IN CNAME, IN MX...).

SOA is start-of-authority. It's basically the machine that hold the authoritive information for the domain (the primary NS). You don't need to put the IP address, and you shouldn't really. The domain name is the thing you should put.

2005121907 ; serial

That's a serial number. It's not crucial. It's basically YYYYMMDDXX where YYYYMMDD is the date of the last update you made to the zone file, and XX is the number of the update you made that day. Obviously I was busy this day! It was my 7th update.

28800 ; refresh

This is like the TTL, except it's only honoured by slave DNS servers.

7200 ; retry

In the event of a problem, retry in 7200 seconds.

604800 ; expire

This is for cahed data and slave DNS servers. Basically, TTL and refresh specify the time durations to get new information from the zone file. But this value here is in the vent that your server has been offline for a long time and the slave DNS server have been unable to refresh their data. They will continue to give out their copy of the data until this time is reached.

86400 ; default_ttl

I actually can't remember what that's there for when TTL is at the top.... it's probably for the slave servers to take note of :?

Code: Select all

@               IN      MX      5       mail 
@               IN      NS      ns1.w3style.co.uk. 
@               IN      NS      ns2.w3style.co.uk. 
@               IN      A       217.147.94.70
These are where my DNS records start. the @ means they apply to swiftmailer.org and NOT http://www.swiftmailer.org or anything else. Notice that some have a dot after them, and some don't? The ones that don't end with a dot are expanded to XXXX.swiftmailer.org. IP addresses needn't end with a trailing dot.

Code: Select all

;Yes yes I know but it helps ATM 
localhost               IN      A       127.0.0.1
Ignore this, I'm an idiot, I forgot I left that in there.

Code: Select all

;Servers etc 
www             IN      A       217.147.94.70 
mail            IN      A       217.147.94.70 
ftp             IN      CNAME   www 
smtp            IN      A       217.147.94.117
DNS records for subdomains of swiftmailer.org:

http://www.swiftmailer.org, mail.swiftmailer.org, ftp.swiftmailer.org etc etc. It should make sense, it's in the same format as those lines starting with @ except we're using subdomains, not the base domain.

Posted: Sun Feb 25, 2007 5:34 am
by Chris Corbyn
FYI, don't try writing a zone file from memory... only madmen would do such things :P Take one zone file and use it as a template. Whenever I set up a new domain I just copy and exisitng zone file then open it and adjust all the records in it.

Posted: Sun Feb 25, 2007 5:41 am
by Ollie Saunders
Whoa thanks d!
I'll read through all this again on Monday and try and get it all to sink in.

Posted: Sun Feb 25, 2007 8:15 am
by RobertGonzalez
Awesome. I think I know what went wrong for me.

If I could ask, does changing the default host name have any significant on the DNS? Say I wanted to change the host name on my server from fc31655.aspadmin.net to something prettier, like d11wtqrocksthehizzie.everah.com, could I do that without breaking everything on the machine? Or should I leave it as is?

Thanks again d11. I think you should write a tutorial. Your explanation, though similar to others on the web, made a lot more sense and was much easier to follow.

Posted: Sun Feb 25, 2007 8:59 am
by Chris Corbyn
If you mean the host name in the environment variable $HOSTNAME, no it won't matter. That's just for your machine.

It took me a while to get my head around it all when I was starting out. I was using spaces rather than tabs which actually caused problems when parsing my zone files initially :oops:

Having a tool like "dig" installed is a godsend when playing around with DNS stuff.