NAS Discovery - how?
Greetings
How can I search and discover NAS devices attached to my LAN from a shell/bash? I'm trying to write a bash script for NAS discovery, but I am unsure what commands to use. It is supposed to enumerate the local network shares. |
what exactly are you looking for? are you looking for a brand new NAS plugged fresh into a DHCP network to identify its IP?
are you looking for an already configured NAS with a static IP? what? |
Either one. I need a list of local shares where a user can select a share in a web-gui (possibly provide authentication), and have the server connect/mount that share to a specific folder. I don't own a NAS, so I have no idea how to discover them. I mean what protocols do they use to announce their presence? CIFS? NFS? UPNP?
|
it all depends on the brand and how they are configured. could be cifs, could be nfs, could be afs or even ftp.
you would detect a share like you would any other kind of share detection. each type has its own method of detection. nfs for example uses exports -a. so yes what you are wanting to do perform is possible, but you need to narrow down, or expand exactly what you are looking for. sounds like you need to start writing the script then when you need additional help post back to these forums with detailed questions. there are plenty of great script masters around here willing to help. |
I'm looking to implement support for the most common consumer-grade NAS' - the ones you can get from shelves or internet stores? Most average users have Windows on their machines, so I assume the protocol of choice would be Samba/CIFS.
EDIT: According to some websites the two most common protocols are NFS and CIFS. Good, this is one part of information I was looking for. Now how to discover which machines on the network offer these services. I could use nmap, but that would be an overkill. EDIT2: You mentioned exports for NFS and samba seems to have a tool called smbtree. I'll play with these a bit. |
I do not know what you exactly like to do .
It does not matter if use the linux box , Mac BOx or the windows box . Typing in firefox find.synology.com it connects to my NAS and it give two options sign as a user or as admin Signing in as admin I can do anything with NAS |
Quote:
also keep in mind, there is zero share by default on many SoHo NAS devices. they are typically configured for DHCP, then require either a web interface access and very few have CLI interface access for configuration. typically its all web based for configuration. setting user/pw, setting types of shares, setting permissions, etc... if you are looking to discover a new NAS randomly plugged into your LAN, then configure via same script, i dont know if you will pull that off with all SoHo types of NAS devices just as most dont have CLI interfaces for configuration. if you are just attempting to detect a new NAS connected to a LAN, then you might look into nmap. i have used that many times to locate a NAS as they typically will report their manufacture and type. |
Maybe I forgot to mention that I'm doing this on a headless system. So no firefox, file managers or gui tools. There's gonna be a web interface in php where a user can connect, and view a list of NAS devices. Thanks for pointing that out about unconfigured NAS devices, but I'm only interested in configured devices that have some existing shares defined.
I wrote this python script that seems to detect most of the CIFS shares. Code:
import sys, re, json Edit: I wrote a simpler python script that only shows visible/public CIFS shares. Code:
import sys |
The only utility to see NFS shares that I know about is showmount. It is per server i.e. it can not browse a network.
|
Thank you.
Do you perhaps know how to discover local FTP shares (without using a port scanner like nmap)? I'm hoping for a ftp-equivalent of the "smbtree" and "showmount" commands. ~dis |
No browsing tool. You could use cURL to test for a FTP server. However, since you posted that the NASs would already be configured I would expect that the IP address and the top level shares/protocols would already be defined. By the way smbtree will find all cifs shares regardless if they are on a NAS or other PC with sharing enabled.
|
Quote:
Quote:
Alright then. I believe I have all the information I was looking for. I recall nmap had some interesting lua scripts to scan FTP servers. I'll see if I can adapt them for my use or at least write something similar and simpler. ~dis |
All times are GMT -5. The time now is 04:22 PM. |