<?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: Read UNIX / Linux System IP Address In a Shell Script</title> <atom:link href="http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html/feed" rel="self" type="application/rss+xml" /><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html</link> <description>This is a Linux sys admin journal by Vivek about sys admin work, Linux tips &#38; tricks, hacks, news and more.</description> <lastBuildDate>Fri, 10 Feb 2012 20:37:43 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <item><title>By: Gaveen</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-171906</link> <dc:creator>Gaveen</dc:creator> <pubDate>Mon, 13 Jun 2011 11:59:19 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-171906</guid> <description>Or you could run:
hostname -I</description> <content:encoded><![CDATA[<p>Or you could run:</p><p>hostname -I</p> ]]></content:encoded> </item> <item><title>By: Chris Browne</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-171794</link> <dc:creator>Chris Browne</dc:creator> <pubDate>Wed, 08 Jun 2011 09:24:58 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-171794</guid> <description>Yeah, because lynx/curl execute the returned website.  That&#039;s how they work.  Didn&#039;t you know?  They take what whatsmyip.org respond with, pass it into a system() call and it gets executed.  Yup.  And when you&#039;re executing lynx as your user (which nobody suggested to do otherwise) rm -rf / is still able to wipe out your hard drive, because well... linux just doesn&#039;t have a permissions system.
ifconfig on the other hand, an administrator&#039;s tool which sends a lot of information about your network interfaces to your shell, potentially sending the result in an email if the script is run from cron; well, that&#039;s just brilliant.  So much more secure.  I&#039;d definitely recommend using ifconfig.  Yup.  Blast a load of intimate hardware details across SMTP, way more secure than fetching a HTML response from a web server that contains nothing but your IP address.
Seriously, though, if you&#039;re gonna get angry at people for lax security practices at least have a clue what you&#039;re talking about first.</description> <content:encoded><![CDATA[<p>Yeah, because lynx/curl execute the returned website.  That&#8217;s how they work.  Didn&#8217;t you know?  They take what whatsmyip.org respond with, pass it into a system() call and it gets executed.  Yup.  And when you&#8217;re executing lynx as your user (which nobody suggested to do otherwise) rm -rf / is still able to wipe out your hard drive, because well&#8230; linux just doesn&#8217;t have a permissions system.</p><p>ifconfig on the other hand, an administrator&#8217;s tool which sends a lot of information about your network interfaces to your shell, potentially sending the result in an email if the script is run from cron; well, that&#8217;s just brilliant.  So much more secure.  I&#8217;d definitely recommend using ifconfig.  Yup.  Blast a load of intimate hardware details across SMTP, way more secure than fetching a HTML response from a web server that contains nothing but your IP address.</p><p>Seriously, though, if you&#8217;re gonna get angry at people for lax security practices at least have a clue what you&#8217;re talking about first.</p> ]]></content:encoded> </item> <item><title>By: Danny Walker</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-171290</link> <dc:creator>Danny Walker</dc:creator> <pubDate>Fri, 13 May 2011 00:39:25 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-171290</guid> <description>You can also do it in cygwin (you have to use Microsoft&#039;s ipconfig command):
ipconfig &#124; grep &#039;IP Address&#039; &#124; grep -v 0.0.0.0 &#124; awk &#039;{ print $15}&#039;
($15 signifies the 15th word - the dots are words too!)
Therefore, to mimic cygwin&#039;s default prompt, use:
export PS1=&quot;\[\e]0;\w\a\]\n\[\e[32m\]\u@`ipconfig &#124; grep &#039;IP Address&#039; &#124; grep -v 0.0.0.0 &#124; awk &#039;{ print $15}&#039;` \[\e[33m\]\w\[\e[0m\]\n\$&quot;
This work for me, but it&#039;s a bit system specific. For example, if you have additional network interfaces, you may have to grep -v any others that might be returned.
Dan</description> <content:encoded><![CDATA[<p>You can also do it in cygwin (you have to use Microsoft&#8217;s ipconfig command):</p><p>ipconfig | grep &#8216;IP Address&#8217; | grep -v 0.0.0.0 | awk &#8216;{ print $15}&#8217;<br
/> ($15 signifies the 15th word &#8211; the dots are words too!)</p><p>Therefore, to mimic cygwin&#8217;s default prompt, use:</p><p>export PS1=&#8221;\[\e]0;\w\a\]\n\[\e[32m\]\u@`ipconfig | grep &#8216;IP Address&#8217; | grep -v 0.0.0.0 | awk &#8216;{ print $15}&#8217;` \[\e[33m\]\w\[\e[0m\]\n\$&#8221;</p><p>This work for me, but it&#8217;s a bit system specific. For example, if you have additional network interfaces, you may have to grep -v any others that might be returned.</p><p>Dan</p> ]]></content:encoded> </item> <item><title>By: vio</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-170898</link> <dc:creator>vio</dc:creator> <pubDate>Mon, 25 Apr 2011 11:33:05 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-170898</guid> <description>hostname -I</description> <content:encoded><![CDATA[<p>hostname -I</p> ]]></content:encoded> </item> <item><title>By: ulysses768</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-168927</link> <dc:creator>ulysses768</dc:creator> <pubDate>Mon, 21 Feb 2011 15:59:22 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-168927</guid> <description>This can be done exclusively in bash, if you&#039;re interested in shaving a ms or two.
IP=`ifconfig`
IP=${IP#*inet addr:}
IP=${IP%% *}</description> <content:encoded><![CDATA[<p>This can be done exclusively in bash, if you&#8217;re interested in shaving a ms or two.<br
/> IP=`ifconfig`<br
/> IP=${IP#*inet addr:}<br
/> IP=${IP%% *}</p> ]]></content:encoded> </item> <item><title>By: neha kamra</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-158973</link> <dc:creator>neha kamra</dc:creator> <pubDate>Tue, 17 Aug 2010 05:59:12 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-158973</guid> <description>Hi
Can anyone send me the simple script with explanation to find the ip address...as i am new to this
thanx</description> <content:encoded><![CDATA[<p>Hi</p><p>Can anyone send me the simple script with explanation to find the ip address&#8230;as i am new to this</p><p>thanx</p> ]]></content:encoded> </item> <item><title>By: foo bar</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-152978</link> <dc:creator>foo bar</dc:creator> <pubDate>Mon, 18 Jan 2010 12:50:40 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-152978</guid> <description>OMFG, guys, please, you *do* realize anybody can hack into whatismyip.org and INSTANTLY gain access to your boxes ?!!!! And you&#039;re not even using HTTPS - so any monkey in the middle can 0wn your boxes too !!!!
Are you dumb enough to run those lynx/curl scripts as root as well ???
NEVER EVER put this much trust into 3rd party systems, or you WILL get screwed !
it would be funny watching you after whatismyip.org returns `rm -rf /`
use ifconfig / ip show... and don&#039;t be so freaking lazy</description> <content:encoded><![CDATA[<p>OMFG, guys, please, you *do* realize anybody can hack into whatismyip.org and INSTANTLY gain access to your boxes ?!!!! And you&#8217;re not even using HTTPS &#8211; so any monkey in the middle can 0wn your boxes too !!!!<br
/> Are you dumb enough to run those lynx/curl scripts as root as well ???</p><p>NEVER EVER put this much trust into 3rd party systems, or you WILL get screwed !</p><p>it would be funny watching you after whatismyip.org returns `rm -rf /`</p><p>use ifconfig / ip show&#8230; and don&#8217;t be so freaking lazy</p> ]]></content:encoded> </item> <item><title>By: Marko Rauhamaa</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-151829</link> <dc:creator>Marko Rauhamaa</dc:creator> <pubDate>Tue, 24 Nov 2009 10:03:21 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-151829</guid> <description>On linux:
hostname -i</description> <content:encoded><![CDATA[<p>On linux:</p><p> hostname -i</p> ]]></content:encoded> </item> <item><title>By: Mika Marttila</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-150989</link> <dc:creator>Mika Marttila</dc:creator> <pubDate>Thu, 08 Oct 2009 14:14:42 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-150989</guid> <description>Thanks! My virtual Ubuntu server is having problems keeping the same IP from DHCP. I need it to start bind my Django app for whole network so this tip came in handy.</description> <content:encoded><![CDATA[<p>Thanks! My virtual Ubuntu server is having problems keeping the same IP from DHCP. I need it to start bind my Django app for whole network so this tip came in handy.</p> ]]></content:encoded> </item> <item><title>By: Aaron Kushner</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-148547</link> <dc:creator>Aaron Kushner</dc:creator> <pubDate>Wed, 13 May 2009 21:37:04 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-148547</guid> <description>@mohan, you can have multiple separators and not have to rerun awk.
@paul, do you like yours because it has a sed abomination in it? Make it simple!
ifconfig eth0 &#124; awk -F&quot;[: ]+&quot; &#039;NR==2 {print $4}&#039;</description> <content:encoded><![CDATA[<p>@mohan, you can have multiple separators and not have to rerun awk.<br
/> @paul, do you like yours because it has a sed abomination in it? Make it simple!</p><p>ifconfig eth0 | awk -F&#8221;[: ]+&#8221; &#8216;NR==2 {print $4}&#8217;</p> ]]></content:encoded> </item> <item><title>By: Paul Colby</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-147116</link> <dc:creator>Paul Colby</dc:creator> <pubDate>Tue, 10 Feb 2009 07:01:20 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-147116</guid> <description>My current favourite:
&lt;code&gt;ifconfig &#124; sed -n -e &#039;s/:127\.0\.0\.1 //g&#039; -e &#039;s/ *inet addr:\([0-9.]\+\).*/\1/gp&#039;&lt;/code&gt;
;)</description> <content:encoded><![CDATA[<p>My current favourite:<br
/> <code>ifconfig | sed -n -e 's/:127\.0\.0\.1 //g' -e 's/ *inet addr:\([0-9.]\+\).*/\1/gp'</code></p><p>;)</p> ]]></content:encoded> </item> <item><title>By: PC Thoughts</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-147115</link> <dc:creator>PC Thoughts</dc:creator> <pubDate>Tue, 10 Feb 2009 06:53:16 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-147115</guid> <description>&lt;strong&gt;Finding the local IP address with ifconfig and sed...&lt;/strong&gt;
There are many ways to determine local IP addresses on Linux platforms.  The almost always involve piping ifconfig into a number of grep, awk, cat, and/or tr commands.
Well, my new favorite approach is to pipe ifconfig into a single sed command :)
if...</description> <content:encoded><![CDATA[<p><strong>Finding the local IP address with ifconfig and sed&#8230;</strong></p><p>There are many ways to determine local IP addresses on Linux platforms.  The almost always involve piping ifconfig into a number of grep, awk, cat, and/or tr commands.</p><p>Well, my new favorite approach is to pipe ifconfig into a single sed command :)<br
/> if&#8230;</p> ]]></content:encoded> </item> <item><title>By: Alan Haggai Alavi</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-145730</link> <dc:creator>Alan Haggai Alavi</dc:creator> <pubDate>Wed, 26 Nov 2008 14:16:30 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-145730</guid> <description>&lt;code&gt;curl whatismyip.org&lt;/code&gt; does the same too. No need of extra parametres. :-)</description> <content:encoded><![CDATA[<p><code>curl whatismyip.org</code> does the same too. No need of extra parametres. :-)</p> ]]></content:encoded> </item> <item><title>By: Mohan</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-143028</link> <dc:creator>Mohan</dc:creator> <pubDate>Wed, 27 Feb 2008 14:33:46 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-143028</guid> <description>This should do the work
ifconfig eth0&#124; awk &#039;NR==2 {print $2}&#039;&#124; awk -F: &#039;{print $2}&#039;</description> <content:encoded><![CDATA[<p>This should do the work</p><p>ifconfig eth0| awk &#8216;NR==2 {print $2}&#8217;| awk -F: &#8216;{print $2}&#8217;</p> ]]></content:encoded> </item> <item><title>By: Oscar</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-142745</link> <dc:creator>Oscar</dc:creator> <pubDate>Fri, 01 Feb 2008 21:42:56 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-142745</guid> <description>@the suggestion of using whatsmyip.
That is a great idea, but if you&#039;re looking to find your ip address on a box that has no internet access then that would not work and the original script(s) should always work. If you&#039;re on a private lan for example with no web access then you can&#039;t see whatsmyip, or ipchicken, etc.
This quick how-to is not so much on how to find  your external IP address, but more on the actual address your system has been assigned either DHCP, or statically.</description> <content:encoded><![CDATA[<p>@the suggestion of using whatsmyip.</p><p>That is a great idea, but if you&#8217;re looking to find your ip address on a box that has no internet access then that would not work and the original script(s) should always work. If you&#8217;re on a private lan for example with no web access then you can&#8217;t see whatsmyip, or ipchicken, etc.</p><p>This quick how-to is not so much on how to find  your external IP address, but more on the actual address your system has been assigned either DHCP, or statically.</p> ]]></content:encoded> </item> <item><title>By: igor</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-142712</link> <dc:creator>igor</dc:creator> <pubDate>Wed, 30 Jan 2008 18:18:29 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-142712</guid> <description>if you use a different locale, consider this version for linux:
LC_ALL=C ifconfig  &#124; grep &#039;inet addr:&#039;&#124; grep -v &#039;127.0.0.1&#039; &#124; cut -d: -f2 &#124; awk &#039;{ print $1}&#039;</description> <content:encoded><![CDATA[<p>if you use a different locale, consider this version for linux:</p><p>LC_ALL=C ifconfig  | grep &#8216;inet addr:&#8217;| grep -v &#8217;127.0.0.1&#8242; | cut -d: -f2 | awk &#8216;{ print $1}&#8217;</p> ]]></content:encoded> </item> <item><title>By: lex</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-142538</link> <dc:creator>lex</dc:creator> <pubDate>Fri, 18 Jan 2008 22:36:23 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-142538</guid> <description>@Clue
no. for as far as I know you&#039;ll always need some external server to &#039;see&#039; who you are.
But if someone knows another way to do this,  the n please let me know.</description> <content:encoded><![CDATA[<p>@Clue<br
/> no. for as far as I know you&#8217;ll always need some external server to &#8216;see&#8217; who you are.<br
/> But if someone knows another way to do this,  the n please let me know.</p> ]]></content:encoded> </item> <item><title>By: TJB</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-142502</link> <dc:creator>TJB</dc:creator> <pubDate>Wed, 16 Jan 2008 18:41:08 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-142502</guid> <description>Dude, you just saved me 15 minutes of relearning awk and the like just to pull out the IP addy. Double thanks!</description> <content:encoded><![CDATA[<p>Dude, you just saved me 15 minutes of relearning awk and the like just to pull out the IP addy. Double thanks!</p> ]]></content:encoded> </item> <item><title>By: Clue</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-142196</link> <dc:creator>Clue</dc:creator> <pubDate>Tue, 18 Dec 2007 00:52:41 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-142196</guid> <description>Hi there,
I&#039;m new to all this and I was wondering, how do those websites get our IP and is there not a shell script that can be written to find out your public IP depending on your private IP without having to use these external websites?</description> <content:encoded><![CDATA[<p>Hi there,</p><p>I&#8217;m new to all this and I was wondering, how do those websites get our IP and is there not a shell script that can be written to find out your public IP depending on your private IP without having to use these external websites?</p> ]]></content:encoded> </item> <item><title>By: Michael Gauthier</title><link>http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-19450</link> <dc:creator>Michael Gauthier</dc:creator> <pubDate>Thu, 15 Jun 2006 03:24:00 +0000</pubDate> <guid
isPermaLink="false">http://www.cyberciti.biz/tips/read-unixlinux-system-ip-address-in-a-shell-script.html#comment-19450</guid> <description>If you don&#039;t have lynx installed and want to use wget without messy temporary files, you can use:
wget -qO - http://whatismyip.org/</description> <content:encoded><![CDATA[<p>If you don&#8217;t have lynx installed and want to use wget without messy temporary files, you can use:</p><p>wget -qO &#8211; <a
href="http://whatismyip.org/" rel="nofollow">http://whatismyip.org/</a></p> ]]></content:encoded> </item> </channel> </rss>
