Hostname: Porovnání verzí

Z Wiki UnArt Slavičín
Skočit na navigaciSkočit na vyhledávání
Bez shrnutí editace
Bez shrnutí editace
Řádek 6: Řádek 6:


Poté, co jsem jeden stroj s Debian Lenny pojmenoval "backup", připojil na UTB k síti s DHCP a následně celé dopoledne řešil, proč si některé démony myslí, že s hostname je "vega" nebo "vega.utb.cz", podařilo se mi najít [http://linux.derkeiler.com/Mailing-Lists/Debian/2007-09/msg00017.html toto vysvětlení]:
Poté, co jsem jeden stroj s Debian Lenny pojmenoval "backup", připojil na UTB k síti s DHCP a následně celé dopoledne řešil, proč si některé démony myslí, že s hostname je "vega" nebo "vega.utb.cz", podařilo se mi najít [http://linux.derkeiler.com/Mailing-Lists/Debian/2007-09/msg00017.html toto vysvětlení]:
 
=Linux Debian hostname a FQDN=
A host is a host. One box, one name.
A host is a host. One box, one name.


Řádek 22: Řádek 22:
With libc6 (or was it 5), the resolver is configured in /etc/nsswitch.conf. That's Name Service Switch, and has many options.
With libc6 (or was it 5), the resolver is configured in /etc/nsswitch.conf. That's Name Service Switch, and has many options.


===So what is the correct way of setting the hostname and the FQDN?===
==So what is the correct way of setting the hostname and the FQDN?==


Ok. So you've named the computer. You put this hostname (the name up
Ok. So you've named the computer. You put this hostname (the name up
Řádek 72: Řádek 72:


Doug.
Doug.
=Co můj problém?=
DNS na UTB mělo již pro stroj s názvem backup.utb.cz záznam:
backup:/proc# dig backup.utb.cz
; <<>> DiG 9.6-ESV-R1 <<>> backup.utb.cz
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37912
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 3
;; QUESTION SECTION:
;backup.utb.cz.                IN      A
;; ANSWER SECTION:
backup.utb.cz.          86400  IN      CNAME  '''vega.utb.cz'''.
Jak prosté...

Verze z 20. 7. 2010, 11:11

Jak Linux Debian nastavuje hostname, resp. FQDN (fully qualified domain name)?

Myslíte, že hostname stačí napsat do /etc/hostname ?

Chyba lávky. Je to složitější.

Poté, co jsem jeden stroj s Debian Lenny pojmenoval "backup", připojil na UTB k síti s DHCP a následně celé dopoledne řešil, proč si některé démony myslí, že s hostname je "vega" nebo "vega.utb.cz", podařilo se mi najít toto vysvětlení:

Linux Debian hostname a FQDN

A host is a host. One box, one name.

A network is a network. One network, one name.

Most hosts are only on one network, however, some hosts are on more than one network and would then possibly have more than one FQDN.

The FQDN of the system is the name that the resolver(3) returns for the host name.

The resolver is the code within libc that maps hostnames to IP addresses.

With libc6 (or was it 5), the resolver is configured in /etc/nsswitch.conf. That's Name Service Switch, and has many options.

So what is the correct way of setting the hostname and the FQDN?

Ok. So you've named the computer. You put this hostname (the name up to but not including the network name(s) to which the box is attached), in /etc/hostname.

So now /bin/hostname will give you your hostname. How does

hostname -f

give the FQDN?

It asks the resover what the dommain name is. The resolver consults the /etc/nsswitch.conf file so see where to look. On debian, it tells it that for hosts it should consult files and if it doesn't get an answer, to consult the DNS via a DNS query to the nameserver that is configured with files, in this case /etc/resolv.conf.

So, the first place it will look is in /etc/hosts. It will see, e.g.

192.168.1.5 rocky.hooton rocky

It will see a FQDN and return rocky.hooton to my hostname -f request.

Now, what if you didn't have this host in /etc/hosts? What if the only line was:

127.0.0.1 localhost

?

It would then look in /etc/resolve.conf and see:

nameserver 192.168.1.1

It will then issue a DNS request to 192.168.1.1 asking what the FQDN is for rocky.

It will be told rocky.hooton.

---

So to finally answer your question, you configure your FQDN wherever you want names resovled. If you want it in files on the box itself, then it goes in /etc/hosts. If you run your own name server like I do (I run dnsmasq for simplicity) then you only have to record the information in one place.

I hope this long-winded answer is of some help. For more clarity, I'd suggest __UNIX_System_Administration_Handbook__ by Evi Nemeth, et. al.

Doug.

Co můj problém?

DNS na UTB mělo již pro stroj s názvem backup.utb.cz záznam:

backup:/proc# dig backup.utb.cz

; <<>> DiG 9.6-ESV-R1 <<>> backup.utb.cz
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 37912
;; flags: qr aa rd ra; QUERY: 1, ANSWER: 2, AUTHORITY: 2, ADDITIONAL: 3

;; QUESTION SECTION:
;backup.utb.cz.                 IN      A

;; ANSWER SECTION:
backup.utb.cz.          86400   IN      CNAME   vega.utb.cz.

Jak prosté...