LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 01-10-2011, 08:59 AM   #1
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Rep: Reputation: 39
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.
 
Old 01-10-2011, 09:34 AM   #2
AlucardZero
Senior Member
 
Registered: May 2006
Location: USA
Distribution: Debian
Posts: 4,824

Rep: Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615Reputation: 615
It would be simpler to add entries in /etc/hosts instead.
 
Old 01-10-2011, 09:50 AM   #3
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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.
Old 01-10-2011, 10:00 AM   #4
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by MensaWater View Post
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 View Post
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 View Post
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 View Post
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.
 
Old 01-10-2011, 12:16 PM   #5
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
/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
 
Old 01-10-2011, 12:48 PM   #6
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Thanks for this tip I did just try (rebooted edited etc etc) but it did not helped me.
 
Old 01-10-2011, 01:44 PM   #7
MensaWater
LQ Guru
 
Registered: May 2005
Location: Atlanta Georgia USA
Distribution: Redhat (RHEL), CentOS, Fedora, CoreOS, Debian, FreeBSD, HP-UX, Solaris, SCO
Posts: 7,831
Blog Entries: 15

Rep: Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669Reputation: 1669
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.
 
Old 01-10-2011, 02:33 PM   #8
tkmsr
Member
 
Registered: Oct 2006
Distribution: Ubuntu,Open Suse,Debian,Mac OS X
Posts: 798

Original Poster
Rep: Reputation: 39
Quote:
Originally Posted by MensaWater View Post
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 View Post
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 View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Bogus entry in /etc/resolv.conf jeffbarish Linux - Networking 10 12-12-2006 07:48 PM
resolv.conf DNS search ( Anyway to continue searching next entry?) starsky Linux - Networking 5 08-22-2006 09:01 PM
DNS Hosts.conf or resolv.conf problem mac_casey SUSE / openSUSE 0 03-26-2006 09:21 AM
dns server and /etc/resolv.conf freeosfreesoul Linux - Laptop and Netbook 2 09-02-2005 06:45 PM
Mandrake adds unwanted entry to resolv.conf kmasaryk Mandriva 8 11-27-2004 03:40 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:17 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