Dave-Markowitzs-Computer:~ davemarkowitz$ ifconfig
lo0: flags=8049mtu 16384
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
gif0: flags=8010mtu 1280
stf0: flags=0<> mtu 1280
en0: flags=8863mtu 1500
inet 10.25.10.51 netmask 0xfffffc00 broadcast 10.25.11.255
ether 00:0d:93:70:ed:44
media: autoselect (100baseTX) status: active
supported media: none autoselect 10baseT/UTP10baseT/UTP 10baseT/UTP 100baseTX 100baseTX 100baseTX
en1: flags=8863mtu 1500
ether 00:11:24:26:23:5f
media: autoselect () status: inactive
supported media: autoselect
fw0: flags=8863mtu 2030
lladdr 00:0d:93:ff:fe:70:ed:44
media: autoselectstatus: inactive
supported media: autoselect
If you just want to find out your IP, pipe the output to grep, like so:
Dave-Markowitzs-Computer:~ davemarkowitz$ ifconfig | grep inetAs you can see, it's a lot easier to sort out your IP address with grep.
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 10.25.10.51 netmask 0xfffffc00 broadcast 10.25.11.255
Something I've been using a bit lately in the lab when testing equipment on one physical network which has two logical networks running on it, is to use IP aliasing. With IP aliasing you can use ifconfig to assign your network interface a second IP, simultaneous address.
For example, as you can see from the above example, my Ethernet port currently is assigned the IP address 10.25.10.51. If I need to also be on the 192.168.0.x network, I can add an address in that subnet, like so:
Dave-Markowitzs-Computer:~ davemarkowitz$ sudo ifconfig en0 alias 192.168.0.20 255.255.255.0Notice that you need to prefix the ifconfig command with sudo, because ifconfig needs to run with administrative privileges. When you get the password prompt, enter your user password, not the root password. (Sudo implementations on other OSes may differ. E.g., on SUSE Linux you'd need to enter the root password.)
Password:
Dave-Markowitzs-Computer:~ davemarkowitz$ ifconfig | grep inet
inet 127.0.0.1 netmask 0xff000000
inet6 ::1 prefixlen 128
inet6 fe80::1%lo0 prefixlen 64 scopeid 0x1
inet 10.25.10.51 netmask 0xfffffc00 broadcast 10.25.11.255
inet 192.168.0.20 netmask 0xffffff00 broadcast 255.255.255.0
Finally, to remove an incorrect or unneeded IP alias, do this:
Dave-Markowitzs-Computer:~ davemarkowitz$ sudo ifconfig en0 -alias 192.168.0.20More information about how to use ifconfig can be found by reading its man page ("man ifconfig").
Incidentally, I've replaced Apple's default Terminal.app with iTerm. It's open source and more configurable than Terminal.app, and most important to me, offers tabbed console windows. I highly recommend it.
4 comments:
as you can see from the above example, my Ethernet port currently is assigned the IP address 10.25.10.51.
Nope, I cannot see that. I mean I recognise three IP addresses but the rest is even less readable than a COBOL program. :)
as you can see from the above example, my Ethernet port currently is assigned the IP address 10.25.10.51
another sintax could give a more readable result:
ifconfig | grep netmask
inet 127.0.0.1 netmask 0xff000000
inet 192.168.1.10 netmask 0xffffff00 broadcast 192.168.1.255
inet 10.37.129.2 netmask 0xffffff00 broadcast 10.37.129.255
inet 10.211.55.2 netmask 0xffffff00 broadcast 10.211.55.255
Thank you! Exactly what I was looking for. I'm citing this in my project for class : )
Thank you for this great post. My daughter is trying to make a ping sweeper for school and needed to figure out what her IP address was. Since I'm on a Win box I could not tell her where to look in a Mac ping.
Post a Comment