[X-Unix] My ip address

Kevin Stevens groups at pursued-with.net
Wed Feb 16 16:24:08 PST 2005


On Mon, 14 Feb 2005, KL Tah wrote:

> Hi,
> Anyone know a slick one-liner in xterm to find out what ip address I'm
> assigned (i.e. Without having to go to System Prefrences)?

ifconfig?

babelfish:~ kes$ ifconfig
lo0: flags=8049<UP,LOOPBACK,RUNNING,MULTICAST> mtu 16384
        inet6 ::1 prefixlen 128
        inet6 fe80::1 prefixlen 64 scopeid 0x1
        inet 127.0.0.1 netmask 0xff000000
gif0: flags=8010<POINTOPOINT,MULTICAST> mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet 10.0.0.42 netmask 0xffffff00 broadcast 10.0.0.255
        ether 00:0a:95:d7:c3:c6
        media: autoselect (1000baseTX <full-duplex>) status: active
        supported media: none autoselect 10baseT/UTP <half-duplex>
10baseT/UTP <full-duplex> 10baseT/UTP <full-duplex,hw-loopback> 100baseTX
<half-duplex> 100baseTX <full-duplex> 100baseTX <full-duplex,hw-loopback>
1000baseTX <full-duplex> 1000baseTX <full-duplex,hw-loopback> 1000baseTX
<full-duplex,flow-control> 1000baseTX
<full-duplex,flow-control,hw-loopback>
fw0: flags=8822<BROADCAST,SMART,SIMPLEX,MULTICAST> mtu 4078
        lladdr 00:0a:95:ff:fe:d7:c3:c6
        media: autoselect <full-duplex> status: inactive
        supported media: autoselect <full-duplex>

If you know the interface you're on, you can narrow it down:

babelfish:~ kes$ ifconfig en0
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet 10.0.0.42 netmask 0xffffff00 broadcast 10.0.0.255
        ether 00:0a:95:d7:c3:c6
        media: autoselect (1000baseTX <full-duplex>) status: active
        supported media: none autoselect 10baseT/UTP <half-duplex>
10baseT/UTP <full-duplex> 10baseT/UTP <full-duplex,hw-loopback> 100baseTX
<half-duplex> 100baseTX <full-duplex> 100baseTX <full-duplex,hw-loopback>
1000baseTX <full-duplex> 1000baseTX <full-duplex,hw-loopback> 1000baseTX
<full-duplex,flow-control> 1000baseTX
<full-duplex,flow-control,hw-loopback>

And I imagine there's options to specify just the IP info; man ifconfig
for details.  Oh hell, let me look...

Try this:

babelfish:~ kes$ ifconfig en0 inet
en0: flags=8863<UP,BROADCAST,SMART,RUNNING,SIMPLEX,MULTICAST> mtu 1500
        inet 10.0.0.42 netmask 0xffffff00 broadcast 10.0.0.255

Anything more specific may need scripting.

KeS


More information about the X-Unix mailing list