# Hostnames and dhcp

## Martux

Hello!

I have two computers with Linux connected to the internet and to each other via a router.

The router assigns ip-adresses to the computers.

When I try to ssh from one to another pc via hostname it does not work.

If I type the actual ip-address it works (so does setting the ips in /etc/hosts with the hostname). How could I get it to work with hostnames, as the ip-adresses can easily change?

So far I tried setting this in /etc/conf.d/net of my gentoo box with no luck:

```

config_eth0="dhcp"

modules_eth0="dhcpcd"

dhcpcd_eth0="-h myhostname"

```

Any ideas on this?

----------

## John R. Graham

Yep.  Typical home router DHCP/DNS does not serve local names properly.  You have two choices:Create and maintain an /etc/hosts file on each of your machines with up-to-date local names and IP addresses.  This is a pain (as you've found out) and doesn't work on Windows machines.

Disable the baby router's broken DHCP/DNS service and set up a non-broken DHCP/DNS service on one of your computers.  I use dnsmasq for this with good results:  all Linux and Windows machines can access each other by name.- John

----------

## Martux

Hi!

Thanks for the hint!

It kinda works with the ip-adresses addet to /etc/hosts, as the router always seems to reuse the last ip-adress.

As I don't want to fiddle around too much, I will let it be that way. That is of course unless another machine is added  :Sad: 

Maybe then I will try to checkout  dnsmasq.

Thx,

Marcus

----------

## John R. Graham

Understood.  It's a good use of an old junk machine, when available.  You can actually use it to replace the crappy little router completely.  See the Gentoo Home Router Guide.

- John

----------

## Rexilion

Can't you just configure the router to use static ip's?

----------

## Mousee

 *Rexilion wrote:*   

> Can't you just configure the router to use static ip's?

 

Sadly a lot of "crappy" routers won't even let you do that these days  :Sad: 

A friend of mine wanted to do just that some time back - he had a Comcast-provided Linksys cable modem/router (don't recall the model) and it had the absolute minimum available routing options.

Quite sad really. I understand they (manufacturers) do it because many home users never access, much less are aware of, such features but they should at least offer an "advanced" option for those of us who require at least some, what I'll call, "basic" routing features.

----------

## John R. Graham

Yeah.  I've got a big, complicated AT&T Residential Gateway (aka crappy router) that I can't get rid of because U-Verse requires it.  It does not handle local DNS properly and has other limitations so the only two things I use it for is (a) the U-Verse box, and (b) the WAN uplink for my Gentoo-based router.  That works pretty well.

- John

----------

