finding my own IP address

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi:

As someone else has already said, you can use ifconfig ppp0 to get your IP
address.

In addition, people running debian who have the ipmasquerading stuff
installed, whil have a script called ipofif.  This is what it looks like -
it gives the IP of an interface.  So you can give a command like ipofif
ppp0 to get your ip.  and since it only outputs your ip, you can use it in
commands, like ping `ipofif ppp0` to ping your current ppp0 address.

There are a number of cool scripts that come with this package.  They are:

bcofif - Get broadcast address of interface
default-if - Give name of default interface
enumerate-if - list names of up interfaces
ipofif - Give IP address of interface
nmofif - Give netmask of interface
peerofif - Give the IP address of the peer you are connected to via
	interface

Note that most take an interface as an argument.  If you don't give one, it
will output data for all interfaces where appropriate.  For example, bcofif
only gives data for eth0 on my system, and peerofif only gives data for
ppp0.  Default-if and enumerate-if obviously don't need any arguments.

These scripts don't use any debian-specific stuff, so they should be fully
transportable.  Since it's relevant to the thread, I'll include ipofif
below.  Feel free to ask for any of the others.

Geoff.


#!/bin/sh
#
# ipofif	Determines the IP address of the interface given on the
#		commandline
#
# v1.0	19 July 1998
# v1.1  12 June 1999
#####

export LC_ALL="C"

/sbin/ifconfig $1 | grep 'inet addr:' | sed 's/.*inet addr:\([0-9.]*\).*/\1/g'





[Index of Archives]     [Linux for the Blind]     [Fedora Discussioin]     [Linux Kernel]     [Yosemite News]     [Big List of Linux Books]
  Powered by Linux