Linux - Server This forum is for the discussion of Linux Software used in a server related context. |
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.
|
 |
01-10-2011, 08:59 AM
|
#1
|
Member
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798
Rep:
|
can I use resolv.conf to have a local DNS entry
Hi,
I am having a situation where I do not have DNS server (the person who has that is not me) for a few websites which are running on a reverse proxy.
I recently after having a long trouble shooting hours found that my proxy pass entries look as follows
Code:
ProxyPass /app1 http://192.168.1.3:8080/app1
ProxyPass / http://192.168.1.3
ProxyPassReverse /app1 http://192.168.1.3:8080/app1
ProxyPassReverse / http://192.168.1.3
If I use the entries as above then some one from internet is able to access the sites.But from within LAN people are unable to access it.
How ever if I use
Code:
ProxyPass /app1 http://site1.myserver.com:8080/app1
ProxyPass / http://site1.myserver.com
ProxyPassReverse /app1 http://site1.myserver.com:8080/app1
ProxyPassReverse / http://site1.myserver.com
then things work on LAN but from internet it is not accessible.
What can be a solution in this case will putting things in resolv.conf do?
Last edited by tkmsr; 01-10-2011 at 09:04 AM.
|
|
|
01-10-2011, 09:34 AM
|
#2
|
Senior Member
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824
|
It would be simpler to add entries in /etc/hosts instead.
|
|
|
01-10-2011, 09:50 AM
|
#3
|
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
|
To amplify on the prior answer a bit:
You can use /etc/hosts on the system to setup basic host records. You must also set /etc/nsswitch.conf so it has "files" before "dns" so it will try your /etc/hosts file before it tries the DNS servers in /etc/resolv.conf.
In /etc/hosts you don't add "http://site1.myserver.com" - you add "site1.myserver.com" with the IP for same. In your browser when you type "http://site1.myserver.com" it will get the IP you put in /etc/hosts.
Note that nslookup, dig, host etc... will NOT show you entries from /etc/hosts. However, most other commands that rely on networking use things such as getbyhostaddress that do know to look at your nsswitch.conf to determine where to look for address. Sometimes you can do ping (e.g. ping site1.myserver.com) to verify which IP commands will use to try to connect. (Since it is a web page trying "telnet site1.myserver.com 80" to connect to port 80 might work, if not using tools like curl, lynx or wget might be useful from command line.)
|
|
1 members found this post helpful.
|
01-10-2011, 10:00 AM
|
#4
|
Member
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798
Original Poster
Rep:
|
Quote:
Originally Posted by MensaWater
To amplify on the prior answer a bit:
You can use /etc/hosts on the system to setup basic host records. You must also set /etc/nsswitch.conf so it has "files" before "dns" so it will try your /etc/hosts file before it tries the DNS servers in /etc/resolv.conf.
|
I just noticed after your messages that I had done the same (6 months back) I had forgotten /etc/hosts file
Here is how it looks on the server in question
Code:
127.0.0.1 localhost
192.168.1.10 myserver.com
192.168.1.16 site4.myserver.com
192.168.1.13 site1.myserver.com
192.168.1.14 site2.myserver.com
192.168.1.15 site3.myserver.com
The problem I reported is after having such entries above in my /etc/hosts file.
So is the above way to have entries correct?
Quote:
Originally Posted by MensaWater
In /etc/hosts you don't add "http://site1.myserver.com" - you add "site1.myserver.com" with the IP for same. In your browser when you type "http://site1.myserver.com" it will get the IP you put in /etc/hosts.
|
That would happen on the server where I make these changes in /etc/hosts.
Quote:
Originally Posted by MensaWater
Note that nslookup, dig, host etc... will NOT show you entries from /etc/hosts. However, most other commands that rely on networking use things such as getbyhostaddress that do know to look at your nsswitch.conf to determine where to look for address.
|
Here is how nsswitch.conf looks on my system.
Code:
# /etc/nsswitch.conf
#
# Example configuration of GNU Name Service Switch functionality.
# If you have the `glibc-doc-reference' and `info' packages installed, try:
# `info libc "Name Service Switch"' for information about this file.
passwd: compat
group: compat
shadow: compat
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
networks: files
protocols: db files
services: db files
ethers: db files
rpc: db files
netgroup: nis
Quote:
Originally Posted by MensaWater
Sometimes you can do ping (e.g. ping site1.myserver.com) to verify which IP commands will use to try to connect. (Since it is a web page trying "telnet site1.myserver.com 80" to connect to port 80 might work, if not using tools like curl, lynx or wget might be useful from command line.)
|
Is there a way I can configure /etc/resolv.conf to give priority to /etc/hosts file to resolve the URL first which is localhost and then query the corporate DNS.
Last edited by tkmsr; 01-10-2011 at 10:07 AM.
|
|
|
01-10-2011, 12:16 PM
|
#5
|
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
|
/etc/resolv.conf has nothing to do with /etc/hosts. It is purely for DNS.
/etc/nsswitch.conf is what determines priority of /etc/hosts over DNS and based on you entry:
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
You already have "files" first which means it should try /etc/hosts before any of the dns entries.
Your issue may be because /etc/hosts is resolving myserver.com first and may not be checking the others.
Try moving this entry:
192.168.1.10 myserver.com
Below these entries:
192.168.1.16 site4.myserver.com
192.168.1.13 site1.myserver.com
192.168.1.14 site2.myserver.com
192.168.1.15 site3.myserver.com
|
|
|
01-10-2011, 12:48 PM
|
#6
|
Member
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798
Original Poster
Rep:
|
Thanks for this tip I did just try (rebooted edited etc etc) but it did not helped me.
|
|
|
01-10-2011, 01:44 PM
|
#7
|
LQ Guru
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
|
Just for clarification. What you set up in a hosts file affects only lookups done on the server that has that hosts file. Reading your original post I fear you are trying to make other PCs/servers see what is on another server and you can only do that by updating the hosts file on each and every one of those. Even setting up DNS wouldn't help unless the lookup was being referred to your server's DNS by the other DNS servers that you mentioned earlier. Note that even Windows PCs have hosts files but it isn't under /etc.
|
|
|
01-10-2011, 02:33 PM
|
#8
|
Member
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798
Original Poster
Rep:
|
Quote:
Originally Posted by MensaWater
Just for clarification. What you set up in a hosts file affects only lookups done on the server that has that hosts file.
|
I am very clear on this part.
[QUOTE=MensaWater;4219602]
Reading your original post I fear you are trying to make other PCs/servers see what is on another server and you can only do that by updating the hosts file on each and every one of those. [./quote]
Quote:
Originally Posted by MensaWater
Even setting up DNS wouldn't help unless the lookup was being referred to your server's DNS by the other DNS servers that you mentioned earlier.
|
You mean to say when I am inside corporate lan and rest of all the machines which are using the corporate DNS there if the Corporate DNS points to
<IP of site1> site1
some above sort of mapping.
Then it will work internally at least.
Quote:
Originally Posted by MensaWater
Note that even Windows PCs have hosts files but it isn't under /etc.
|
Yes I know thanks for reminding as I had forgotten it.
|
|
|
All times are GMT -5. The time now is 04:24 PM.
|
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
|
|