NFS Scanner and Mounter is a Python tool designed to scan, list, and mount NFS shares on a given network range or a single IP address. It leverages nmap
for scanning and showmount
for listing available NFS shares. The tool supports multi-threaded scanning and offers options to remember scanned NFS shares, allowing for efficient and repeated use.
- NFS Discovery: Scan a range of IPs or a single IP to discover available NFS shares.
- List NFS Shares: List all mountable NFS shares on the discovered IPs.
- Mount NFS Shares: Mount discovered NFS shares and display their contents.
- Recursive Listing: Option to list all files within the NFS shares recursively.
- Remember Scanned Shares: Save the results of NFS scans to reuse in future runs without rescanning.
- Clean-up: Automatically unmounts and removes directories created during the operation.
- Python 3.x
nmap
installed and accessible from the command lineshowmount
command available (typically part of thenfs-common
package on Linux)- Install required Python packages using:
pip install tqdm termcolor pandas python-nmap
Run the script with appropriate permissions (typically as root or using sudo
).
To scan a range of IPs and list all available shares:
sudo python3 nfs-scanner.py --range 192.168.1.0/24 --list
To scan a single IP and list all available shares:
sudo python3 nfs-scanner.py --ip 192.168.1.100 --list
To scan a range of IPs, mount available shares, and show their contents:
sudo python3 nfs-scanner.py --range 192.168.1.0/24 --mount
To scan a single IP, mount available shares, and show their contents:
sudo python3 nfs-scanner.py --ip 192.168.1.100 --mount
To include files in the listing, add the --recursive
flag:
sudo python3 nfs-scanner.py --range 10.0.0.0/24 --mount --recursive
To remember the scanned NFS shares for future use:
sudo python3 nfs-scanner.py --range 192.168.1.0/24 --list --remember
To use the remembered NFS shares without scanning again:
sudo python3 nfs-scanner.py --list --remember
To ensure that you have a clean and isolated environment for running the NFS Scanner and Mounter script, it's a good idea to use a Python virtual environment. Here's how to set it up:
-
Install
virtualenv
(if you don't have it already):pip3 install virtualenv
-
Create a virtual environment:
virtualenv venv
-
Activate the virtual environment:
- On Windows:
venv\Scripts\activate
- On macOS and Linux:
source venv/bin/activate
- On Windows:
-
Install the required Python packages:
pip3 install -r requirements.txt
-
Run the script:
-
Deactivate the virtual environment when you're done:
deactivate
By following these steps, you'll ensure that your system's Python environment remains clean and that the NFS Scanner and Mounter script runs with the required dependencies.
The script will automatically unmount and clean up directories created during the operation.