# Setting domainname

## salmonix

Can sb explain me the differences of setting domainname in

1)  /etc/conf.d/domainname, 

2) /etc/conf.d/net file, 

3) /etc/sysctl.conf 

4) /etc/hosts ?

and probably their relation with dnsmasq domain option?

Thnx!

----------

## UberLord

/etc/conf.d/domainname isn't used anymore

/etc/conf.d/net can set a DNS or NIS domain name

/etc/sysctl.conf only sets a NIS domain name

/etc/hosts doesn't set any domain names as such - is purely a name -> ip lookup table

First ask why you need to set a DNS domain name, as 99% of the time you are wrong.

Making the unknown_domain go away on your terminal login isn't a valid answer  :Smile: 

----------

## salmonix

Thanx. It was merely a question risen after reading some controversal docs and the picture i felt not clear.

----------

## Ph0eniX

 *UberLord wrote:*   

> /etc/conf.d/domainname isn't used anymore
> 
> /etc/conf.d/net can set a DNS or NIS domain name
> 
> /etc/sysctl.conf only sets a NIS domain name
> ...

 

The thing is that if you don't set your FQDN in /etc/hosts, hostname -f will not work.  Ironically when I do, then my PPTP connection stops working.  Go figure.

----------

## UberLord

 *Ph0eniX wrote:*   

> The thing is that if you don't set your FQDN in /etc/hosts, hostname -f will not work.  Ironically when I do, then my PPTP connection stops working.  Go figure.

 

hostname -f merely looks up the FQDN in DNS if the hostname is not a FQDN.

The default libc setup will use /etc/hosts before looking up in DNS.

Why do you need hostname -f to report a FQDN anyway?

----------

## depontius

I don't know about Ph0eniX, but I frequently need an FQDN, in order to run CAD (Computer Aided Design) tools when I'm working from home.  Many of these tools have all sorts of licensing crap built-in, and for one particular tool suite, I have to have a forward and reverse resolvable FQDN that appears to be inside my employer's domain.  If I don't have that, I get to sit waiting for all sorts of time-outs, and so far have never gotten any useful work done without the FQDN properly set.  Maybe the software is broken, and I would agree with that assessment for other reasons, but it's what my employer has chosen for use on our designs, so we don't really have a viable choice.  File-level compatibility, standards, I wish!

Incidentally, to set my FQDN to be "at work" I use the IP assigned through my employer's VPN and find the associated FQDN through a DNS lookup.  Then I craft an entry in /etc/hosts to match, and use "hostname (shortname)" to set the name.  After that, "hostname -f" returns the FQDN properly, even though I've only set the shortname.  The shortname plus /etc/hosts is sufficient.  The CAD software runs.

----------

## UberLord

 *depontius wrote:*   

> I don't know about Ph0eniX, but I frequently need an FQDN, in order to run CAD (Computer Aided Design) tools when I'm working from home.  Many of these tools have all sorts of licensing crap built-in, and for one particular tool suite, I have to have a forward and reverse resolvable FQDN that appears to be inside my employer's domain.  If I don't have that, I get to sit waiting for all sorts of time-outs, and so far have never gotten any useful work done without the FQDN properly set.  Maybe the software is broken, and I would agree with that assessment for other reasons, but it's what my employer has chosen for use on our designs, so we don't really have a viable choice.  File-level compatibility, standards, I wish!

 

That's probably the first valid reason I've heard for setting a FQDN like that!

 *Quote:*   

> Incidentally, to set my FQDN to be "at work" I use the IP assigned through my employer's VPN and find the associated FQDN through a DNS lookup.  Then I craft an entry in /etc/hosts to match, and use "hostname (shortname)" to set the name.  After that, "hostname -f" returns the FQDN properly, even though I've only set the shortname.  The shortname plus /etc/hosts is sufficient.  The CAD software runs.

 

Could do better  :Smile: 

Install openresolv

Install a decent local resolver, like dnsmasq

Configure /etc/dnsmasq.conf according to /etc/resolvconf/update.d/dnsmasq

DHCP clients always wang their domains entries in "search".

OpenVPN wangs the domain in "domain". If you don't use OpenVPN in Gentoo, you'll need to make your VPN client 1) use resolvconf, and 2) wang the domain in domain if it uses search.

This enables all DNS queries for the VPN domain to goto the VPN server and all other queries to the DNS server specified by the DHCP client.

----------

## depontius

 *UberLord wrote:*   

>  *depontius wrote:*   Incidentally, to set my FQDN to be "at work" I use the IP assigned through my employer's VPN and find the associated FQDN through a DNS lookup.  Then I craft an entry in /etc/hosts to match, and use "hostname (shortname)" to set the name.  After that, "hostname -f" returns the FQDN properly, even though I've only set the shortname.  The shortname plus /etc/hosts is sufficient.  The CAD software runs. 
> 
> Could do better 
> 
> Install openresolv
> ...

 

I tried the "resolvconf" package a while ago, shortly after it first arrived for Gentoo.  It didn't work for me, something wasn't getting triggered, because the directory structures seemed to be there, but the final result wasn't.  I scripted a few kludges to force it to work, and then decided to just bag it, and script stuff myself to do what it did.

