Page 1 of 1

Hostname instead of IP

Posted: Sat Apr 06, 2013 12:46 pm
by ATARI
Hi Everyone

I was wondering if following is possible:

I have installed an Apache2 server, MySQL, PHPmyAdmin and vsftp(i think its called)

I can connect to the FTP, PHP and mySQl using the IP address, I see the default index page of the Apache server when using the IP address in the Browser.
If I try the same with the newly set hostname instead of IP, it fails. My router does see the Raspberry and displays its name and IP correctly.

is it possible to get this to work?
im trying to make the FTP server accessible from the world. its not really necessary via hostname since my router will do the Dynamic DNS part and will Portforward to the raspberry... (or I hope at least that this will work. fairly new to this networking)

Great full for any input!
-Atari

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 1:11 pm
by azeam
ATARI wrote:If I try the same with the newly set hostname instead of IP, it fails.
How did you set up the hostname? Can you paste the output of

Code: Select all

cat /etc/hosts
And

Code: Select all

cat /etc/hostname

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 1:13 pm
by ATARI
Hi!

the Output reads following

Code: Select all

127.0.0.1       localhost
::1             localhost ip6-localhost ip6-loopback
fe00::0         ip6-localnet
ff00::0         ip6-mcastprefix
ff02::1         ip6-allnodes
ff02::2         ip6-allrouters

127.0.1.1       ethftp
and

Code: Select all

ethftp
thanks for the fast reply

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 1:25 pm
by azeam
Are you using IPv6 or why are those lines uncommented (normally they are commented out)? Did you reboot (restarting the network should be enough) after you made the changes? Was it working before you changed it?

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 1:40 pm
by ATARI
I am not really sure why its set to IPv6, its not by my choice so I could change it to IPv4 if you can tell me how that works.

yes the network and the PI was restarted

no it never worked with hostname, although I haven't tried it with the default name

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 1:54 pm
by azeam
ATARI wrote:I am not really sure why its set to IPv6, its not by my choice so I could change it to IPv4 if you can tell me how that works.

yes the network and the PI was restarted

no it never worked with hostname, although I haven't tried it with the default name
Maybe the default settings have been changed (on my RPi they are commented out), don't think that's the issue here anyway.

Just to make sure - is the device you are trying to connect from connected to the same local network as the RPi?

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 2:02 pm
by ATARI
they are.

my PC's IP is 192.168.0.199

and the Pi's is 192.168.0.198

I really dont know what wrong

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 2:13 pm
by azeam
ATARI wrote:they are.

my PC's IP is 192.168.0.199

and the Pi's is 192.168.0.198

