LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 04-25-2017, 09:56 AM   #1
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 789

Rep: Reputation: Disabled
Access local web server via host name


I have a raspberry pi which who's host name is greenbean3 and it has a static IP of 10.120.11.30 and it is running nginx. I can access it via a web browser using http://10.120.11.30/. I installed avahi-daemon and I can ping it from a local device (yet for some reason not all local devices). Nginx is set up using server_name $domain_name greenbean3 greenbean3.local;.

My desire is to access it via a local web browser using http://greenbean3.local/ or http://greenbean3/ instead of the IP, but cannot do so and get greenbean3.local’s server DNS address could not be found. error. What can I do? Thank you

Code:
michael@raspberrypi2:/var/www $ ping greenbean3.local
PING greenbean3.local (10.120.11.30) 56(84) bytes of data.
64 bytes from 10.120.11.30: icmp_seq=1 ttl=64 time=0.339 ms
64 bytes from 10.120.11.30: icmp_seq=2 ttl=64 time=0.348 ms
^C
--- greenbean3.local ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.339/0.343/0.348/0.019 ms
michael@raspberrypi2:/var/www $
Code:
michael@greenbean3:~ $ cat /etc/dhcpcd.conf
hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option ntp_servers
require dhcp_server_identifier
slaac private
nohook lookup-hostname

interface eth0
static ip_address=10.120.11.30/24
static routers=10.120.11.1
static domain_name_servers=10.120.11.1
michael@greenbean3:~ $ hostname
greenbean3
michael@greenbean3:~ $
 
Old 04-25-2017, 10:06 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Poor Man's DNS:
vi /etc/hosts from the client:
Code:
10.120.11.30 greenbean3
as I'm not certain how
Code:
10.120.11.30 greenbean3 greenbean3.local
will respond, but you can try it.
If http://greenbean3.local doesn't puke....works until it doesn't?
http://greenbean3 should in any case.
 
Old 04-25-2017, 10:14 AM   #3
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 789

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
Poor Man's DNS:
Thanks Habitual, While I appreciate such a simple fix, this has one issue which I am a little concerned to tell you what it is as I am sure I will be damned for doing something so foolish and irresponsible. The who purpose of the web server is to change the network configuration settings, and I am using script to edit /etc/dhcpcd.conf and then restart the network. If I use this poor man's DNS approach, I need to parse even more config files.
 
Old 04-25-2017, 10:46 AM   #4
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Yeah, I couldn't grok the dhcp connection, so I punted.
https://s-media-cache-ak0.pinimg.com...7cf7ac88eb.jpg
 
Old 04-25-2017, 08:27 PM   #5
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 789

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by Habitual View Post
Yeah, I couldn't grok the dhcp connection, so I punted.
https://s-media-cache-ak0.pinimg.com...7cf7ac88eb.jpg
Ouch brain!!!

I knew it wouldn't be received well, thus the reason I was concerned to state my intent

Off topic. How can I build a router using a small Linux device and change the IP of the device using an embedded webserver?

Just kidding. On topic
 
Old 04-25-2017, 09:25 PM   #6
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,749

Rep: Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928
avahi is providing the local DNS service but AFAIK needs to be running on all linux boxes. MACs use bonjour and you would have to install it on Windows. For all devices connected to the local LAN to resolve hostnames to IP address you would need a local DNS server i.e. dnsmasq or bind. dnsmasq is simpler to configure is also a dhcp server and you can use an include file.

Considering that webmin and cups change configuration files but are standalone applications and not Nginx or Apache which have limitations on directories/permissions.
 
Old 04-26-2017, 06:43 AM   #7
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 789

Original Poster
Rep: Reputation: Disabled
Thanks michaelk.

If I install dnsmasq installed on the device, and the device is installed on a network with another dns server, will they conflict?
 
Old 04-26-2017, 09:34 AM   #8
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,749

Rep: Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928Reputation: 5928
I assume this is your home LAN? What DNS server is running?

Your want to be able to set a static IP address on the Pi via a web page and have its name resolution automatically be updated somehow.
 
Old 04-26-2017, 11:44 AM   #9
NotionCommotion
Member
 
Registered: Aug 2012
Posts: 789

Original Poster
Rep: Reputation: Disabled
Quote:
Originally Posted by michaelk View Post
I assume this is your home LAN? What DNS server is running?

Your want to be able to set a static IP address on the Pi via a web page and have its name resolution automatically be updated somehow.
No, it will be on a school's LAN, and the specific DNS server is unknown.

The two goals are:
  • Allow non-technical user to change static IP via a web browser.
  • If non-technical user forgets the IP, they can fall back to using the hostname.
 
Old 04-27-2017, 12:16 PM   #10
jmgibson1981
Senior Member
 
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: Debian
Posts: 1,144

Rep: Reputation: 392Reputation: 392Reputation: 392Reputation: 392
I would rethink what I'm trying to do. People shouldn't be able to arbitrarily change their ip, especially not on a network outside of their home. Otherwise you can end up with collisions. The right way to do this is a dns server ( i use bind 9 at home) and a dhcp server with ip addresses assigned via mac address I would think.

What is the end goal and what are you trying to achieve by giving people the ability to change their static ip?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Local users cannot access my web server using public address sdblanchet Linux - Networking 1 11-21-2014 08:42 PM
[SOLVED] Local users cannot access my web server using public address sdblanchet Linux - Networking 0 11-18-2014 07:45 PM
Host a web server from local PC via VPN? Vita Linux - Newbie 0 03-02-2014 06:45 PM
How to access local web server? Libertes Linux - Server 2 04-15-2008 07:11 AM
access lan web server thru dual homed host / webserver from internet with one pub IP. swilhelm Linux - Networking 2 08-02-2006 02:57 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 01:44 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration