Qoramas
Posts: 2
Joined: Wed Feb 03, 2016 7:33 pm

Local Web Interface via ethernet

Wed Feb 03, 2016 7:46 pm

Hi guy, I'm relatively new to the pi world and I'm probably jumping in a little too deep for my first project but here it goes.

I'm setting up my pi as a prototype controller for an embedded system (the details of which are irrelevant). I want the interface for the controls of the system to be very simple and intuitive to use so I'm going with a design that allows the user to plug an ethernet cable into the pi and their machine and access a web interface. Its nice and handy to set up a server but for the user to connect they need to statically set their ip and then enter the ip of the pi to access the interface. Heres the difficulty I'm having.

I want the system to be idiot proof. I'd like a system where the pi is set up as a dhcp server and a dns server so the user has no configurations and can simply type "pi.controls" for example into their browser. Theres examples of these parts online but they're all either too complex for what I need or above my head.

Is there any projects out there that already accomplish this?

Thanks in advance :)

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: Local Web Interface via ethernet

Thu Feb 04, 2016 8:18 am

No project to point you to but you can simply install dnsmasq that would act as a dhcp server and dns cache. Properly configured, any host connecting to the pi will receive a ip address from it as well as the dns server to point to (the pi itself).

Look for any dnsmasq tutorial. Pretty easy to configure for what you want to do.

To put you on track and to show you how easy dnsmasq is, here is a very basic configuration that works:

in /etc/dnsmasq.conf just define the ip range you want dnsmasq to serve:

Code: Select all

dhcp-range=192.168.0.5,192.168.0.6,255.255.255.0,1h
Add the Pi's fixed ip address in the pi's /etc/hosts file so that the hosts resolve the "pi.controls" domain name to the pi's address (here 192.168.0.155 for the example)

Code: Select all

192.168.0.155	pi.controls
Restart dnsmasq:

Code: Select all

sudo systemctl restart dnsmasq
That's two lines in config files and one restart. Can not be any simpler. Of course you can add any options of your liking int the dnsmasq.conf file.
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

Qoramas
Posts: 2
Joined: Wed Feb 03, 2016 7:33 pm

Re: Local Web Interface via ethernet

Thu Feb 04, 2016 9:11 am

Thanks ripat.

I think I was definitely overcomplicating this for myself. I'll get back if I have any issues but it looks like I should be good. :)

Return to “Beginners”