takurua
Posts: 16
Joined: Thu Sep 29, 2016 2:23 pm

Webserver - how do I set a nice address?

Thu Oct 27, 2016 1:50 pm

I am running a Pi in a classroom. There is no internet so the Pi is the webserver, connected to a router and picked up by student's smart phones. I have set a static address so I have to ask my students to go to http://192.168.1.88. This feels messy and I would like to direct them to an address so they could type say "english.class" in the address bar and be directed to the pi webserver.
How would I do this? Perhaps a dns config?
I am running Raspbian lite.

User avatar
DougieLawson
Posts: 40201
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Webserver - how do I set a nice address?

Thu Oct 27, 2016 2:04 pm

If the RPi is running avahi-daemon then http://pi.local/ should "just work". You could tweak the avahi-daemon config to change the second part of that name. You can change the first part of that name in sudo raspi-config (it uses the hostname).

If that doesn't work then you'll need to set up dnsmasq or bind9 as a local DNS server. Which is something interesting to do anyway.
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

mutley
Posts: 61
Joined: Sat Jan 02, 2016 8:06 pm

Re: Webserver - how do I set a nice address?

Thu Oct 27, 2016 2:20 pm

As you stated, you need to modify what ever is servicing DNS for this network. You state it's connecting to a router, so this is probably what's doing name resolution for you. BUT :-
Most routers do not do DNS, they simply forward the request onto your ISP's DNS server. Since you said there is no internet connection, this obviously isn't the case in your situation.
We would need to know more about the network and the specifics of how the student's smart phones are connecting to the network to state where / how your could do this. Here is a brief overview of a Normal network and how this works.

Client device once connected to a network (WiFi or Hardwire with PC or Phone), requests an address on the network with DHCP from a DHCP server.
DHCP server reply's with an address, and also a few other pieces of information, one of them being a DNS server.
Once connected, and the client types in "english.class" in a browser the client device requests the address of "english.class" from the DNS server. IP address is returned and browser connects.

So, if you can control the DNS server address that gets sent to the client during the DHCP request, AND you can set english.class = 192.168.1.88 in that DNS server you can achieve what you want.

My guess is your router (probably WiFi router) is doing DHCP for you, and there is no DNS at all on your network. So in this situation I would configure your router to send your PI's address as the DNS server when handing out DHCP leases, and to install a small DNS server on the PI.

dnsmasq might be the easiest "DNS server" to install and configure on the pi but it's designed to be a DHCP server as well as DNS server and to have access to an upstream DNS server (a real DNS server on the internet). So the config might be challenging in your situation, and I can't confirm it will actually work in your situation. If you do use dnsmasq, I would recommend turning off DHCP in your router and using dnsmasq as the DHCP server as well as DNS server as that will make life a lot easier.

mutley
Posts: 61
Joined: Sat Jan 02, 2016 8:06 pm

Re: Webserver - how do I set a nice address?

Thu Oct 27, 2016 2:25 pm

DougieLawson wrote:If the RPi is running avahi-daemon then http://pi.local/ should "just work". You could tweak the avahi-daemon config to change the second part of that name. You can change the first part of that name in sudo raspi-config (it uses the hostname).
I was thinking of an easier way to do this than running a DNS server, so I think this is a great idea, but isn't avahi-daemon a Bonjour implementation for linux? i.e. it will only work with Apple products?

takurua
Posts: 16
Joined: Thu Sep 29, 2016 2:23 pm

Re: Webserver - how do I set a nice address?

Thu Oct 27, 2016 2:30 pm

Thanks guys. I hate networking! The router is mine and I carry it into the classroom every day. The static IP address on the pi is a pain as I switch networks so I will try your suggestions. pi.local did not connect ( nor did raspberypi.local as picked up by my Ipscanner). Excellent feedback.

User avatar
DougieLawson
Posts: 40201
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Webserver - how do I set a nice address?

Thu Oct 27, 2016 3:29 pm

mutley wrote:
DougieLawson wrote:If the RPi is running avahi-daemon then http://pi.local/ should "just work". You could tweak the avahi-daemon config to change the second part of that name. You can change the first part of that name in sudo raspi-config (it uses the hostname).
I was thinking of an easier way to do this than running a DNS server, so I think this is a great idea, but isn't avahi-daemon a Bonjour implementation for linux? i.e. it will only work with Apple products?
Bonjour has been a integral part of Windows since Win7 (or possibly earlier) even though it was invented by Apple.
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

User avatar
CarlRJ
Posts: 598
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: Webserver - how do I set a nice address?

Thu Oct 27, 2016 4:54 pm

DougieLawson wrote:
mutley wrote:... but isn't avahi-daemon a Bonjour implementation for linux? i.e. it will only work with Apple products?
Bonjour has been a integral part of Windows since Win7 (or possibly earlier) even though it was invented by Apple.
Avahi and Apple's Bonjour (originally named Rendezvous) are both implementations of ZeroConf (which, yes, Apple had a large part in creating). Windows has an implementation as well, though I don't know much about it. But Avahi is on by default in modern versions of Raspbian, and plays well with Bonjour. I use it every time I ssh into my Raspberry Pi's as _whatever_.local, the Pi's use it to talk to each other via MQTT, and they also use it to mount a drive from my NAS to back themselves up. Keep in mind that the mechanism involves each host periodically broadcasting its name/address details, which the other hosts on the network then cache for future use, so a machine that has just booted up or awoken may take a moment or two before it knows its neighbors by name, but it sure beats using using numeric (okay, dotted quad) IP addresses like an animal.

