Sunday, March 29, 2020

Unix Dominance To Discovery Ip Address From Hostname - Linux Example

IP address from hostname inwards UNIX
In this Unix ascendency tutorial, nosotros volition encounter How to discovery IP address of whatever host inwards a UNIX based system e.g. Linux, Solaris or IBM AIX. In full general hostname as well as IP address are 2 of import things nearly whatever host inwards a UNIX based network.  You ever demand either hostname or IP address to connect to whatever host. Some fourth dimension you lot desire to discovery IP address of localhost, exactly about fourth dimension IP address of exactly about other host on network etc. We convey shown exactly about techniques to find IP address from hostname inwards UNIX as well as hither nosotros volition encounter is especial listing of UNIX commands to larn IP address of localhost or host on which you lot are working along amongst whatever other host for which nosotros know hostname. 


List of UNIX ascendency to discovery IP address from hostname

Here is listing of UNIX command which tin dismiss last used to discovery IP address :

ifconfig
nslookup
hostname

ifconfig ascendency example
Let's encounter event of ifconfig ascendency to find IP address of localhost on which you lot are working :
ifconfig ascendency shows lot of information nearly diverse NIC cards inwards system, you lot tin dismiss cheque either for "inet" or "inet addr" for seeing IP address to respective NIC cards :



# /usr/sbin/ifconfig -a
inet 192.52.32.15 netmask ffffff00 broadcast 192.52.32.255

As I said ifconfig ascendency shows lot of details but I convey solely included relevant inet one, if you lot convey to a greater extent than than ane network carte du jour attached to that host, you lot may encounter to a greater extent than than ane inet address corresponding to each of them. Main drawback of ifconfig ascendency inwards UNIX is that you lot tin dismiss solely larn IP address of localhost from this command, you lot tin dismiss non larn IP address of whatever other host.

grep as well as hostname example
You tin dismiss combine grep command as well as hostname to expect IP address from /etc/hosts file. hither `hostname` volition render output of hostname ascendency as well as non bad volition hence search for that give-and-take inwards /etc/hostname. practise goodness of using `hostname` is that you lot tin dismiss exactly re-create as well as run this ascendency on whatever host without typing hostname past times yourself. This is ane of many non bad usage of grep inwards UNIX, encounter 10 ways to purpose grep ascendency inwards UNIX to discovery out why grep is ane of the most useful ascendency inwards UNIX.

# grep `hostname` /etc/hosts
192.52.32.15     nyk4035        nyk4035.unix.com

ping ascendency example
How to discovery IP address of whatever host inwards a UNIX based organization Unix ascendency to discovery IP address from hostname - Linux exampleOur patently quondam ping ascendency tin dismiss too last used to discovery IP address of localhost or whatever other host provided you lot know the hostname. ping is used to cheque wither target server is last or non but piece using amongst selection -s it too display IP address of corresponding host every bit well. Ping is genuinely ane of the of 10 useful networking ascendency inwards UNIX , encounter that link for other commands.

# ping -s `hostname`
PING nyk4035: 56 information bytes
64 bytes from nyk4035 (192.52.32.15): icmp_seq=0. time=0.186 ms

nslookup ascendency example
nslookup is ane of the principal UNIX ascendency to find IP address from hostname as well as in ane trial again from hostname to IP address. Similar to ping you lot tin dismiss too purpose nslookup ascendency to discovery IP address of both local host as well as remote host inwards whatever UNIX based system. nslookup is by as well as large available inwards most of UNIX based organization e.g. Linux, Solaris, IBM AIX or whatever other UNIX system.

# nslookup `hostname`
nyk4035.unix.com       canonical mention = nyk4035.unix.com
Name:   nyk4035.unix.com
Address: 192.52.32.15

That's all on How to discovery IP address inwards UNIX , Linux as well as other UNIX based system e.g. Solaris, IBM AIX, BSD etc. We convey seen examples of getting IP address from hostname past times using ipconfig, ping, hostname as well as nslookup command. If ane ascendency is non working inwards your machine you lot tin dismiss ever purpose other ascendency or you lot tin dismiss only cross cheque IP address past times using multiple UNIX commands.

Further Learning
Linux Command Line Basics
10 chmod ascendency event inwards UNIX as well as Linux

No comments:

Post a Comment