I am running dnsmasq, principally to act as a versatile resolver, as you suggest.  The caching is unimportant in this situation, and can be a hindrance when the VPNs are coming up and going down, and I forget what my status is, and get a bogus resolution stuck in the cache.

I also run both OpenVPN for my own endpoint, and my employer's VPN for work access.  Getting the latter to play well may be the biggest reason to stay scripted, rather than some more standard solution that presumes cooperative, friendly software.

But just in case, does openresolv work better than resolvconf did?  (Or did you never have problems with either?)

----------

## UberLord

 *depontius wrote:*   

> I tried the "resolvconf" package a while ago, shortly after it first arrived for Gentoo.  It didn't work for me, something wasn't getting triggered, because the directory structures seemed to be there, but the final result wasn't.  I scripted a few kludges to force it to work, and then decided to just bag it, and script stuff myself to do what it did.

 

...

But just in case, does openresolv work better than resolvconf did?  (Or did you never have problems with either?)[/quote]

You should have reported your issues so we could try and make it work how you like it.

openresolv does work better than resolvconf-gentoo and does fix some issues.

I never have a problem using my own software - or I wouldn't release it  :Wink: 

So lets chat about it.

How about wanging openresolv in (it's available in Gentoo) and if you have any issues with it then open a bug at http://bugs.marples.name/enter_bug.cgi?product=openresolv

----------

## depontius

 *UberLord wrote:*   

> You should have reported your issues so we could try and make it work how you like it.
> 
> openresolv does work better than resolvconf-gentoo and does fix some issues.
> 
> I never have a problem using my own software - or I wouldn't release it 
> ...

 

I think I did report it at the time, but there were others making much more noise than me, and I was able to fix things on my own.  I probably won't have the laptop back in the cradle until after the holidays, but I'll give "openresolv" a shot, then.  As I said, I'm just a little fearful of making this work with the proprietary VPN software from my employer, but I'll see what I can do.

----------

## hem

My reason to set domainname:

I need to set a domainname for a software license. If its not set properly. the software don't start. 

What i tryed:

1) /etc/conf.d/domainname -> is set, don't work

2) /etc/conf.d/net file -> (dns_domain_eth0="domainname") don't work and end in a little drawback, resolv.conf will be overwritten and kill nameserver settings on each start

3) /etc/sysctl.conf -> no idea whats to do here

4) /etc/hosts ? -> is set properly but don't affect domainname (only hostname -f works, but the software license ignore that)

5) The settomainname prog i found on this forum -> only work with a hostname like "hostname.domainname" with ends in a "hostname.domainname.domainname" on login with some routing trouble

So how can i set the domainname on startup?

Any help would be appreciated.

----------

## depontius

I'm surprised you can't get it to work in /etc/conf.d/net - that's how I do it on my work machines.  I'll check mine tomorrow and post.  In the meantime you might post yours here.

I'm guessing that you're using dhcp.  Is this on a laptop that moves to other networks, or a deskside that stays on your employer's lan?  I have a static IP deskside at work, and that's simple.  I also have a laptop that moves, and I handle the domain name on that with custom scripting.  The case of a deskside with dhcp is simpler, in that /etc/conf.d/net will work, but you have to give it the right dhcp flags, as well.  Basically, you don't want dhcp to overwrite /etc/resolv.conf, and you want to properly configure it yourself.

----------

## hem

I use a static ip. My conf.d/net is:

```
modules=( "ifconfig" )

config_eth0=( "192.168.100.65 broadcast 192.168.100.255 netmask 255.255.255.0" )

routes_eth0=( "default via 192.168.100.1" )

dns_domain="net"

dns_domain_eth0="net"

dns_domain_lo="net"

dns_servers_eth0="192.168.100.1"
```

But i don't think that the software is interested on interface settings. It parse the output of the domainname command to check the license-identifier of the machine.

----------

## UberLord

 *hem wrote:*   

> It parse the output of the domainname command to check the license-identifier of the machine.

 

The domainname command is for the NIS domain, not the DNS domain.

----------

## depontius

 *UberLord wrote:*   

> 
> 
> The domainname command is for the NIS domain, not the DNS domain.

 

Well that's fascinating, to have a buried dependence on NIS like that.  How prevalent was NIS, in it's day?  I guess I figured they just parsed "hostname -f".

----------

## hem

Ok, then i need to set NIS. My setting in /etc/domainname for NIS is the same as DNS. It seems i have to set some more.

The prog from genome https://forums.gentoo.org/viewtopic-t-51538-highlight-setdomainname.html takes the right NIS setting, but it should use the settings from /etc/domainname instead of hostname. Can anyone change the code on this way?

----------

## UberLord

Set nis_domain="net" in conf.d/net

----------

## depontius

 *UberLord wrote:*   

> Set nis_domain="net" in conf.d/net

 

This looks handy, but if suddenly "domainname" starts returning something other than "(none)" will other programs start assuming that one is using NIS?

----------

## UberLord

You don't have to belong to a nis domain to use nis.

So in order words, only badly coded programs should be affected.

----------

## hem

 *Quote:*   

> nis_domain="net" in conf.d/net

 

Works great, thx for the help.

Btw: Setting dns_servers_eth0=... in addition to dns_domainname=... in /etc/conf.d/net will restore the lost DNS settings in /etc/resolv.conf

----------