User avatar
DougieLawson
Posts: 40201
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Webserver - how do I set a nice address?

Thu Oct 27, 2016 6:38 pm

I'm old school. I've got a fully configured local DNS which includes IPv4 and IPv6 addresses for all twenty seven machines on my network. It's also got some DNS poisoning so some urls like dailymail.co.uk simply won't work.

I did it years ago after I'd read the Cricket book - DNS & BIND (now in its 5th edition) http://shop.oreilly.com/product/9780596100575.do

There's some downloadable scripts for DNS & BIND that convert a simple hosts file into zone definitions. Those can make going from nothing to a full bind9 DNS really easy. Beware they unzip into the current working directory so you have to muck about.

cd /tmp
wget http://examples.oreilly.com/9780596100575/dns.5ed.tar.Z
mkdir dns_bind
cd dns_bind
tar xavf ../dns.5ed.tar.Z
cd h2n-hp
Criticising any questions is banned on this forum.

Any DMs sent on Twitter will be answered next month.
All fake doctors are on my foes list.

Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

mutley
Posts: 61
Joined: Sat Jan 02, 2016 8:06 pm

Re: Webserver - how do I set a nice address?

Thu Oct 27, 2016 10:41 pm

CarlRJ wrote:
DougieLawson wrote:
mutley wrote:... but isn't avahi-daemon a Bonjour implementation for linux? i.e. it will only work with Apple products?
Bonjour has been a integral part of Windows since Win7 (or possibly earlier) even though it was invented by Apple.
Avahi and Apple's Bonjour (originally named Rendezvous) are both implementations of ZeroConf (which, yes, Apple had a large part in creating).
But going back to the O.P., he mentioned smart phones, So I was thinking Android & IOS are the main devices. I don't think Android supports any form of ZeroConf. And thinking about it further, I think by default some android devices are fixed to googles DNS server. So if this is the case, avahi-daemon won't work for android phones, and custom DNS server will only fork for some Android devices, unless the students re-configure the device to use the default network DNS server over Googles.

User avatar
CarlRJ
Posts: 598
Joined: Thu Feb 20, 2014 4:00 am
Location: San Diego, California

Re: Webserver - how do I set a nice address?

Fri Oct 28, 2016 2:27 am

mutley wrote:But going back to the O.P., he mentioned smart phones, So I was thinking Android & IOS are the main devices. I don't think Android supports any form of ZeroConf.
Or, instead of guessing, you could click the link I posted to the ZeroConf article on Wikipedia, search for "Android" and read this:
The Bonjour implementation (mDNSResponder) is available under the Apache 2 Open Source license and is included in Android 4.1 “Jelly Bean” and later under the same license.
But if you really want to do things the hard way, feel free. ;)

broe23
Posts: 902
Joined: Thu Jan 28, 2016 9:35 pm
Location: Central IL
Contact: Website

Re: Webserver - how do I set a nice address?

Fri Oct 28, 2016 6:02 am

takurua wrote:I am running a Pi in a classroom. There is no internet so the Pi is the webserver, connected to a router and picked up by student's smart phones. I have set a static address so I have to ask my students to go to http://192.168.1.88. This feels messy and I would like to direct them to an address so they could type say "english.class" in the address bar and be directed to the pi webserver.
How would I do this? Perhaps a dns config?
I am running Raspbian lite.
You really should be sending them through a Captive Portal before allowing them to go online. That way if their grades slip, they would have to answer select quiz questions that would give them so much time on the system. Also letting them use smartphones and not having any way to keep them from trying to send files between each other or someone trying to hack another student's smartphone or tablet, you are opening yourself up to some issues that you need to make sure that they understand it is Zero Tolerance. Once again we come back to using the Captive Portal to remind them that the use of the system is a privilege and that privilege can be taken away.

Now as for running a Pi as a server. There is the fact that if a Android OS device is rooted and running something like Airsnort or a packet capture app. That student can also cause issues. In this day and age you really have to think ahead. Using Free Radius is one way to help secure besides the Captive Portal. Also using Webmin to maintain the Samba or FTP server from the backend, along with making sure that rulesets are not going to allow them outside of the folder with the shares. You can make their life tough when it comes to only doing what you only want them to do.

The other thing to keep in mind is to make sure that if the students do upload files, that you have a log running to record the device MAC ID, IP assigned and the file they transferred. It may mean just swapping out SD cards each day to hold that prior day in a binder locked in a desk, so that if you are called to the carpet, you can produce the SD card and there would be no question asked for proof to show the what and the why.
Ren: Now listen, Cadet. I've got a job for you. See this button? Ren: Don't touch it! It's the History Eraser button, you fool! Stimpy: So what'll happen? Ren: That's just it. We don't know. Maybe something bad, maybe something good.

takurua
Posts: 16
Joined: Thu Sep 29, 2016 2:23 pm

Re: Webserver - how do I set a nice address?

Fri Oct 28, 2016 10:12 am

Just to clarify. Right now the Pi is only delivering web pages. The set up is Apache, Perl and an xml-based CMS called GetSimple. The pi connects to a router using a static address and students can only access the webserver, with everything happening in a classroom. This way, instead of paper handouts - readings, pictures, role cards, exercises - students look at their phone using a browser.
I see over 300 students a week so the student side, mainly android phones, must be very easy to connect. The students have problems understanding complicated instructions and I have to navigate through a phone displaying only Chinese to assist them connecting.
Next step is more interaction so I have installed Learning Management Systems Chamilo and Moodle on another sdcard. Installing, configuring and developing content is a big task so I would like to get my static pages looking a bit more professional first.

Return to “General discussion”