# where shall I set domainname?

## clouds222

where shall I set the domainname? I can set the hostname in /etc/conf.d/hostname, but I can't set the domainname.

```

localhost ~ # domainname

(none)

```

----------

## Mike Hunt

You set that in /etc/hosts

Example:

```
127.0.0.1 mybox.at.myplace mybox localhost
```

And /etc/conf.d/hostname

```
HOSTNAME="mybox"
```

Then activate it

```
# hostname mybox

# hostname -f

mybox.at.myplace

# dnsdomainname

at.myplace
```

Last edited by Mike Hunt on Wed Sep 09, 2009 2:15 pm; edited 1 time in total

----------

## clouds222

Thanks Mike, follow your help. I set the domain name successfully.

my hosts.

```
# IPv4 and IPv6 localhost aliases

127.0.0.1       localhost  

 127.0.0.1     www.95908.com  www

::1             localhost
```

but when I execute command domainname it gives the result. whats the reason?

is "www.95908.com" domainname or hostname?

```

localhost ~ # domainname

(none)

localhost ~ # host

host      hostid    hostname

localhost ~ # hostname

www

localhost ~ # hostname -f

www.95908.com

localhost ~ # domainname

(none)

localhost ~ # domainname -f

www.95908.com

localhost ~ #

```

----------

## John R. Graham

 *Mike Hunt wrote:*   

> You set that in /etc/make.conf

 Actually, that would be "/etc/hosts".    :Rolling Eyes: 

- John

----------

## Mike Hunt

Oops fixed that - sorry about that - need more coffee. :Smile: 

BTW clouds222

the command is dnsdomainname - try that.

----------

## elissoncosta

Clouds222,

You must set the parameter sysctl:

# sysctl -w kernel.domainname="mydomain"

or insert the following line in '/etc/sysctl.conf':

kernel.domainname = "mydomain"

 :Smile: 

--

Elisson CostaLast edited by elissoncosta on Tue Jan 05, 2010 9:00 pm; edited 1 time in total

----------

## clouds222

Thanks.

Mike,  follow your help, the dnsdomainname can be read.

elissoncosta, follow your steps, domainname can be read.

it should be kernel.domainname = mydomain ? no """ 

but one more question:

It replys time interval by ping the hostname on the localhost:

```
sha1worktest2 ~ # ping sha1worktest2

PING sha1worktest2.xxxx.com (127.0.0.1) 56(84) bytes of data.

64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.102 ms

64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.075 ms
```

but the host can't be reached by hostname from other pc on the local network, but can be reached by IP addr.

the nameserver is setted by dhcp automatically in resolve.conf

```
sha1worktest2 ~ # less /etc/resolv.conf 

# Generated by dhcpcd from eth2

# /etc/resolv.conf.head can replace this line

search xxxx.com

nameserver 10.130.1.10

nameserver 10.1.100.50

```

----------

## Mike Hunt

 *clouds222 wrote:*   

> but the host can't be reached by hostname from other pc on the local network, but can be reached by IP addr.

 

It can if you configure it in the /etc/hosts of the remote hosts.

----------

## clouds222

do you mean configure the /etc/hosts in each computer you visit from? I think it should not be the solution.

I guess that it may need the network manager to add the client to the DOMAIN. so that the hostname is recode in the DNS database. is that so?

although I can use the DHCP to aquire an IP addr. but the PC is just on the network but not on the DOMAIN, am I right?

----------

## clouds222

Although the hostname display correct at localhost, but I think it's feint.

I get the client list from my router, the first and the second are windows client, and the third is gentoo linux client.

The PC is always find as none enven I reboot the router, change the Linux client hostname. but the other clients can be found correctly when I change the hostname.

Some other configuration needed?

1 IBM-2F52A991B5C 

2 oem_desktop 

3 none 

----------

## clouds222

In my friend's Federo Core system(we are on the same network), I encounter the same problem, but he adds hostname to /etc/hostname to fix it.

I checked /etc/conf.d/hostname

there is such line.

```

HOSTNAME="sha1worktest2"

```

The PC is still not reacheable by hostname.

----------

## clouds222

I finally resolved this by install samba.

----------

