On Fri, 2011-04-01 at 05:20 +0200, Ralf Corsepius wrote: > On 03/31/2011 07:28 PM, Dan Williams wrote: > > On Sun, 2011-03-27 at 17:57 +0200, Ralf Corsepius wrote: > >> On 03/27/2011 05:27 PM, Chuck Anderson wrote: > >>> On Sun, Mar 27, 2011 at 03:58:06PM +0200, Ralf Ertzinger wrote: > >>>> Hi. > >>>> > >>>> On Sun, 27 Mar 2011 15:48:14 +0200, Kevin Kofler wrote > >>>>> NM supports static IPs these days. So I think that rather than > >>>>> hacking around NM, you should just fix the IP inside NM's > >>>>> configuration and have NM work FOR you rather than AGAINST you. > >>>> > >>>> I'm sorry, but by the time I have clicked through the GUI to do > >>>> that I have configured the interface via ip, did what I wanted to > >>>> do and unconfigured the interface again. > >>>> > >>>> I uncheck "Enable networking" in nm-applet before doing that, > >>>> and for me that makes NM keep it's grubby paws off my manually > >>>> configured interface, so I'm not complaining. > >>> > >>> You don't need to use the GUI. Just edit > >>> /etc/sysconfig/network-scripts/ifcfg-* with a static IP and NM will > >>> pick it up right away and configure it. > >> > >> And how to tweak /etc/sysconfig/network-scripts/ifcfg-* (and/or > >> /etc/sysconfig/network) for static IPs such that NM sets > >> hostname/domainname correctly? > > > Let me try to provide more details: > > Given a small (3 machines), wired (No WLAN, no VPN), static network > without dhcp and static IPs only, on a subnet of a larger network > (provides DNS), which is supposed to appear on a (private) domain of its > own (It's a lab's network). > > When adding a Fedora machine, > * with the "network" scripts it was possibile to assign the domainname > through /etc/sysconfig/network. > - "hostname" returned "<machine>", > - "hostname -f" returned "<machine>.<privatedomain>" man hostname: The function gethostname(2) is used to get the hostname. When the hostname -a, -d, -f or -i is called will gethostbyname(3) be called. The difference in gethostname(2) and gethostbyname(3) is that gethostâ byname(3) is network aware, so it consults /etc/nsswitch.conf and /etc/host.conf to decide whether to read information in /etc/sysconâ fig/network or /etc/hosts So here's what you do. Set your hostname to "happy" by modifying /etc/sysconfig/network: HOSTNAME=happy and update your /etc/hosts file to include this line: 127.0.0.1 happy.foobar.com happy localhost.localdomain localhost Then, 'hostname' will return "happy", and "hostname -f" will return happy.foobar.com as you desire. But note that 'man hostname' also says: It is not possible to set the FQDN or the DNS domain name with the dnsâ domainname command (see THE FQDN below). and further: You can't change the FQDN (as returned by hostname --fqdn) or the DNS domain name (as returned by dnsdomainname) with this command. The FQDN of the system is the name that the resolver(3) returns for the host name. Technically: The FQDN is the name getaddrinfo(3) returns for the host name returned by gethostname(2). The DNS domain name is the part after the first dot. Therefore it depends on the configuration (usually in /etc/host.conf) how you can change it. Usually (if the hosts file is parsed before DNS or NIS) you can change it in /etc/hosts. If a machine has multiple network interfaces/addresses or is used in a mobile environment, then it may either have multiple FQDNs/domain names or none at all. Therefore avoid using hostname --fqdn, hostname --domain and dnsdomainname. hostname --ip-address is subject to the same limitations so it should be avoided as well. So basically, if you don't have control over your DNS setup, you can't control your FQDN (obviously). If you have a small network, you probably *do* want to set your machine hostname to the FQDN if you for any reason need FQDNs at all. Otherwise you get to keep /etc/hosts up to date between all machines. Dan > * with NM, when > - using a fqn as hostname in > /etc/sysconf/networking-scripts/ifcfg*eth0 (rsp. nm-connection-editor), > both "hostname" and "hostname -f" always return the FQDN: > "<machine>.<privatedomain>" > - using "<machine>" as hostname in > /etc/sysconf/networking-scripts/ifcfg*eth0 rsp. nm-connection-editor, > "hostname" returns "<machine", while "hostname -f", thoughout the years > sometimes returned "<machine>", sometimes an empty string, sometimes > "localhost" and sometimes even hung. > > I don't know the exact causes. We've tried various things, but never > could make NM working as desired. > > In other words, my question is: > How to configure NM in a private, dhcp-less, static network, with only > static IPs, such that > "hostname" returns "<machine>" and > "hostname -f" returns "<machine>.<privatedomain>" > > > domainname is only used for NIS, > Hmm, this doesn't match with my understanding. Domainname and > ypdomainname are separate things. Domainname is the "domain part" of a > "FQDN", while ypdomainname is complete independent from the domainname > and may be set to something entirely different than "domainname". > > > which I assume you're not running. > We are using yp/NIS for this private network, but currently are not > using it for hostname resolution. > > > Otherwise, if you have a persistent hostname set > > in /etc/sysconfig/network (HOSTNAME=adasdasdf) then NM will respect > > that. If you do not have a persistent hostname set, then the hostname > > will come from the DHCP server, or if not available from DHCP, from > > reverse DNS lookup of your IP address, just as with the 'network' > > service. > > > NM will update your /etc/resolv.conf with various domains taken from > > your hostname, so if your hostname is "blah.foobar.com", NM will add > > "foobar.com" to the searches in /etc/resolv.conf. > > > > As has been stated before, NM does not touch /etc/hosts anymore. > > Could you tell me since when? The machines in question are running F13 ( > > Ralf -- devel mailing list devel@xxxxxxxxxxxxxxxxxxxxxxx https://admin.fedoraproject.org/mailman/listinfo/devel