156

I'm basically looking for something like this but available on Mac. I am using Mac OS X 10.6.

I am trying to connect a new workstation to our wireless multifunction printer and I'm having a hell of a time getting the device to spit out an IP for me to connect to.

Is there a way I can scan the network somehow?

Giacomo1968
  • 55,001
macek
  • 6,205

9 Answers9

241
  1. Ping the broadcast address. (You can find it with ifconfig | grep broadcast.)

  2. And then do an arp -a.

Giacomo1968
  • 55,001
Hasaan Chop
  • 4,768
  • Best answer because it required no software download. Thanks, NSD :) – macek Mar 29 '10 at 16:00
  • 2
    Great tip.. I filtered out the results to only show the ip's that are not incomplete (and are present) with..

    arp -a | grep :

    – Jas Panesar Jul 17 '13 at 02:46
  • 14
    Can someone explain why/how this works? You ping the broadcast and this causes all the other connected clients to commit network activity which is then visible to arp ?? – Do Not Track Me Dec 28 '14 at 18:28
  • 27
    Best answer. You can do it one line too: ifconfig | grep broadcast | arp -a – Codeversed Jan 21 '15 at 13:16
  • 2
    @deweydb when you're on LAN, connecting to an IP involves resolving the IP into a mac address. ARP keeps a cache of all resolved IP addresses. Doing a broadcast ping indirectly triggers a resolution for all IPs on the network. Now... how can we resolve the list of IPs into DNS (or other) names? – Rolf Oct 25 '16 at 10:24
  • 2
    I use: arp -a | grep -v '^?' under Macosx. – Mirko Ebert Dec 29 '16 at 23:11
  • 2
    What do the ? (192.168.1.15) at <incomplete> on eth0 mean? there is nothing (and AFAIK there has never been) anything on my lan at that address – Gaia Oct 16 '18 at 20:30
  • 3
    oneliner: ping $(ifconfig | grep broadcast | awk '{print $NF}') -t 1 > /dev/null && arp -a (to have this work on a linux box you'll need to add -b to ping) – ccpizza Apr 16 '23 at 19:44
9

Where x.x.x is the first three numbers in your ip address.

for ip in $(seq 1 254); do ping -c 1 x.x.x.$ip -o ConnectTimeout=5; [ $? -eq 0 ] && echo "x.x.x.$ip UP" || : ; done
ow3n
  • 286
  • 3
    On a Mac here, had to slightly adjust your answer as the timeout is set using the -t option (for instance -t 5 for a 5 seconds timeout) – Pierre-Adrien Aug 02 '13 at 19:03
  • 1
    Right, that also didn't work for me. On the Mac you not only need to use the -t 5 option, but also move it to be before the ip. i.e. -c 1 -t 5 x.x.x.$ip. Otherwise it'll error and bomb out. – hookenz Feb 24 '14 at 04:06
  • Right. First of all, x.x.x only works for netmasks that are /24(=0xffffff00). One should verify this using ifconfig. Second of all, this takes 21 minutes to run serially. Can do this in parallel by terminating the for loop using & instead of ;. On MacOS, this looks like: for ip in $(seq 1 254); do ping -c 1 -t5 192.168.1.$ip > /dev/null ; [ $? -eq 0 ] && echo "x.x.x.$ip UP" || : & done – ijoseph Nov 27 '19 at 23:35
8

Single Line Answer: http://nmap.org/download.html [Use NMAP] or Angry IP Scanner

adeelx
  • 1,288
5

Your printer provides a file share for dropping files into or are you just trying to locate the printer on your network?

Does your new multifunction printer support Bonjour/ZeroConf? (Most new network based printers do) If so you can use a program such as Bonjour Browser to see what is available on your network.

On your router does it appear on the DHCP Clients Table (you may have to consult your manual to see how to see this table) - as this will also give you the IP but will also let you know for certain that your printer is actually connected to your network.

From your Mac itself you can use a program such as Nmap from the command line or use a GUI based app (eg. Zenmap - GUI for Nmap or AngryIPScanner) to scan your network and then see what ports are available.

Chealion
  • 25,777
  • 1
    To add to @Chealion's answer, if your printer supports Bonjour, you should see it in the "Nearby printers" list on the "Printer" pop-up menu of the "File > Print..." dialog sheet, or in the printer browser you see when you go to "Add Printer...".

    So many multifuction printers from the major manufacturers support Bonjour nowadays, that I'm surprised when a printer doesn't just automatically show up on those places I mentioned.

    – Spiff Mar 26 '10 at 20:03
5

NMAP [nmap] is your best friend for all sorts of network devices scans. Use Zenmap if you need GUI [zenmap].

Assuming your local network is 192.168.0.0/24 (where 24 means netmask 255.255.255.0) this will give you online hosts with their IP and MAC addresses:

nmap -sP 192.168.0.0/24

You can download the package from project website or build yourself from sources with MacPorts [macports]. Enjoy! :-)

[nmap] https://nmap.org/

[zenmap] https://nmap.org/zenmap/

[macports] https://www.macports.org/

CeDeROM
  • 161
3

Fing (mostly known as a mobile network scanner for android/ios) has a freely available macos console version which additionally does some fingerprinting via its own built-in mac address manufacturer tables. It appears to be faster than nmap.

Once installed you can run it with:

sudo fing -r 1

-r 1 will run the discovery once; without the flag it will keep running the discovery in live mode.

It is apparently closed source so I don't know how safe it is to use. Make sure you are aware of potential risks.

Also available as a homebrew cask:

brew install fing-cli
ccpizza
  • 7,763
0

Works:

$ for ip in $(seq 1 254); do ping -c 1 192.168.0.$ip; done

or

$ for ip in $(seq 1 254); do ping -c 1 192.168.0.$ip -W 1; done

Description:

loop from 1 till 254
on each loop ping the ip one after another, to skip press CTRL + C
or
on each loop -W 1 means auto skip after 1 second
YumYumYum
  • 1,677
0

There are two common protocols by which devices announce themselves on the local network.

One is Bonjour, which is an Apple invention, and has already been answered here (though they're missing the alternative browser BonJeff.

The other is SSDP (related to UPnP), which comes from the Windows world. It is a bit more verbose. You can use this SSDP Browser.app (my own work, BTW).

-1

On the Mac, there is IP Scanner, which looks has a GUI that aggregates arp, bonjour, NBT and some other network scanning technologies.

Lee Taylor
  • 1,484
  • 8
    Hi! Per the [FAQ], please disclose any affiliation with products you recommend. And please don't let that be the only reason you're on Super User—otherwise your posts may be considered spam. – slhck Dec 31 '12 at 19:20
  • 6
    IP Scanner is useless as it has a 6 device limit, then they want $30. Avoid this. – JohnnyVegas Aug 24 '15 at 18:57
  • I wasn't sure what to think of this comment at first, and I'm not sure how to see that the author of this answer is affiliated with the product. If they are, they should have definitely disclosed it.

    That being said, I checked out IP Scanner and I really like it. Fantastic GUI. Saves me a ton of time. The free version is good enough for me and I can see myself buying the paid version if I use it more often. Looks like money well spent to me.

    There used to be a great shareware culture in the old days; IP Scanner is essentially that. I like it.

    – Thomas Walther Sep 10 '23 at 11:46