4

I've got a raspberry pi running raspbian server edition. My problem is that the only way I can ssh into it with putty is through the static ip. My router doesn't recognize the hostname; it shows the mac address as the name. This causes the pi not to show my website online (I think). The only way I've gotten it to work is using my other linux server to forward using virtual hosts, and that has to use the ip address, too. However, now that I have my other server off, the website doesn't work and I can't ssh (or find it anywhere on the network) using the hostname.

  • How is the IP address for the RPi assigned? Is it manually set on the Pi or is it getting the IP via DHCP? Or something else? – Craig Jul 3 '13 at 16:08
  • Is the IPv4 address of the RPi set in /etc/network/interfaces with static or dhcp? If static, your router will never know the connection between the IPv4 address and hostname. If you set the IPv4 through dhcp, the RPi will send what name it wants when it askes for a IPv4 number. So your router will know the connection between IPv4 and hostname. If you want the same IPv4 address for your RPi, then config your router to set the IPv4 address to machines with the RPi MAC address. – Anders Jul 4 '13 at 20:23
3

For me, an update to the xbian-update package deleted most of the lines in my /etc/dhcp/dhclient.conf file. I am using XBian, which may differ slightly from base Raspbian.

I had to find an older version of that file and restore the content. Restoring that data (and rebooting my Pi) registered the hostname properly. My older version contained this data:

# Configuration file for /sbin/dhclient, which is included in Debian's
#   dhcp3-client package.
#
# This is a sample configuration file for dhclient. See dhclient.conf's
#   man page for more information about the syntax of this file
#   and a more comprehensive list of the parameters understood by
#   dhclient.
#
# Normally, if the DHCP server provides reasonable information and does
#   not leave anything out (like the domain name, for example), then
#   few changes must be made to this file, if any.
#

option rfc3442-classless-static-routes code 121 = array of unsigned integer 8;

#send host-name "andare.fugue.com";
send host-name = gethostname();
#send dhcp-client-identifier 1:0:a0:24:ab:fb:9c;
#send dhcp-lease-time 3600;
#supersede domain-name "fugue.com home.vix.com";
#prepend domain-name-servers 127.0.0.1;
request subnet-mask, broadcast-address, time-offset, routers,
    domain-name, domain-name-servers, domain-search, host-name,
    dhcp6.name-servers, dhcp6.domain-search,
    netbios-name-servers, netbios-scope, interface-mtu,
    rfc3442-classless-static-routes, ntp-servers;
#require subnet-mask, domain-name-servers;
#timeout 60;
#retry 60;
#select-timeout 5;
#initial-interval 2;
#media "-link0 -link1 -link2", "link0 link1";
#reject 192.33.137.209;

#alias {
#  interface "eth0";
#  fixed-address 192.5.5.213;
#  option subnet-mask 255.255.255.255;
#}

#lease {
#  interface "eth0";
#  fixed-address 192.33.137.200;
#  medium "link0 link1";
#  option host-name "andare.swiftmedia.com";
#  option subnet-mask 255.255.255.0;
#  option broadcast-address 192.33.137.255;
#  option routers 192.33.137.250;
#  option domain-name-servers 127.0.0.1;
#  renew 2 2000/1/12 00:00:01;
#  rebind 2 2000/1/12 00:00:01;
#  expire 2 2000/1/12 00:00:01;
#}
initial-interval 1;
reboot 4;
script "/etc/xbian-udhcpc/dhclient-script-xbian";

My newer version only had those last three lines. I noticed the data that the questioner posted had lines similar to my backup file, yet lacked the last three lines.

  • It happened again - an update overwrote this file. I have about 50 candidate packages, so I'll try to keep a closer watch whenever I update my system. (I have a feeling it's xbian-update, though.) – palswim Apr 12 '14 at 18:46
  • It happened again, but I still had a list of nine or so packages that may have overwritten the file. But, then I confirmed xbian-update causes the overwrite with apt-get install --reinstall xbian-update. – palswim Apr 25 '14 at 6:31
  • The XBian developers have now fixed this. – palswim Feb 18 '15 at 7:53
1

Check /etc/dhcp/dhclient.conf and make sure the line that begins with 'sendhostname' is not commented out.

  • pastebin.com/PNPdcBCb – xSpartanCx Jul 2 '13 at 17:04
  • Try changing the send host-name = gethostname(); line to the actual hostname you want - e.g. send host-name = "raspberrypi.local.net"; – Lawrence Jul 3 '13 at 1:16
  • Hang on. When you said 'static ip', do you mean the router has the reserved an IP address for the RasPi ? Or do you mean you have set a static IP on the Pi itself ? – Lawrence Jul 3 '13 at 1:20
1

I would suggest setting up a real DNS server at some point, as it will simplify DNS resolution. Then you just point your router to your internal DNS server as one of it's WAN DNS servers (make it the first one in the list)

You can try what Lawrence says, or if there is a way in your router to specify static DNS resolutions, as there is in DD-WRT you could try that.

0

Some routers only use the netbios hostname and this is published to all Windows machines.

On Debian you can

sudo apt-get install samba

and if your /etc/hostname is set correctly this will show up in the network without a restart.

This works for RaspberryPi, BeagleboneBlack and as far as I can remember also with Ubuntu.

ping should now work.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.