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

Re: How do i find dynamic IP assigned?



On Tue, Jun 21, 2005 at 01:39:34PM -0700, Valeriu Cerchez wrote:
| I'm trying to find out a(/n easy) way to determine
| what is my dynamic IP assigned by my ISP (not my
| internal DHCP).

I recommend using the 'ip' command (in package 'iproute').  My
understanding is that it is intended to replace the 'ifconfig' tool.

    $ ip addr show dev wlan

(substitute the proper device name on your system instead of 'wlan')

or just

    $ ip addr show

(or even just 'ip addr')


| I wish to make a script to determine
| that by request.

This yields the IPv4 address in CIDR notation :

    $ ip addr show dev wlan  | grep 'inet\>' | awk '{print $2}'

If you don't want the netmask with the address,

    $ ip addr show dev wlan  | grep 'inet\>' | awk '{print $2}' | sed 's,/.*,,'

(note that if your system is configured for ipv6, the grep pattern
there excludes the 'inet6' addresses)

-D

-- 
(A)bort, (R)etry, (T)ake down entire network?
 
www: http://dman13.dyndns.org/~dman/            jabber: dman@dman13.dyndns.org

Attachment: signature.asc
Description: Digital signature


Reply to: