# bind hostname to ip address

## mlybarger

my hostname is set

 *Quote:*   

> 
> 
> mark@lightning ~/Downloads $ cat /etc/conf.d/hostname 
> 
> # Set to the hostname of this machine
> ...

 

but i can't ping that hostname:

 *Quote:*   

> 
> 
> mark@lightning ~/Downloads $ ping lightning
> 
> ping: unknown host lightning
> ...

 

my ip address is obtained from dhcp from my wifi router, so it can change. id' rather not put something into /etc/hosts to hack it to work temporarially.  how do i get this hostname recognized?

----------

## eccerr0r

This is completely dependent on your router's DHCP/DNS caching server... The most that your Linux box can do is make sure that your DHCP client sends out a name along with the DHCP request, and if the router DHCP/DNS server doesn't honor it, you're SOL and need to find another solution.

----------

## UberLord

If you want it to work just on the local host, edit /etc/hosts and add it to the 127.0.0.1 line.

----------

## szatox

Yeah, export to DNS, a line in /etc/hosts, and finaly avahi (distributed, multicast DNS). 3 ways to get it done, which one is good for you depends completly on your setup

----------

## mlybarger

thanks for the insights. i ended up going with a "static" ip address from the router (dhcp server) and putting it into /etc/hosts.

----------

