# DNS resolve for hostnames in a network

## 1veedo

I have names for my computers but whenever I ssh I always have to use the full IP address.  If I try to run say

```
ssh tux
```

I get an error, 

```
ssh: Could not resolve hostname tux: Name or service not known
```

I know of a couple solutions to this and they mostly involve static IP addresses and modifying your hosts file which would be great if I was always on the same network but I don't want to have to set up different host files for every network I join, I just want it to be dynamic. 

Usually routers have dns servers so I tried adding my router to /etc/resolv.conf but it didn't seem to do anything.  Is there like a refresh you have to do when you modify that file (init 2 / init 5?) or am I simply doing it wrong?

----------

## NeddySeagoon

1veedo,

You need the sendhost option in your /etc/conf.d/net file for dhcp.

For baselayout2/openrc  the net.example flle says 

```
# GENERIC DHCP OPTIONS

# Set generic DHCP options like so

#dhcp_eth0="release nodns nontp nonis nogateway nosendhost"

# This tells the dhcp client to release its lease when it stops, not to

# overwrite dns, ntp and nis settings, not to set a default route and not to

# send the current hostname to the dhcp server and when it starts.

# You can use any combination of the above options - the default is not to

# use any of them.
```

The baselayout1 syntax is slightly different.  This allows the dhcp server to associate the host name with the IP address it just gave you.

----------

## 1veedo

So I need something like 

```
dhcp_eth0="sendhost"
```

?

----------

## NeddySeagoon

1veedo,

Try it.  I can't test as my home network is all static and I use /etc/hosts

----------

## floppymaster

This will only work if your router's dhcp server is actually configured to update the dns server. I have never used an off-the-shelf router, so I'm not certain this is enabled by default on most models.

In my network, I have a Linux box (Ubuntu LTS) doing my routing, dns, and dhcp. I had to configure dhcpd to send dns updates, and bind to receive them.

----------

## magic919

I run dnsmasq on my networks to allow this kind of thing.  It provides the much needed link between DHCP and DNS functions.

----------

## platojones

 *magic919 wrote:*   

> I run dnsmasq on my networks to allow this kind of thing.  It provides the much needed link between DHCP and DNS functions.

 

Thank you!  I was looking for exactly that application for the past couple of weeks.  I didn't want a full scale BIND install for my simple home network and personal VPN for my android phone.  I hate typing in IP addresses from on my phone though.  Solved my problem in 5 minutes.  Awesome application.  I just installed it, with no configuration and it works perfectly.

----------

