How Hostname To Ip Address Conversion Or Lift Resolution Industrial Plant Inwards Linux?

One of my favorite Linux Interview questions is near how to convert hostname to IP address inward Linux? This questions non merely attempt out candidate's basic Linux ascendancy skills but equally good shows his agreement of how refer resolution plant inward UNIX or Linux? Many developers, software engineers, as well as back upward professional person don't actually know how Linux converts an hostname into IP address or what happens when they type http://www.amazon.com inward their browser inward UNIX? They are non actually familiar amongst how the refer amazon.com is resolved to an IP address. Since network application entirely plant amongst IP address as well as names are for us humans, who notice it easier to retrieve a refer than IP address, it makes feel to empathize how this refer resolution happens. Sometimes, this enquiry equally good asks equally for how nslookup or host ascendancy works, which are ii of the pop ascendancy to convert hostname to IP address.

There are several key files which play business office inward refer resolution but the journeying starts from the file /etc/nsswitch.conf file or the /etc/host.conf inward pre-glibc2 systems. When a user types http://www.amazon.com inward the address bar of the browser as well as presses the acquire inward button, the organization needs to resolve this hostname to an IP address to brand the connection.

It showtime consults the /etc/nsswitch.conf file to create upward one's heed which subsystems to enquire as well as inward what enterprise to resolve this hostname. The file contains lookup enterprise for many network related setup e.g. password, shadow passwords, groups, hosts, aliases etc.



The default entry for hosts inward this file expect similar this:

hosts: files dns nis

Which agency showtime piece of job the local files e.g. /etc/hosts for refer resolution as well as if non institute piece of job DNS (domain refer resolution) as well as if non able to resolve at that topographic point as well as hence in conclusion piece of job Network information server (NIS) inward the same order. For pocket-size person network merely file lookup is plenty but for most of the medium to large networks, DNS as well as NIS is used to resolve the hostname to IP address.

Now, Linux volition search for the hostname inward /etc/hosts file as well as if institute at that topographic point it volition provide the IP address to brand the connection. The /etc/hosts commonly incorporate a twain of entries equally shown below:

$ truthful cat /etc/hosts 127.0.0.1       localhost ::1     localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 172.17.1.43     63d51553371a

If the hostname is non institute inward this file as well as hence Linux consults to DNS for refer resolution.



In enterprise to connect to DNS, it needs something called nameservers as well as for that it lookup on the /etc/resolve.conf file. This file contains a twain of nameservers for consultation e.g.

$ truthful cat /etc/resolv.conf # Dynamic resolv.conf(5) file for glibc resolver(3) generated past times resolvconf(8) #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN nameserver 10.0.0.2 nameserver 192.168.10.15 nameserver 192.168.250.20

Influenza A virus subtype H5N1 utility similar nslookup volition showtime consult to the primary DNS server, the showtime server inward the /etc/resolv.conf file. Influenza A virus subtype H5N1 DNS asking is made to the primary DNS server. If a response is received i.e. the IP address of hostname is received as well as hence the same address is used to brand the HTTP request.

If no response is received, either because the DNS server did non convey a mapping for the hostname or the DNS server is downward or did non response to the request, as well as hence the side past times side nameserver listed inward the /etc/resolv.conf is consulted. This procedure repeats until all refer servers convey been consulted.

 One of my favorite Linux Interview questions is near  How hostname to IP address Conversion or Name Resolution plant inward Linux?


On a side note, the enterprise is real of import inward /etc/resolv.conf. I retrieve 1 instance when nosotros had the wrong hostname to IP address mapping inward 1 refer server but right inward other but because the faulty refer server was the showtime listed inward /etc/resolv.conf, it is the 1 which is consulted first, resulting inward wrong IP address resolution. The number was solved tactically past times merely changing the enterprise of server until mapping inward faulty refer server is corrected.

If refer resolution failed at refer servers as well as hence in conclusion NIS is consulted as well as if at that topographic point equally good Linux non able to notice a corresponding IP address for a given hostname as well as hence the spider web browser volition provide an error. The same machinery is used amongst whatsoever refer resolution utility e.g. nslookup.

As a Programmer, Developer or Support professional, it's of import to last familiar amongst fundamentals similar this because they assistance a lot spell troubleshooting. The importance of /etc/hosts cannot last ignored because commonly it is the showtime file which is consulted as well as that's why yous ever institute the localhost to IP address 127.0.0.1 mapping here. Never delete this file equally many programs including Java ones depository fiscal establishment check this file for localhost refer resolution. Some systems e.g. pre-glibc2 the /etc/host.conf is consulted inward house of /etc/nsswitch.conf file.


So, right away yous know how hostname is resolved to IP address inward Linux. This whole procedure is equally good known equally refer resolution as well as it is 1 of the of import concepts to larn from Linux Interview indicate of view. If yous are interested inward learning Linus fundamentals similar this I advise yous reading How Linux works, it's amount of such of import details which brand a uncomplicated Linux user to a Super User :-)

 One of my favorite Linux Interview questions is near  How hostname to IP address Conversion or Name Resolution plant inward Linux?


Further Learning
Linux Command Line Basics
10 Essential Networking Commands for Linux Users
  • Top xv Linux Interview Questions amongst Answers
  • 10 Examples of lsof ascendancy inward Linux
  • 10 Example of tar commands inward Unix
  • 5 Example of kill commands inward Unix as well as Linux
  • VI Editor examples as well as tips for beginners
  • The Linux Command Line: Influenza A virus subtype H5N1 Complete Introduction

  • Thank yous for reading this article, if yous actually similar this article as well as hence delight percentage amongst your friends as well as collegues as well as if yous convey whatsoever proposition or feedback as well as hence delight percentage amongst us past times dropping comments. If yous merely desire to larn to a greater extent than near Linux fundamentals, merely acquire as well as read, How Linux works

    Sumber https://javarevisited.blogspot.com/

    0 Response to "How Hostname To Ip Address Conversion Or Lift Resolution Industrial Plant Inwards Linux?"

    Post a Comment

    Iklan Atas Artikel

    Iklan Tengah Artikel 1

    Iklan Tengah Artikel 2

    Iklan Bawah Artikel