# hostname -f/-d/-a

## redgsturbo

so /etc/conf.d/hostname is set to node1, and hosts is 

127.0.0.1 localhost

172.16.0.101 node1 node1.example.org

hostname returns 'node1'

hostname -f returns 'node1'

hostname -d returns nothing

hostname -a returns 'node1.example.org'

how do I get hostname -d to return example.org?

----------

## depontius

for one thing, you're a bit off on your format for "/etc/hosts".  It should look more like this:

```
127.0.0.1       localhost.localdomain   localhost

172.16.0.101    node1.example.org       node1
```

The general order is IP, longname, shortname.

That's the way my /etc/hosts are built.  For me -

"hostname" returns the shortname

"hostname -f" returns the full host+domain name

"hostname -d" returns the domain name

"hostname -a" returns the short hostname (I'm not using any aliases.)

----------

## poly_poly-man

hmm, seems to be a part of your dns server configuration.

I ran an strace on hostname -d (which for me properly gives back "lan"), seems to give traffic to my dns server.

wireshark seems to say it's a standard A request against my fqdn.

The first line of my zone.lan (after the $DIRECTIVES):

lan                     IN SOA  lan. sheeva.lan. (

seems to indicate the lan domain.

You may consider a packet dump against your ns to make sure it can resolve you. Either that or make for certain that resolv.conf also points to hosts.

----------

## depontius

Lacking other information, I was making the (perhaps erroneous) assumption that he didn't really have a lan - that we were talking a cable/dsl modem, maybe an appliance firewall, and a computer.  Perhaps I was jumping the gun, but no other information was supplied to suggest a more sophisticated setup.

I had to ssh into my server to find a "real" /etc/hosts file to show the format I did.  On my client machines I generally just have loopback defined as localhost in /etc/hosts, and count on dhcp to grab the hostname from my server.

----------

## InExile

Might want to look at etc/host.conf, if it reads 

```
order hosts, bind
```

then it looks in /etc/hosts before dns

/etc/hosts should be ip fqdn alias alias alias

```
127.0.0.1   pwned.mydomain.org pwned localhost localhost.localdomain
```

It is a laptop so I don't bother hard-coding a static ip, since it would be wrong 60% of the time.

also if you have nscd running you will be reading cached information, shut it down while troubleshooting this issue.

----------

