[olug] Unix Tip: GET YOUR IP-ADDRESS (long explanation)

Blaufuss, Shane sblaufuss at fnni.com
Thu Mar 20 20:27:50 UTC 2003


Nobody said anything about a command line :)

> -----Original Message-----
> From: CM Miller [mailto:cmmiller1973 at yahoo.com]
> Sent: Thursday, March 20, 2003 2:23 PM
> To: Omaha Linux User Group
> Subject: Re: [olug] Unix Tip: GET YOUR IP-ADDRESS (long explanation)
> 
> 
> 
> I know what all of these commands mean, but why do
> something like this at the command line?  A script,
> yes. 
> 
> -Chris 
> 
> --- Eric Penne <epenne at olug.org> wrote:
> > ifconfig | grep "inet addr" |  grep -v "127.0.0.1" |
> > awk '{print $2;}' |
> > awk -F':' '{print $2;}'
> > 
> > 
> > Here is a rundown on this command for the newbies.
> > 
> > 1) ifconfig is usually located in /sbin/ifconfig
> > shows the network
> > interfaces that are up and how they are configured.
> > 
> > 2) grep pulls lines out of the ifconfig info that
> > contain inet addr
> > 
> > 3) grep -v inverts.  It prints all the lines that
> > don't have 127.0.0.1
> > in them.
> > 
> > 4) awk looks at the info and pulls the second field
> > out, where the
> > fields are separated by whitespace by default.
> > 
> > 5) Then awk -F':' is used again to pull the second
> > field out, where the
> > fields are separated by a colon.
> > 
> > The individual outputs follow:
> > 
> > 1)
> > 
> > eth0      Link encap:Ethernet  HWaddr
> > 00:80:AD:0C:BA:43
> >           inet addr:192.168.1.42 
> > Bcast:192.168.255.255
> > Mask:255.255.0.0 UP BROADCAST RUNNING MULTICAST 
> > MTU:1500
> > Metric:1
> >           RX packets:34866 errors:0 dropped:0
> > overruns:0 frame:0
> >           TX packets:5882 errors:0 dropped:0
> > overruns:0 carrier:0
> >           collisions:0 txqueuelen:100
> >           RX bytes:7133322 (6.8 MiB)  TX
> > bytes:850473 (830.5 KiB)
> >           Interrupt:3 Base address:0xd800
> > 
> > lo        Link encap:Local Loopback
> >           inet addr:127.0.0.1  Mask:255.0.0.0
> >           UP LOOPBACK RUNNING  MTU:16436  Metric:1
> >           RX packets:8 errors:0 dropped:0 overruns:0
> > frame:0
> >           TX packets:8 errors:0 dropped:0 overruns:0
> > carrier:0
> >           collisions:0 txqueuelen:0
> >           RX bytes:400 (400.0 b)  TX bytes:400
> > (400.0 b)
> > 
> > 2)
> >           inet addr:192.168.1.42 
> > Bcast:192.168.255.255
> > Mask:255.255.0.0 inet addr:127.0.0.1  Mask:255.0.0.0
> > 
> > 3)
> >           inet addr:192.168.1.42 
> > Bcast:192.168.255.255
> > Mask:255.255.0.0
> > 
> > 4)
> > addr:192.168.1.42
> > 
> > 5)
> > 192.168.1.42
> > 
> > 
> > Now don't we all love the pipe command.  Hopefully
> > if you are having
> > trouble with the above command this explanation can
> > step you through the
> > issues.
> > 
> > Eric
> > 
> > 
> > 
> > _______________________________________________
> > OLUG mailing list
> > OLUG at olug.org
> > http://lists.olug.org/mailman/listinfo/olug
> 
> 
> =====
> Winning an argument on the internet is like getting 1st place 
> at the Special Olympics
> 
> *****************************************
> GAIM ID:  cmmiller1973
> *****************************************
> 
> __________________________________________________
> Do you Yahoo!?
> Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!
> http://platinum.yahoo.com
> _______________________________________________
> OLUG mailing list
> OLUG at olug.org
> http://lists.olug.org/mailman/listinfo/olug
> 



More information about the OLUG mailing list