LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   SUSE / openSUSE (https://www.linuxquestions.org/questions/suse-opensuse-60/)
-   -   Adding a host alias in /etc/hosts (https://www.linuxquestions.org/questions/suse-opensuse-60/adding-a-host-alias-in-etc-hosts-388888/)

tortle 12-03-2005 12:31 PM

Adding a host alias in /etc/hosts
 
Hi --

I'm setting up a virtual host (test.org) for testing. The
host is on my desktop machine which is running SUSE 9.3.

I added an alias to /etc/hosts:

Code:

128.0.0.1      localhost test.org
In hosts.conf I have:

Code:

order hosts, bind
So the hosts file should be checked first. (This is how
I've done this in the past.)

Anyway, I get:

Code:

user@/> host localhost
localhost has address 127.0.0.1
user@/> host test.org
Host test.org not found: 3(NXDOMAIN)

Do I need to restart the resolver? How do I do that?

MensaWater 12-04-2005 08:00 AM

One of the nasty surprises from Linux is that it does NOT use /etc/hosts for nslookup/host command unlike Unix. It does resolve within programs but there's no way to prove it from the command line with either of those utilties. :mad:

I beat my head over this issue for a while since I was used to nslookup working just fine for this purpose on Unix. Most of the Linux only folks thought I was nuts for expecting it to work.

At the time I stated my opinion this is a bug in Linux. :twocents:

tortle 12-05-2005 10:38 AM

Hi jlightner --

Thanks for the reply. I think this behavior might be distro-specific,
because I'm pretty sure I had a setup similar to this working exactly
this way under Slackware a while back; don't know what's different
under SUSE. It occurred to me after I posted that SUSE might be
treating '/etc/hosts' more strictly; that is, it is allowing only
a _host name_ (i.e., and undotted string) as an alias to be added
there, and what I'm trying to add is a _domain name_ as an alias
for 127.0.0.1.

Anyway, I think I'm going to have to let this one go for now
and figure out some other way to do this. Thanks.

MensaWater 12-05-2005 10:53 AM

I don't think it is distro specific because it does the same in RH 9, RH 7, RH EL AS 3, Fedora 3, RH EL AS4, Fedora 4 (all of which are RedHat derivaives I know) but also in Debian (which is NOT a RedHat derivative). Also nearly everyone that responded to the thread I posted at the time I ran across this thought I was a moron for expecting it to work. It appears to be Linux specific though of course one could modify the source to make it do whatever they want.


All times are GMT -5. The time now is 07:26 AM.