change DNS name on raspbian (debian)

1

0

I just installed raspbian on my raspberry pi, and was wondering why I can't use it's hostname from other machines.

on my router, I can see which computers are connected by their name, for example a windows pc, a mac, my iphone, etc... all have names. But for my Pi, I see only the ip adress.

on the pi, I have set hostname correctly, like this:

pi@pi ~ $ sysctl kernel.hostname
kernel.hostname = pi

hostname also delivers:

pi@pi ~ $ hostname
pi

but hostname -d won't deliver anything:

pi@pi ~ $ hostname -d 
pi@pi ~ $ 

why is this? why can't I run ping pi on any other machine and get to the pi?

thanks

otmezger

Posted 2013-02-24T12:06:09.993

Reputation: 211

hostname -d is unreliable; RTFM. I think you need to provide more information about your router, and /etc/host*s, and /etc/resolv.confs of the hosts, for a useful answer. ping resolves names according to DNS: if the host pinged from can't resolve it, it asks the next DNS server; on WLAN routers that is usually coupled with a DHCP server. I think the DNS server can't know about the hostname if the target host doesn't tell it implicitly when requesting an IP address via a DHCP vendor extension. This question is probably too localized. – PointedEars – 2013-02-24T14:02:35.657

Thanks @PointedEars for your comment. I have a fritz.box router. As I said, all other machines tell the DHCP server on the router their name... but the pi doesn't. resolv.conf shows the following line: nameserver 192.168.178.1 which is the router's ip. I edited hosts with the line 127.0.0.1 pi... should I put here the real ip? what if it changes? i`m using dhcp on the pi. – otmezger – 2013-02-24T15:41:30.303

As your router is the primary DNS server for your clients, it is as I said. You need to configure your Raspian to tell the router on DHCP handshake what the client's hostname is. A change in your DHCP client configuration in /etc/dhcp* to use the vendor extension is more likely to help than the FQDN in the hosts file. With dhclient 4.x, there should be a line like send host-name = gethostname(); in your /etc/dhcp/dhclient.conf. – PointedEars – 2013-02-26T20:58:15.623

Answers

0

Put into /etc/dhcp/dhclient.conf:

send host-name "yourhostname"

and remove "host-name" from the "request" statement.

Sz.

Posted 2013-02-24T12:06:09.993

Reputation: 145

I already did that... but still doesn't work :-( – otmezger – 2013-02-25T08:57:36.340

Hmm, sorry to hear. After due restarts (of the router, too), I suppose. – Sz. – 2013-02-26T19:26:20.183

I see no reason to remove the host-name request option; DNS resolution works fine with that option here (Debian 7.0 with dhclient 4.2.4 connected to a Linksys WRT54GL). In any event, the logfiles should tell what happened, and dhclient -v or service networking restart on the client(s) should suffice. – PointedEars – 2013-02-26T21:05:31.853