# Where does the domain name come from?

## curmudgeon

Can someone tell me where /etc/init.d/hostname script (when run at boot) gets the domain name from?

----------

## Hypnos

/etc/conf.d/hostname

----------

## toralf

 *Hypnos wrote:*   

> /etc/conf.d/hostname

 IMHO wrong.

I've :

```
tfoerste@n22 ~ $ cat /etc/conf.d/hostname

# Set to the hostname of this machine

hostname="n22"

```

and /et/issue shows my domain name if I use "\O" instead the default "\o"[code]:[code]tfoerste@n22 ~ $ cat /etc/issue

This is \n.\O (\s \m \r) \t

[/code]

----------

## Hypnos

The Gentoo Handbook specifies /etc/conf.d/hostname as the place.  If /bin/hostname doesn't show the same hostname after /etc/init.d/hostname is invoked, then that's a bug.

It is true that \O in /etc/issue displays the FQDN, and not just the hostname.  This is equivalent to "hostname -f" .

----------

## toralf

 *Hypnos wrote:*   

> The Gentoo Handbook specifies /etc/conf.d/hostname as the place.  

 That documents says : *Quote:*   

> Second, if you need a domainname, set it in /etc/conf.d/net. 

 

----------

## mv

Every script from /etc/init.d inherits the variables set in /etc/conf.d/$same_name. Whether it uses these variables depends on the script, but an inspection of /etc/init.d/hostname shows that this script obviously uses the variable defined there for the call of the hostname binary.

----------

## Hypnos

I'm an idiot -- I read "domain name" as "hostname" in the OP.

 :Embarassed: 

----------

## toralf

 *Hypnos wrote:*   

> I read "domain name" as "hostname" in the OP. 

 FUnny enogh - your answer seems to be right nevertheless  :Wink: 

----------

## javeree

That is also where I set my domain name. 

 *Quote:*   

> hostname="Myhostname.mydomain"

 

However, I see when I start up, my logon prompt says:

This is user at Myhostname.mydomain.mydomain

(or something to that effect, I don don have access to that pc now.

So I guess there is still a second location where the domain name is set, or it is reinterpreted a second time.

however, the only place where I explicitly mention the domain name is in the dnsmasq configuration (this PC is acting as a router).

DNSMASQ_OPTS="$DNSMASQ_OPTS --domain-needed --domain=mydomain"

----------

## xaviermiller

Try to set your domain name in /etc/hosts

Something like

```
127.0.0.1 hostname.domainname hostname localhost

```

----------

## JC99

In /etc/hosts you should have something like...

```
192.168.0.1     hostname.domain.com      hostname
```

...obviously replacing hostname and domain.com with whatever you are using.

----------

