# domain name and host name

## hvedam

host name is recognizing what's your name on the network right...i'm pretty sure of that.  I don't understand what's the purpose of domainname.. can someone explain that to me? it will be great,  i'm just really confused at this part of manual is it neccessary to have domainname?

----------

## John R. Graham

You're right about the definition of "host name": a unique name for your computer so that other computers can refer to it by name.  You can just use the default from the handbook for the domain name.  Not too simplistically, the domain name gives your local area network as a whole a unique name.  Its value only becomes important when you're trying to let computers outside your organization (house, dorm room, etc.) have access to the computers inside your organization.  If you need information beyond this, please reply.

- John

----------

## hvedam

next the step, the host file is indicating what other computers are the network right? by there ipaddress?

----------

## John R. Graham

That's right.  I believe the file you're referring to is /etc/hosts.  If you have 3 computers on your LAN, you can out the IP addresses of the other two in your /etc/hosts.  Here's one of my /etc/hosts files for reference:

```
127.0.0.1           localhost

192.168.123.250     ceres

192.168.123.90      wap-downstairs

192.168.123.92      wap-upstairs

192.168.123.101     venus

192.168.123.165     algonquin

192.168.123.170     mercury

192.168.123.157     mars

192.168.123.190     sal2000

```

(Yes, I have a lot of computers   :Very Happy:  ).  When you edit the default /etc/hosts file, you'll see one funny IP address associated with the computer name localhost.  Leave that one alone as it referrs to the local computer.  127.0.0.1 is a special IP address that means "myself".

Best of luck with your install.

- John

----------

## hvedam

yeah you do...I specified my computer by 192.168.1.103 because that what routers gives as ip address,  why would be neccessary/useful to specify this 127.0.0.1 ip address for my computer in the host file? my comp is known as genma. would I specify it 127.0.0.1 genma or 192.168.1.103 genma?

----------

## John R. Graham

The purpose of the /etc/hosts file is to help your computer find other computers by name.  In the /etc/hosts file on "genma", you don't really need a line that says "genma" or even the IP address of "genma".  So, to illustrate, if you have just the one computer, your /etc/hosts file needs only this line:

```
127.0.0.1      localhost
```

Your computername, "genma" goes in /etc/conf.d/hostname, like so:

```
# /etc/conf.d/hostname

# Set to the hostname of this machine

HOSTNAME="genma"
```

Here's an example of what /etc/hosts should look like if you have a additional computer other than genma (let's call it "fred" and give it IP address 192.168.1.104 just as an example), then that computer would get an entry in /etc/hosts for "genma" and the /etc/hosts file on "genma" would get an entry for "fred".

So, the /etc/hosts on "genma" would be:

```
127.0.0.1      localhost

192.168.1.104  fred
```

And, the /etc/hosts on "fred" would be:

```
127.0.0.1      localhost

192.168.1.103  genma
```

Again, you don't need to look up yourself, so the 127.0.0.1 IP address (called the "loopback" address), which means "yourself" implicitly, is the right way to go: it's more efficient, too.  Note that these simple guidelines change if you're setting up a larger network (and you have a lot more to set up).  However, they're just fine for setting up a single computer or a very small network of computers.

- John

----------

## John R. Graham

Oh, yes, one more thing.  Most modern home routers are configured with a web browser.  Anyway, they have an IP address.  If you want to refer to the router by name, say "myrouter", add this line to your /etc/hosts file (with the IP address of your router substituted for the one I give):

```
192.168.1.254  myrouter
```

In your web browser, you can then just put in the router's name as the address.

- John

----------

## WhimpyPeon

hvedam:

I hate to confuse your issue even more, but you should probably understand how your addresses are given out.  You see, your router is acting as a dhcp server and assigning addresses to your computers.  The router is probably set up with a range of addresses that it "hands out on request".  As you stated you were given an address of 192.168.1.103.  Based on that I am assuming that your router is using a range 192.168.1.100 - (something like) 192.168.1.200.

Depending on how your router handles leases you may not always get the same address.  A prime example would be if you went on an extended vacation and turned off all of your computers.  When you come back and start turning them back on you may get different addresses for your computers.

I would consider giving your computers a "static" address (assigned by you).  If you look at your router's configuration you can see what range they are using for it's dynamic address pool.  Then you can just use an address outside of the range (be sure to note things like dns server...).  For instance you might want to give your computers addresses like 192.168.1.10 if that is outside of the dynamic address pool.

A lot of your "home based" routers use themselves for network functions like dns and default gateway.  So for your setup you would set the following:

default gateway: 192.168.1.1

dns server: 192.168.1.1

Network Mask: 255.255.255.0

You might want to read through the relevant section of the Gentoo Handbook.

With static addresses you will never confuse /etc/hosts.

Good Luck!

----------

