<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
> <channel><title>Comments on: Bash Shell Command to Find or Get IP address</title> <atom:link href="http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/feed/" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/</link> <description>Every answer asks a more beautiful question.</description> <lastBuildDate>Fri, 10 Feb 2012 19:55:56 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Thomas Arend</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-67645</link> <dc:creator>Thomas Arend</dc:creator> <pubDate>Sat, 28 Jan 2012 21:43:48 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-67645</guid> <description>A computer may have multiple network interfaces and therefore more than one ip-address you should try:
/sbin/ifconfig [dev] &#124;  \
sed -n &#039;/inet [Aa]d\{1,2\}resse\{0,1\}:/ { s# *inet [Aa]d\{1,2\}resse\{0,1\}:##; s# .*##p }&#039;
If you omit [dev] this command will give you a list of all IP-address and should work with English and  German localization.
Have a look &lt;a href=&quot;http://byggvir.de/?p=1124&quot; rel=&quot;nofollow&quot;&gt;here&lt;/a&gt; (German page).
&lt;em&gt;hostname -i&lt;/em&gt; is unpredictable in its result and &lt;em&gt;nslookup $(hostname)&lt;/em&gt; will give you only what DNS knows about your machine.</description> <content:encoded><![CDATA[<p>A computer may have multiple network interfaces and therefore more than one ip-address you should try:</p><p>/sbin/ifconfig [dev] |  \<br
/> sed -n &#8216;/inet [Aa]d\{1,2\}resse\{0,1\}:/ { s# *inet [Aa]d\{1,2\}resse\{0,1\}:##; s# .*##p }&#8217;</p><p>If you omit [dev] this command will give you a list of all IP-address and should work with English and  German localization.</p><p>Have a look <a
href="http://byggvir.de/?p=1124" rel="nofollow">here</a> (German page).</p><p><em>hostname -i</em> is unpredictable in its result and <em>nslookup $(hostname)</em> will give you only what DNS knows about your machine.</p> ]]></content:encoded> </item> <item><title>By: shweta</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-66173</link> <dc:creator>shweta</dc:creator> <pubDate>Thu, 29 Dec 2011 11:58:40 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-66173</guid> <description>is there any other option available to get ip address on linux</description> <content:encoded><![CDATA[<p>is there any other option available to get ip address on linux</p> ]]></content:encoded> </item> <item><title>By: Criss</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-64699</link> <dc:creator>Criss</dc:creator> <pubDate>Mon, 21 Nov 2011 23:03:59 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-64699</guid> <description>Work saeed and don`t be a facebook adict</description> <content:encoded><![CDATA[<p>Work saeed and don`t be a facebook adict</p> ]]></content:encoded> </item> <item><title>By: Keith Kyzivat</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-56671</link> <dc:creator>Keith Kyzivat</dc:creator> <pubDate>Sun, 27 Mar 2011 17:51:04 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-56671</guid> <description>Similar approach, but with Awk instead of sed:
time { ifconfig vmnet8 &#124; awk &#039;/inet addr:/ {print substr($2,6)}&#039; ; }
Do some *nix implementations put a space after &#039;addr:&#039; ?  If so, this will break in those cases.</description> <content:encoded><![CDATA[<p>Similar approach, but with Awk instead of sed:</p><p>time { ifconfig vmnet8 | awk &#8216;/inet addr:/ {print substr($2,6)}&#8217; ; }</p><p>Do some *nix implementations put a space after &#8216;addr:&#8217; ?  If so, this will break in those cases.</p> ]]></content:encoded> </item> <item><title>By: Adi</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-54487</link> <dc:creator>Adi</dc:creator> <pubDate>Tue, 04 Jan 2011 12:17:47 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-54487</guid> <description>To find the ip address of Unix box from Unix prompt:
nslookup </description> <content:encoded><![CDATA[<p>To find the ip address of Unix box from Unix prompt:</p><p>nslookup</p> ]]></content:encoded> </item> <item><title>By: radha</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-53224</link> <dc:creator>radha</dc:creator> <pubDate>Wed, 22 Dec 2010 07:19:52 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-53224</guid> <description>ifconfig -a  (now this works for Solaris 10)</description> <content:encoded><![CDATA[<p>ifconfig -a  (now this works for Solaris 10)</p> ]]></content:encoded> </item> <item><title>By: Henrique</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-51102</link> <dc:creator>Henrique</dc:creator> <pubDate>Wed, 24 Nov 2010 19:44:39 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-51102</guid> <description>Simples...
Work For me (Debian Lenny 5.0)
# ifconfig eth0 &#124; grep inet &#124; grep -v &quot;inet6&quot; &#124; awk {&#039;print $3&#039;}</description> <content:encoded><![CDATA[<p>Simples&#8230;<br
/> Work For me (Debian Lenny 5.0)<br
/> # ifconfig eth0 | grep inet | grep -v &#8220;inet6&#8243; | awk {&#8216;print $3&#8242;}</p> ]]></content:encoded> </item> <item><title>By: Sandeep</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-49826</link> <dc:creator>Sandeep</dc:creator> <pubDate>Thu, 30 Sep 2010 10:59:40 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-49826</guid> <description>Hi Award
Excellent command to find the originating IP addresss
hostname -i
Thanks!!</description> <content:encoded><![CDATA[<p>Hi Award</p><p>Excellent command to find the originating IP addresss<br
/> hostname -i</p><p>Thanks!!</p> ]]></content:encoded> </item> <item><title>By: award</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-49708</link> <dc:creator>award</dc:creator> <pubDate>Fri, 24 Sep 2010 16:07:29 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-49708</guid> <description>Hi,
in case someone still interested, i think easiest way to get local ip address is:
hostname -I  (capital i)
this will return just the ip address with nothing else.
To get my external ip address (without use dyndns, noip &amp; c) i use in a script:
&lt;pre&gt;wget www.whatismyip.com/automation/n09230945.asp -O /tmp/ip.txt -o /dev/null&lt;/pre&gt;
This will write to /tmp/ip.txt my external ip and then i upload the text file with curl
to a directory on my web page
&lt;pre&gt;
#!/bin/bash
wget www.whatismyip.com/automation/n09230945.asp -O /tmp/ip.txt -o /dev/null
extip=`cat /tmp/ip.txt`
echo &quot;$extip&quot; &gt; /tmp/ip.txt
hostname -I &gt; /tmp/intip.txt
exit 0
&lt;/pre&gt;
Bye
Award
------------------
C u in /dev/null</description> <content:encoded><![CDATA[<p>Hi,<br
/> in case someone still interested, i think easiest way to get local ip address is:<br
/> hostname -I  (capital i)<br
/> this will return just the ip address with nothing else.</p><p>To get my external ip address (without use dyndns, noip &amp; c) i use in a script:</p><pre>wget <a href="http://www.whatismyip.com/automation/n09230945.asp" rel="nofollow">http://www.whatismyip.com/automation/n09230945.asp</a> -O /tmp/ip.txt -o /dev/null</pre><p>This will write to /tmp/ip.txt my external ip and then i upload the text file with curl<br
/> to a directory on my web page</p><pre>
#!/bin/bash
wget <a href="http://www.whatismyip.com/automation/n09230945.asp" rel="nofollow">http://www.whatismyip.com/automation/n09230945.asp</a> -O /tmp/ip.txt -o /dev/null
extip=`cat /tmp/ip.txt`
echo "$extip" &gt; /tmp/ip.txt
hostname -I &gt; /tmp/intip.txt
exit 0
</pre><p>Bye<br
/> Award<br
/> &#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<br
/> C u in /dev/null</p> ]]></content:encoded> </item> <item><title>By: Alejandro Smith</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-49503</link> <dc:creator>Alejandro Smith</dc:creator> <pubDate>Mon, 13 Sep 2010 14:51:26 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-49503</guid> <description>Excellent info on that.. thanks for updating this. That&#039;s true, fewer processes translates into a faster execution.
Two years ago when i first posted on this faq with a &quot;solution&quot;, i was a new linux user, and i did not had any experience on this. I read some good information on bash scripting and came out with this solution for a problem i was having at that time.
I didn&#039;t care back then if it was faster than other solutions, i just needed to solve the issue.. ;-) but of course, YOU are completely right with your point of view.
Thank you all for sharing your knowledge on this.
God bless you all.</description> <content:encoded><![CDATA[<p>Excellent info on that.. thanks for updating this. That&#8217;s true, fewer processes translates into a faster execution.</p><p>Two years ago when i first posted on this faq with a &#8220;solution&#8221;, i was a new linux user, and i did not had any experience on this. I read some good information on bash scripting and came out with this solution for a problem i was having at that time.</p><p>I didn&#8217;t care back then if it was faster than other solutions, i just needed to solve the issue.. ;-) but of course, YOU are completely right with your point of view.</p><p>Thank you all for sharing your knowledge on this.</p><p>God bless you all.</p> ]]></content:encoded> </item> <item><title>By: mrG</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-49500</link> <dc:creator>mrG</dc:creator> <pubDate>Mon, 13 Sep 2010 14:03:02 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-49500</guid> <description>brill score!  well done.</description> <content:encoded><![CDATA[<p>brill score!  well done.</p> ]]></content:encoded> </item> <item><title>By: /dev/movebo</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-49492</link> <dc:creator>/dev/movebo</dc:creator> <pubDate>Sun, 12 Sep 2010 22:09:41 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-49492</guid> <description>@wuhaa @Alejandro\ Smith
Personally I prefer this version:
&lt;code&gt;$ /sbin/ifconfig eth0 &#124; sed &#039;/inet\ /!d;s/.*r://g;s/\ .*//g&#039; &lt;/code&gt;
Why, you may ask. Because of this:
&lt;code&gt;
$ time { /sbin/ifconfig  eth0&#124;grep &quot;inet addr:&quot;&#124;awk &#039;{print $2}&#039;&#124;awk -F : &#039;{print $2}&#039; ; }
192.168.1.8
real	0m0.027s
user	0m0.013s
sys	0m0.003s
$ time { /sbin/ifconfig eth0 &#124; grep inet &#124; awk &#039;{print $2}&#039; &#124; sed &#039;s/addr://&#039; &#124; grep . ; }
192.168.1.8
real	0m0.009s
user	0m0.011s
sys	0m0.010s
$ time { /sbin/ifconfig eth0 &#124; sed &#039;/inet\ /!d;s/.*r://g;s/\ .*//g&#039; ; }
192.168.1.8
real	0m0.005s
user	0m0.005s
sys	0m0.004s
&lt;/code&gt;
The fewer processes, the faster the execution.</description> <content:encoded><![CDATA[<p>@wuhaa @Alejandro\ Smith</p><p>Personally I prefer this version:<br
/> <code>$ /sbin/ifconfig eth0 | sed '/inet\ /!d;s/.*r://g;s/\ .*//g' </code></p><p>Why, you may ask. Because of this:<br
/> <code><br
/> $ time { /sbin/ifconfig  eth0|grep "inet addr:"|awk '{print $2}'|awk -F : '{print $2}' ; }<br
/> 192.168.1.8</p><p>real	0m0.027s<br
/> user	0m0.013s<br
/> sys	0m0.003s</p><p>$ time { /sbin/ifconfig eth0 | grep inet | awk '{print $2}' | sed 's/addr://' | grep . ; }<br
/> 192.168.1.8</p><p>real	0m0.009s<br
/> user	0m0.011s<br
/> sys	0m0.010s</p><p>$ time { /sbin/ifconfig eth0 | sed '/inet\ /!d;s/.*r://g;s/\ .*//g' ; }<br
/> 192.168.1.8</p><p>real	0m0.005s<br
/> user	0m0.005s<br
/> sys	0m0.004s</p><p></code></p><p>The fewer processes, the faster the execution.</p> ]]></content:encoded> </item> <item><title>By: mrG</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-48141</link> <dc:creator>mrG</dc:creator> <pubDate>Tue, 29 Jun 2010 22:15:30 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-48141</guid> <description>IP=`who -m --ips &#124; awk &#039;{print $6}&#039;`</description> <content:encoded><![CDATA[<p>IP=`who -m &#8211;ips | awk &#8216;{print $6}&#8217;`</p> ]]></content:encoded> </item> <item><title>By: Mike Godin</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-47693</link> <dc:creator>Mike Godin</dc:creator> <pubDate>Tue, 08 Jun 2010 16:09:36 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-47693</guid> <description>I like to use the simple and concise:
host $(hostname) &#124; sed &#039;s/.*has address //g&#039;
It simply returns the IP address that the rest of the world sees for your machine.</description> <content:encoded><![CDATA[<p>I like to use the simple and concise:<br
/> host $(hostname) | sed &#8216;s/.*has address //g&#8217;</p><p>It simply returns the IP address that the rest of the world sees for your machine.</p> ]]></content:encoded> </item> <item><title>By: wuhaa</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-45380</link> <dc:creator>wuhaa</dc:creator> <pubDate>Thu, 31 Dec 2009 16:44:09 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-45380</guid> <description>This one I have used on my Ubunut 9.04 system
&lt;code&gt;# ifconfig eth0&#124;grep &quot;inet addr:&quot;&#124;awk &#039;{print $2}&#039;&#124;awk -F : &#039;{print $2}&#039;&lt;/code&gt;</description> <content:encoded><![CDATA[<p>This one I have used on my Ubunut 9.04 system</p><p><code># ifconfig eth0|grep "inet addr:"|awk '{print $2}'|awk -F : '{print $2}'</code></p> ]]></content:encoded> </item> <item><title>By: Dave</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-44937</link> <dc:creator>Dave</dc:creator> <pubDate>Sat, 28 Nov 2009 09:55:15 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-44937</guid> <description>ifconfig eth0 &#124; grep inet &#124; sed -n &quot;s/^\s*inet addr://p&quot; &#124; awk &#039;{ print $1 }&#039;
works on my system</description> <content:encoded><![CDATA[<p>ifconfig eth0 | grep inet | sed -n &#8220;s/^\s*inet addr://p&#8221; | awk &#8216;{ print $1 }&#8217;</p><p>works on my system</p> ]]></content:encoded> </item> <item><title>By: Bijoy Meethal</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-41821</link> <dc:creator>Bijoy Meethal</dc:creator> <pubDate>Thu, 28 May 2009 12:13:11 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-41821</guid> <description>Kishore , go to Terminal, and say &#039;ping yahoo.com&#039;</description> <content:encoded><![CDATA[<p>Kishore , go to Terminal, and say &#8216;ping yahoo.com&#8217;</p> ]]></content:encoded> </item> <item><title>By: vyagh</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-40548</link> <dc:creator>vyagh</dc:creator> <pubDate>Mon, 02 Mar 2009 10:47:11 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-40548</guid> <description>Hi
we have server configured on Linux.
Is there any way to get the IP Address of the client which is conncetd to that server.</description> <content:encoded><![CDATA[<p>Hi<br
/> we have server configured on Linux.<br
/> Is there any way to get the IP Address of the client which is conncetd to that server.</p> ]]></content:encoded> </item> <item><title>By: kishore</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-40248</link> <dc:creator>kishore</dc:creator> <pubDate>Thu, 12 Feb 2009 04:18:15 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-40248</guid> <description>how to find the ip address of an website in linux</description> <content:encoded><![CDATA[<p>how to find the ip address of an website in linux</p> ]]></content:encoded> </item> <item><title>By: Bill Gates</title><link>http://www.cyberciti.biz/faq/bash-shell-command-to-find-get-ip-address/#comment-39924</link> <dc:creator>Bill Gates</dc:creator> <pubDate>Mon, 19 Jan 2009 07:12:26 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/faq/faq/bash-shell-command-to-findget-ip-address.php#comment-39924</guid> <description>oops.. Watch out for the way this thread/forum  alters the matching Quote to the single and double qupte   if you cut and paste the examples.   ie:
single Quotes    &#039;hello&#039;
double quotes  &quot;hello&quot;
back ticks `hello`
I had to manually alter the lines after i pasted them to use proper quoteing.</description> <content:encoded><![CDATA[<p>oops.. Watch out for the way this thread/forum  alters the matching Quote to the single and double qupte   if you cut and paste the examples.   ie:</p><p>single Quotes    &#8216;hello&#8217;</p><p>double quotes  &#8220;hello&#8221;</p><p>back ticks `hello`</p><p>I had to manually alter the lines after i pasted them to use proper quoteing.</p> ]]></content:encoded> </item> </channel> </rss>