I really dont know what wrong
What OS is the PC running? Can you try this command (works on Linux, I think Windows and Mac I don't know)

Code: Select all

arp -a

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 2:15 pm
by ATARI
this is the output on said command

Code: Select all

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Kim9>arp -a

Interface: 192.168.0.199 --- 0xb
  Internet Address      Physical Address      Type
  192.168.0.1           00-18-e7-ce-43-98     dynamic
  192.168.0.197         00-1f-c6-1b-ee-ac     dynamic
  192.168.0.255         ff-ff-ff-ff-ff-ff     static
  224.0.0.22            01-00-5e-00-00-16     static
  224.0.0.251           01-00-5e-00-00-fb     static
  224.0.0.252           01-00-5e-00-00-fc     static
  239.255.255.250       01-00-5e-7f-ff-fa     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static

Interface: 25.125.210.207 --- 0x11
  Internet Address      Physical Address      Type
  25.0.0.1              7a-79-19-00-00-01     dynamic
  25.45.17.222          7a-79-19-2d-11-de     dynamic
  25.129.7.57           7a-79-19-81-07-39     dynamic
  25.255.255.255        ff-ff-ff-ff-ff-ff     static
  224.0.0.22            01-00-5e-00-00-16     static
  224.0.0.251           01-00-5e-00-00-fb     static
  224.0.0.252           01-00-5e-00-00-fc     static
  239.255.255.250       01-00-5e-7f-ff-fa     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static

C:\Users\Kim9>

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 2:50 pm
by klricks
I think you have to install winbind. I haven't tried it myself
see this:
http://www.raspberrypi.org/phpBB3/viewt ... 66&t=25693

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 2:52 pm
by PeterO
How are you expecting the PC to resolve the hostname of the PI into its IP address ?
PeteO

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 2:53 pm
by azeam
ATARI wrote:this is the output on said command

Code: Select all

Microsoft Windows [Version 6.1.7600]
Copyright (c) 2009 Microsoft Corporation.  All rights reserved.

C:\Users\Kim9>arp -a

Interface: 192.168.0.199 --- 0xb
  Internet Address      Physical Address      Type
  192.168.0.1           00-18-e7-ce-43-98     dynamic
  192.168.0.197         00-1f-c6-1b-ee-ac     dynamic
  192.168.0.255         ff-ff-ff-ff-ff-ff     static
  224.0.0.22            01-00-5e-00-00-16     static
  224.0.0.251           01-00-5e-00-00-fb     static
  224.0.0.252           01-00-5e-00-00-fc     static
  239.255.255.250       01-00-5e-7f-ff-fa     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static

Interface: 25.125.210.207 --- 0x11
  Internet Address      Physical Address      Type
  25.0.0.1              7a-79-19-00-00-01     dynamic
  25.45.17.222          7a-79-19-2d-11-de     dynamic
  25.129.7.57           7a-79-19-81-07-39     dynamic
  25.255.255.255        ff-ff-ff-ff-ff-ff     static
  224.0.0.22            01-00-5e-00-00-16     static
  224.0.0.251           01-00-5e-00-00-fb     static
  224.0.0.252           01-00-5e-00-00-fc     static
  239.255.255.250       01-00-5e-7f-ff-fa     static
  255.255.255.255       ff-ff-ff-ff-ff-ff     static

C:\Users\Kim9>
Winbind shouldn't be necessary for this.

"arp -a" works differently on Windows then apparently. What you could do as a workaround is add the hostname manually to the host file on the Windows computer:

Code: Select all

192.168.0.198 ethftp

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 3:11 pm
by PeterO
arp is not the problem here.....

arp translates ip addresses into MAC addresses. The problem here (as far as I read it) is a lack of a mechanism to preform host name to IP address translation.

PeterO

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 3:17 pm
by azeam
PeterO wrote:arp is not the problem here.....

arp translates ip addresses into MAC addresses. The problem here (as far as I read it) is a lack of a mechanism to preform host name to IP address translation.

PeterO
I know that it's not the problem, "arp -a" also shows the hostnames of the devices on the local network (on Linux), I just wanted to see if it was able to resolve it. I guess there's some DNS problem, but I don't really know how to investigate that further. Setting the RPi's host on the PC client will work though.

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 3:20 pm
by ATARI
Yes well this doesnt work either.

Im starting to think my router is the problem, because if I set my Router to lookup the Dyndns entry it allways says: connected.

if I ftp to the Dyndns domain e.g. [email protected] it resolvers the external IP of the router correctly but then does not let me access the PI for witch I port forwarded correctly (on port 21 to the internal IP of the RPI)

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 3:27 pm
by azeam
ATARI wrote:Yes well this doesnt work either.

Im starting to think my router is the problem, because if I set my Router to lookup the Dyndns entry it allways says: connected.

if I ftp to the Dyndns domain e.g. [email protected] it resolvers the external IP of the router correctly but then does not let me access the PI for witch I port forwarded correctly (on port 21 to the internal IP of the RPI)
Many routers don't allow loopback connections, so if you are connecting from the same local network through dyndns to the server it might not be possible. You could try an online port checker to see if the port is open. This is probably a different issue anyway.

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 3:29 pm
by ATARI
PeterO wrote:How are you expecting the PC to resolve the hostname of the PI into its IP address ?
PeteO
Well to be honest I though my router would resolve this since all is connected to it.
This is probably a different issue anyway.
yep I guess so too, even online port check tools say all the port are closed.

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 3:43 pm
by trouch
your pi make a DHCP request including its hostname.
but unfortunately, all routers does not link their embedded DNS server with the embedded DHCP server.
this is because for many routers, the DNS server is only a forwarder to your ISP DNS.
sometimes, the DHCP of the router directly send the ISP DNS in the DHCP offer/reply.

if you have a single computer, the simplest is to modify the hosts file of this computer, not on the Pi.
on windows, it's located at C:\Windows\system32\drivers\etc\hosts
add the hostname of your raspberry and its IP.
if you other computer is linux, it's simply /etc/hosts
this file as only a local meaning, and used by the local machine to override DNS solving.

if you have multiple computers :
* look if you can add static DHCP lease including a hostname in your router config
* or install a DNS server on your network, you will have to register it on your DHCP
* or buy another router or upgrade to OpenWRT

a last thing about arp -a
it only display last knows mac address. ARP table is often flushed. you have to ping that IP to have an entry in the ARP table.

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 3:47 pm
by PeterO
ATARI wrote:
PeterO wrote:How are you expecting the PC to resolve the hostname of the PI into its IP address ?
PeteO
Well to be honest I though my router would resolve this since all is connected to it.
This is probably a different issue anyway.
yep I guess so too, even online port check tools say all the port are closed.
A router will only do this if it is running a DNS server, in which case you'll need to use the routers gui to put entries into its DNS table.

But probably the simplest way to get the PC to resolve the PI's address is to put the PI's hostname and ip address into the hosts file on the PC. I can't help you with that as I don't have any M$ windblows PCs here.

PeterO

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 4:17 pm
by ATARI
PeterO wrote:
A router will only do this if it is running a DNS server, in which case you'll need to use the routers gui to put entries into its DNS table.

But probably the simplest way to get the PC to resolve the PI's address is to put the PI's hostname and ip address into the hosts file on the PC. I can't help you with that as I don't have any M$ windblows PCs here.

PeterO
haha allways with the love for microsoft ;)

well after a little fight with the PC over permissions i have change the "hosts" file and it now works wonderfull!
thanks alot

now I only have to open the proper ports on the router but I guess that this is for different forum right?

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 4:22 pm
by PeterO
Most recent M$ software I have in my house is W95 on an old laptop !
PeterO

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 4:30 pm
by ATARI
PeterO wrote:Most recent M$ software I have in my house is W95 on an old laptop !
PeterO
so you stopped using Windows right about when I started using computers :D


again thanks for the help. now I have to get this to work from externaly

Re: Hostname instead of IP

Posted: Sat Apr 06, 2013 6:33 pm
by oldsalt
Hi,

Rather than a new router you could try running dnsmasq on the pi and disable dhcp on the router,
http://www.thekelleys.org.uk/dnsmasq/doc.html, but more work but saves money.