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 |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
04-25-2017, 09:56 AM
|
#1
|
Member
Registered: Aug 2012
Posts: 789
Rep: 
|
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:~ $
|
|
|
04-25-2017, 10:06 AM
|
#2
|
LQ Veteran
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Rep: 
|
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.
|
|
|
04-25-2017, 10:14 AM
|
#3
|
Member
Registered: Aug 2012
Posts: 789
Original Poster
Rep: 
|
Quote:
Originally Posted by Habitual
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.
|
|
|
04-25-2017, 08:27 PM
|
#5
|
Member
Registered: Aug 2012
Posts: 789
Original Poster
Rep: 
|
Quote:
Originally Posted by Habitual
|
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
|
|
|
04-25-2017, 09:25 PM
|
#6
|
Moderator
Registered: Aug 2002
Posts: 26,732
|
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.
|
|
|
04-26-2017, 06:43 AM
|
#7
|
Member
Registered: Aug 2012
Posts: 789
Original Poster
Rep: 
|
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?
|
|
|
04-26-2017, 09:34 AM
|
#8
|
Moderator
Registered: Aug 2002
Posts: 26,732
|
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.
|
|
|
04-26-2017, 11:44 AM
|
#9
|
Member
Registered: Aug 2012
Posts: 789
Original Poster
Rep: 
|
Quote:
Originally Posted by michaelk
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.
|
|
|
04-27-2017, 12:16 PM
|
#10
|
Senior Member
Registered: Jun 2015
Location: Tucson, AZ USA
Distribution: LMDE 6
Posts: 1,235
|
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?
|
|
|
All times are GMT -5. The time now is 12:36 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|