Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I installed a Linux (Ubuntu) server inside my home LAN, initially it's automatically configured to use DHCP interface. I'm connecting to this server from another computer using that server's hostname. All OK, my router is configured to use DHCP inside my home network and gives an IP automatically to each computer. But when I connect to this host using SSH, it warns me that I should accept a fingerprint from each newly assigned IP of the server, and it's a little annoying. So I configured it to use a static IP addressing editing the /etc/network/interfaces file like this:

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
auto eth0
iface eth0 inet static


All works well except that I can't connect to this server using it's hostname. When pinging I see that it's routed to the last assigned IP address that was given by DHCP dynamically, and of course Destination Host is Unreachable. I know that I can hardcode it in my /etc/hosts file, but I want to know -- why it works well with DHCP and it doesn't with static.

Apparently, I don't understand something. Thanks in advance!

share|improve this question
up vote 3 down vote accepted

You need to assign your router as your first dns server(s) in the interface configuration when using static ip. So If you are using ubuntu 12.04 you would add for example:


And then restart your networking:

/etc/init.d/networking restart

Check How do I configure my static DNS in interfaces? for more on DNS configuration.

share|improve this answer
Thanks for you reply! But problem is that the desktop machine is still DHCP, I set static IP on the server (not gateway just another LAN node, say web-server). – Dan K.K. Dec 11 '12 at 19:53

When you were using DHCP for the server, it was registering its hostname with your DNS server each time it obtained a new IP address. Now that your IP is static, it does not interact with the DHCP server, and so the DHCP server cannot pass the hostname to DNS.

You will need to do this directly. If your router (assuming that is your DNS server) supports it in its web gui, then you may be able to update the hosts file of the router with the server hostname.

If it doesn't but the DNS server on the router accepts updates from the local network (as opposed to just the DHCP server), then you can do this:

sudo apt-get install dnsutils
> update add hostname.domainame 86400 a
> send

The "domainname" is whatever your local DNS suffix is. The downside of this approach is that the router would lose the setting if rebooted, so you would want your server to send this update periodically via a script and cron.

If the DNS server doesn't accept local updates - which it probably won't then your best bet, and the better long term solution, would be to run DNS from your server rather than from the router.

bind is the most commonly used DNS server for linux, though there are lighter weight alternatives.

Perhaps a simpler alternative would be to revert the server to using DHCP, but configure the router to allocate the same IP address each time. Many routers support this functionality, and means the hostname should go back to being registered each time.

share|improve this answer
Thank you @Paul! I've discovered my router configs, and found manual IP reservation, and it works :) – Dan K.K. Dec 11 '12 at 21:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .