# Home server setup

## Sidein

I'm trying to set up a home server, but rather unsuccessfully. I don't know that much about servers so I am probably stumbling around blindly. I want to set my server up so any computer that connects to the network can be identified by its host name instead of a dynamic ip address. The server is also the gateway to the internet, and I have a wireless router that should support Dynamic DNS. I do not know what all I need to set up to make this work. I have been using iptables to try and get NAT working as a start, but to no avail. Any help is much appreciated.

----------

## thestick

google for gentoo wiki home server, you should find a lot of tutorials. cheers

----------

## Sidein

I found a tutorial a tutorial on how to set up a home router, but did not cover setting up your own dns server, only a forwarder, and I had no luck with the NAT configuration.

----------

## manaka

For setting up dynamic DNS you need an account with one service provider (www.dyndns.com, www.no-ip.com, ...). They usually provide free service for non-customized domains. If you want a personal domain (i.e. myreallyowndomain.net) you could contract an extended service.

----------

## szczerb

I think that he is more after a local DNS (try dnsmasq) then a dyndns service.

----------

## Sidein

Yes, it is only for computers located throughout my house. The tutorial I found stated that dnsmasq only forwarded dns requests. I want something that'll be able to register computers as they connect via dhcp so I can identify them via their name instead of looking up their ip address.

----------

## szczerb

That's exactly what dnsmasq can do.

Did you read that?

http://www.gentoo.org/doc/en/home-router-howto.xml

----------

## Sidein

I have had success in in getting NAT working. I am posting on a computer that gets the internet through my server. Now all I have left to is to figure out how to address my computers by name instead of ip. Currently, I still have to address my server as 192.168.0.1 from other computers. I wish for my router to report the ip address and names of computers that connect to my network. I believe this is done through dynamic dns.

----------

## szczerb

No. Dynamic DNS is:

http://en.wikipedia.org/wiki/Dynamic_DNS

You just need to setup a local dns server. You can work your ass off and do it with bind, or you can just let dnsmasq be the caching dns, local dns, and the dhcp server. You can also make it work with the DHCP daemon from ISC (it can read its lease files and add hosts to the dns) but that's more work.

----------

## Hu

For a single home network, you may be better off using DHCP reservations to ensure that a given system always receives a fixed address from DHCP.  You can then configure your DNS server with static name to address mappings, and not worry about them becoming stale.  This is also useful from the perspective that if you see a log message stating that two weeks ago, 192.168.0.6 was misbehaving, you do not need to comb DHCP logs to identify the offending system.

----------

## Sidein

Szczerb, dynamic DNS sounds exactly like what I want, having my router tell my server what computers are connected, their host names, and addresses in real time.

----------

## BitJam

You are fighting over semantics (the meaning of words).  The key thing is that the dnsmasq package does EXACTLY what you want regardless of what you want to call it.  Here is the pertinent section from the page szczerb linked to: *Quote:*   

