ATARI
Posts: 11
Joined: Thu Apr 04, 2013 8:32 am

Hostname instead of IP

Sat Apr 06, 2013 12:46 pm

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
"This isnt where I parked my Car" - Albert Einstein - Zürich - 2008

User avatar
azeam
Posts: 194
Joined: Fri Oct 26, 2012 11:13 pm
Contact: Website

Re: Hostname instead of IP

Sat Apr 06, 2013 1:11 pm

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

ATARI
Posts: 11
Joined: Thu Apr 04, 2013 8:32 am

Re: Hostname instead of IP

Sat Apr 06, 2013 1:13 pm

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
"This isnt where I parked my Car" - Albert Einstein - Zürich - 2008

User avatar
azeam
Posts: 194
Joined: Fri Oct 26, 2012 11:13 pm
Contact: Website

Re: Hostname instead of IP

Sat Apr 06, 2013 1:25 pm

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?

ATARI
Posts: 11
Joined: Thu Apr 04, 2013 8:32 am

Re: Hostname instead of IP

Sat Apr 06, 2013 1:40 pm

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
"This isnt where I parked my Car" - Albert Einstein - Zürich - 2008

User avatar
azeam
Posts: 194
Joined: Fri Oct 26, 2012 11:13 pm
Contact: Website

Re: Hostname instead of IP

Sat Apr 06, 2013 1:54 pm

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?

ATARI
Posts: 11
Joined: Thu Apr 04, 2013 8:32 am

Re: Hostname instead of IP

Sat Apr 06, 2013 2:02 pm

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
"This isnt where I parked my Car" - Albert Einstein - Zürich - 2008

User avatar
azeam
Posts: 194
Joined: Fri Oct 26, 2012 11:13 pm
Contact: Website

Re: Hostname instead of IP

Sat Apr 06, 2013 2:13 pm

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

ATARI
Posts: 11
Joined: Thu Apr 04, 2013 8:32 am

Re: Hostname instead of IP

Sat Apr 06, 2013 2:15 pm

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>
"This isnt where I parked my Car" - Albert Einstein - Zürich - 2008

klricks
Posts: 6609
Joined: Sat Jan 12, 2013 3:01 am
Location: Grants Pass, OR, USA
Contact: Website

Re: Hostname instead of IP

Sat Apr 06, 2013 2:50 pm

I think you have to install winbind. I haven't tried it myself
see this:
http://www.raspberrypi.org/phpBB3/viewt ... 66&t=25693
Unless specified otherwise my response is based on the latest and fully updated Raspbian Buster w/ Desktop OS.

User avatar
PeterO
Posts: 5067
Joined: Sun Jul 22, 2012 4:14 pm

Re: Hostname instead of IP

Sat Apr 06, 2013 2:52 pm

How are you expecting the PC to resolve the hostname of the PI into its IP address ?
PeteO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
azeam
Posts: 194
Joined: Fri Oct 26, 2012 11:13 pm
Contact: Website

Re: Hostname instead of IP

Sat Apr 06, 2013 2:53 pm

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

User avatar
PeterO
Posts: 5067
Joined: Sun Jul 22, 2012 4:14 pm

Re: Hostname instead of IP

Sat Apr 06, 2013 3:11 pm

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
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

User avatar
azeam
Posts: 194
Joined: Fri Oct 26, 2012 11:13 pm
Contact: Website

Re: Hostname instead of IP

Sat Apr 06, 2013 3:17 pm

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.

ATARI
Posts: 11
Joined: Thu Apr 04, 2013 8:32 am

Re: Hostname instead of IP

Sat Apr 06, 2013 3:20 pm

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)
"This isnt where I parked my Car" - Albert Einstein - Zürich - 2008

User avatar
azeam
Posts: 194
Joined: Fri Oct 26, 2012 11:13 pm
Contact: Website

Re: Hostname instead of IP

Sat Apr 06, 2013 3:27 pm

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.

ATARI
Posts: 11
Joined: Thu Apr 04, 2013 8:32 am

Re: Hostname instead of IP

Sat Apr 06, 2013 3:29 pm

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.
"This isnt where I parked my Car" - Albert Einstein - Zürich - 2008

trouch
Posts: 310
Joined: Fri Aug 03, 2012 7:24 pm
Location: France
Contact: Website

Re: Hostname instead of IP

Sat Apr 06, 2013 3:43 pm

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.

WebIOPi - Raspberry Pi REST Framework to control your Pi from the web
http://store.raspberrypi.com/projects/webiopi
http://code.google.com/p/webiopi/
http://trouch.com

User avatar
PeterO
Posts: 5067
Joined: Sun Jul 22, 2012 4:14 pm

Re: Hostname instead of IP

Sat Apr 06, 2013 3:47 pm

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
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

ATARI
Posts: 11
Joined: Thu Apr 04, 2013 8:32 am

Re: Hostname instead of IP

Sat Apr 06, 2013 4:17 pm

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?
"This isnt where I parked my Car" - Albert Einstein - Zürich - 2008

User avatar
PeterO
Posts: 5067
Joined: Sun Jul 22, 2012 4:14 pm

Re: Hostname instead of IP

Sat Apr 06, 2013 4:22 pm

Most recent M$ software I have in my house is W95 on an old laptop !
PeterO
Discoverer of the PI2 XENON DEATH FLASH!
Interests: C,Python,PIC,Electronics,Ham Radio (G0DZB),1960s British Computers.
"The primary requirement (as we've always seen in your examples) is that the code is readable. " Dougie Lawson

ATARI
Posts: 11
Joined: Thu Apr 04, 2013 8:32 am

Re: Hostname instead of IP

Sat Apr 06, 2013 4:30 pm

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
"This isnt where I parked my Car" - Albert Einstein - Zürich - 2008

oldsalt
Posts: 4
Joined: Sat Apr 06, 2013 2:44 pm

Re: Hostname instead of IP

Sat Apr 06, 2013 6:33 pm

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.

Return to “Networking and servers”