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 How ever if I use Code:
ProxyPass /app1 http://site1.myserver.com:8080/app1 What can be a solution in this case will putting things in resolv.conf do? |
It would be simpler to add entries in /etc/hosts instead.
|
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.) |
Quote:
Here is how it looks on the server in question Code:
127.0.0.1 localhost So is the above way to have entries correct? Quote:
Quote:
Code:
# /etc/nsswitch.conf Quote:
|
/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 |
Thanks for this tip I did just try (rebooted edited etc etc) but it did not helped me.
|
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.
|
Quote:
[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:
<IP of site1> site1 some above sort of mapping. Then it will work internally at least. Quote:
|
All times are GMT -5. The time now is 05:35 PM. |