> 5.  LAN Services (because we're nice people)
> 
> DHCP Server
> 
> I bet it'd be nice if everyone else in your house could just plug their computers into the network and things would just work. No need to remember mind-numbing details or make them stare at confusing configuration screens! Life would be grand eh? Introducing the Dynamic Host Configuration Protocol (DHCP) and why you should care. 
> ...

 

It's like you asked advice on how to build a mail-server and then when someone tells you how to do it you say "no no, I want gmail because gmail does exactly what I want".    Using a service someone else provides is very different from creating that service yourself.

----------

## szczerb

Again. dynDNS type services do just one thing. They give you a domain name. So your public IP address get's a domain name. And if you have a public IP that changes all the time that DNS server keeps track of that (actually your client just keeps telling him "hey, I'm here now"). That's it. Don't argue about that - read the wiki and understand.

----------

## depontius

Stop please.  As someone else has said, there are semantic wars here, over dynamic vs static vs reservations, and internal vs external.

Really, dnsmasq will do what you want.  In this particular case, it will do 2 things for you:

1: It will relay and cache dns requests for hostnames out on the internet at large.

2: It will act as a dns/dhcp server for systems on your home lan, and I believe it will assign fixed mapping, so each machine gets the same IP and hostname every time.

For what you want, it really will be simple one-stop shopping.

On my home LAN, I run BIND and ISC DHCP, but that's only because I wanted practice running the industrial-strength software.  (On flea-market hardware, no less)  But I also run dnsmasq on my client machines, because it's also capable of properly arbitrating multiple upstream DNS when you're running a VPN.

----------

## Sidein

The wiki link posted stated that Dynamic DNS is a method, protocol, etc. not a specific service like dyndns.org. BitJam, the section you quoted from is dhcp, not dns. I can just connect to the network and surf the web, but I am not able to connect to my network and address my tower by name, only ip. Dnsmasq is then not providing these services out of the box. Doing an nslookup on my tower from another computer return an address outside of my network, 8.15.228.169 to be specific. I shall look further into dnsmasq and why it is not working. Having a wireless router between my server and all other computers may be part of the problem.

----------

## BitJam

What part of: *Quote:*   

> We'll use a package called dnsmasq which provides both DHCP and DNS services

  do you not understand?

Now that you have gone to the great effort of emerging dnsmasq (note the "dns" in the name), by far the easiest way for you to get what you want is to read the simple documentation under /usr/share/doc/dnsmasq-2.45/html/ (assuming you emerged the current stable version).

On my system dnsmasq actually did start serving DNS "out of the box":

```
# emerge dnsmasq

...

# rc-update add dnsmasq default

...

# /etc/init.d/dnsmasq start

...

# netstat -autp | grep dnsmasq

tcp        0      0 *:domain  *:*    LISTEN 5040/dnsmasq

udp       0      0 *:domain  *:*                5040/dnsmasq
```

It does not get any easier than that.  If you want the machine running dnsmasq to take advantage of the dns caching it provides then add the following line to the top of /etc/resolv.conf.head:

```
nameserver 127.0.0.1
```

(assuming that machine is using dhcp to get its Internet connection, otherwise you can put that line in the top of resolv.conf directly).

I wish you the very best of luck.

----------

## Sidein

Let me rephrase this. I want to be able to address my computers, on my network, by their name. Computers on my network. No internet connection involved. Dnsmask is not doing this out of the box. I get the impression you think I want to address other servers via a domain name, and I can already do that, but that's not what I am asking about. I want 'MyComA' to register its ip with my server, so I may address it from 'MyComB' as 'MyComA' instead of '192.168.1.4'.

----------

## BitJam

Yes, we all know what you want.  That is trivial to do now that you have dnsmasq installed: */etc/dnsmasq.conf wrote:*   

> # Supply parameters for specified hosts using DHCP. There are lots
> 
> # of valid alternatives, so we will give examples of each. Note that
> 
> # IP addresses DO NOT have to be in the range given above, they just
> ...

 

Instructions for finding the MAC (hardware) address of your clients can be found here.  On gentoo you just have to run:

```
$ /sbin/ifconfig
```

One simple way to configure your system is that for each client, specify an IP address and a name given that client's MAC address.  To let everyone else know about the naming conventions, you *may* need to add the names and IP addresses to your /etc/hosts file.

----------

## Sidein

I'm not looking to reserve certain ip's for certain computers. I talked to a friend who game me this link http://wm161.net/2006/11/06/dhcp-and-dynamic-dns/. Correct me if I am wrong, but he does not appear to be reserving any ip addresses for his computers with the exception of his server, jupiter, for port forwarding.

----------

## BitJam

If you want to do it with BIND (as in the link) that's fine with me.  I've been trying to help you with an easy way to do it.  If you would prefer to have the clients send the server their hostnames instead of having the server assign them, dnsmasq can easily handle that (as you would have known if you had read the fine documention I pointed you to), although I suggest that you do assign a fixed IP address for each client (as per the "bert" example) because that will avoid potential headaches down the road.  I also think it is easier and more robust for the server to assign the names as I suggested before.

I've told you in extreme detail a very simple way of doing what you requested yet you seem determined to not follow the advice you requested.   If you think you have a better way to do it, please do it that way.  You could have had the whole thing up and running with 1/10th of the energy you've spent  needlessly arguing here.

----------

## tutaepaki

dnsmasq does this by default. Any DHCP leases it gives, are automatically added to it's DNS cache, using the the hostname the dhcp client presented.

----------

## Sidein

As far as I can tell BitJam, you are the only one arguing, especially given your sarcasm. What I see is a breakdown in communication. I should have also clarified the point that I have a wireless router that will eventually be providing dhcp services and as such, it will present some interesting problems. I did mention I had one in my initial post.

When you quoted for me

 *Quote:*   

> I bet it'd be nice if everyone else in your house could just plug their computers into the network and things would just work.

 

and

 *Quote:*   

> We'll use a package called dnsmasq which provides both DHCP and DNS services.

 

you were reffering to the DHCP section, and the first line referred to something I already working and something completely unrelated to dns. In the relevant DNS section, I interpreted 

 *Quote:*   

> It's a little DNS caching/forwarding server for local networks.

 

as saying that it would cache and forward name translations, like a watered down dns service. Nothing to suggest to me that it could do what I want.

 *Quote:*   

> On my system dnsmasq actually did start serving DNS "out of the box":

 

So did mine, but that's not why I asked for help.

The advice you have continued to give me appears to me like you are trying to solve a problem that is similar to mine, but not what what I am asking for specifically. I understand your frustration. I am aparently not communicating my problem correctly. I do appreciate your time on the subject, but I find your attitude a bit, agitating. I will continue to take a stab at this alone.

----------

## BitJam

I am sorry if I was rude.  I was very frustrated. Perhaps I better understand your problem now.  It sounds like your client machines are going to connect to the Internet via your wireless router which provides dynamic IP addresses that can change each time a machine connects.  

Part of my confusion (and perhaps others' as well) was that your subject was "Home Server Setup" and your original post said: *Quote:*   

>  I want to set my server up so any computer that connects to the network can be identified by its host name instead of a dynamic ip address. The server is also the gateway to the internet, and I have a wireless router that should support Dynamic DNS.

 

The part the caused the confusion was when you said "the server is also the gateway to the internet ..."  which made me think that your server would  be providing both dhcp and dns.  

I'm still not perfectly clear about your configuration.  Is your server in between your wireless router and the external Internet or is the router connected between the external Internet and your server?

But either way, I agree with you that you want some sort of dynamic DNS arrangement.  I'm no expert but AFAIK, this is much more difficult than the solution we were trying to foist on you.   Is it possible that your wireless router assigns "pseudo-static" IPs based on client MAC addresses?  If so then a cheap and easy kludge would be to rely on these "pseudo-static" IP addresses and then simply put the IP-address / name combos in your DNS server's /etc/hosts file.

But if you want/need to build your own DDNS server, the only solution I know of involves using BIND as per the article you linked to previously.  Maybe someone else has a better suggestion.   Below is the best info I could find.

Here is a PHP script that claims it does DDNS when combined with BIND.  It says it is fully compatible with the dyndns.org API so a variety of clients are available.  I would want to take a close look at the code to make sure it has no gaping security holes.  You have got to be VERY careful with security when you let clients update DNS.

This page and this page give instruction for setting up DDNS using BIND and nsupdate.   This is similar to the article you previously linked to.

Again, I'm sorry I was rude.  I hope we are close to being on the same page now.

----------

## jburns

You could also look at net-dns/avahi  See http://avahi.org/ and http://en.gentoo-wiki.com/wiki/Avahi

Edit added reference to wiki

----------

## Sidein

My network is as follows:

Internet -> Modem -> Server -> Wireless router -> Other computers

I did some hunting on my router this morning and managed to turn off it's dhcp service so my server is now providing both dns and dhcp. Sounds somewhat trivial, but I had a fun experience not being able to change a thing on my modem. Now my windows machine has been sitting at "Validating identity" for the last 2 hours, but it can get on the web. My linux machines connect just fine. I am starting to read the links you just posted. I do appriciate your help and I can understand your frustration.

----------

## Will Scarlet

I've experienced your last problem of Windows clients not able to get an address from the dhcp server and Linux clients work fine.  For me the solution is to reboot the wireless router, and then all clients (windows and linux) work as before.

Hope this helps...   :Wink: 

----------

## Sidein

Thanks, I'll try that tonight when I'm back home. It just makes me laugh a little that windows has such a hard connection given how 'easy' it is to connect to any network in windows.

----------

## ocbMaurice

Hi,

I kinda have a similar setup. I'm using BIND and DHCPCD for that.

If you map MAC to IP in your DHCP, you can also "hardcode" this info into your DNS Zone.

But if you go completely dynamic, the DHCP server has to inform your DNS server of assigned IPs and hostnames.

This can be also be done manualy via nsupdate.

Please note that the linked posts are quite old. But it should get you stated in that direction.

hth, Maurice

p.s. My wireless router is set to bridge mode, so it actually acts like a hub.

----------

