Scan devices on linux

How to Find What Devices are Connected to Network in Linux

Last updated September 30, 2019 By Abhishek Prakash 60 Comments

Brief: This quick trick shows you how to find devices connected to your local network in Linux.

Wireless networks have always been a desirable target for wannabe hackers. Wireless networks are also more vulnerable to hacking than the wired ones.

Forget hacking, do you ever wonder that someone might be leeching off your hard paid wifi network? Maybe a neighbor who once connected to your network and now uses it as his/her own?

It would be nice to check what devices are on your network. This way you can also see if there are some unwanted devices on your network.

So you might end up thinking, “how do I find what devices are connected to my network”?

I’ll show you how to do that in this quick tutorial. Not only it’s a good idea from security point of view, it is also a good little exercise if you have interest in networking.

We will use both, command line and GUI, way for finding out what devices are connected to your local network in Linux. The process is very simple and easy to use even for beginners.

A. Using Linux command to find devices on the network

Step 1: Install nmap

nmap is one of the most popular network scanning tool in Linux. Use the following command to install nmap in Ubuntu based Linux distributions:

You can easily install it in other Linux distributions as well. It should be in the official software repository.

Step 2: Get IP range of the network

Now we need to know the IP address range of the network. Use the ifconfig command to find the IP address in Linux. Look for wlan0 if you are using wifi or eth0 if you are using Ethernet.

$ ifconfig
wlan0 Link encap:Ethernet HWaddr 70:f1:a1:c2:f2:e9
inet addr:192.168.1.91 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::73f1:a1ef:fec2:f2e8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2135051 errors:0 dropped:0 overruns:0 frame:0
TX packets:2013773 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1434994913 (1.4 GB) TX bytes:636207445 (636.2 MB)

The important things are highlighted in bold. As you see my IP is 192.168.1.91 and the subnet mask is 255.255.255.0 which means that the ip address range on my network varies from 192.168.1.0 to 192.168.1.255.

You may also use ip a command to know your IP address in Ubuntu and other Linux distributions.

At the same time, I’ll recommend you to read about basic Linux networking commands for more information.

Step 3: Scan to find devices connected to your network

It is advisable to use root privileges while scanning the network for more accurate information. Use the nmap command in the following way:

$ sudo nmap -sn 192.168.1.0/24
Starting Nmap 5.21 ( http://nmap.org ) at 2012-09-01 21:59 CEST

Nmap scan report for neufbox (192.168.1.1)
Host is up (0.012s latency).
MAC Address: E0:A1:D5:72:5A:5C (Unknown)
Nmap scan report for takshak-bambi (192.168.1.91)
Host is up.
Nmap scan report for android-95b23f67te05e1c8 (192.168.1.93)
Host is up (0.36s latency).

As you can see that there are three devices connected to my network. The router itself, my laptop and my Galaxy S2.

If you are wondering about why I used 24 in the above command, you should know a little about CIDR notation. It basically means that the scanning will be from 192.168.1.0 to 192.168.1.255.

Читайте также:  Перо windows ink как выключить

B. Using GUI tool to find devices connected to network

When I first wrote this article, there was no GUI tool for this task. Then I saw a Google+ discussion about a new network monitoring tool being developed for elementary OS. I suggested including a periodic device scan feature in this tool and the developer readily agreed.

So, now we have a GUI tool that does this task. It’s called Nutty. Just run install this app and run it. It will periodically scan for new devices on the network and will notify you if there is a new device.

This application is only available for elementary OS, Ubuntu and hopefully, other Ubuntu based Linux distributions. You can find installation instructions on this detailed article on Nutty.

Oh, you can also log in to your router and see the devices connected to your devices. I let you figure the best way to find devices connected to your network.

Like what you read? Please share it with others.

Источник

Scanners and Linux

Using optical scanners with Linux.

Imaging profesionals will want to perform a monitor color corection and calibration prior to using and tuning a scanner.
See our Linux monitor calibration tutorial.

Related YoLinux Tutorials:

To utilize a scanner under Linux one must install the «SANE» software package. It is also wise to employ a front-end application for scanning such as Xsane. Linux uses a software interface to scanning devices known as SANE. PC’s often use TWAIN. These software packages run as interfaces between the application and the scanner. SANE is like TWAIN except that it allows network access to the scanner through the saned (Networked scanner daemon). TWAIN is not network enabled and merely talks to local applications. (It is not necessary to run the saned for local applications.)

The current SANE release talks to SCSI scanners. Most non-USB scanners are SCSI scanners. Even if the scanner comes with it’s own card, that card is likely a simple SCSI card with a limited feature set which can provide enough features to talk to the scanner.

See this link to see what scanners are supported by SANE: http://www.mostang.com/sane/sane-backends.html

SCSI devices under Linux are often named to suite the device. For example the first SCSI tape drive is /dev/st0. The first SCSI CD-ROM is /dev/scd0. When using scanners, one uses the «raw» device name.

SCSI ID Number Linux Device
0 /dev/sga
1 /dev/sgb
2 /dev/sgc
3 /dev/sgd
4 /dev/sge
5 /dev/sgf
6 /dev/sgg
7 /dev/sgh

The SCSI device number 7 is usually reserved for the SCSI card itself.
To list scsi devices on Linux system: cat /proc/scsi/scsi

Set up a new logical device: As root: ln -s /dev/sgX /dev/scanner where X refers to your raw SCSI device. One may also want to change privileges for the device: chmod ugo+r /dev/sgX. (You may want to set up a group and privileges for the group if this is on a server.)

Configuration files: The defaults from the Red Hat rpm do not require any changes. Here are my samples for my HP Scanjet 5p (or any HP scanner)

File: /etc/sane.d/hp.conf (default will work) — There are many other files to provide support for other manufacturers.

Test to see if the device is recognized: scanimage -L

  • If you don’t get this, reboot the system so that the system picks up and accounts for the links and device security changes.
  • Make the scanner the first with that name. For example I had an HP CR-ROM that was scsi device 4 and the HP scanner was scsi device 6. Scanimage would probe and return that the first HP device was the CD-ROM and would assume that it was the scanner. I had to change the scanner to device 2 so that it would be the first HP device scanned.

Man pages: saned, scanimage, xscanimage, sane-scsi, sane-pnm, sane-dll
Man pages on devices: sane-apple, sane-epson, sane-hp, sane-microtek, etc
See «rpm -ql sane» to see all files and man pages in package.

Look at: man sane-scsi This tells of how to recompile the kernel for a larger scsi buffer for more speed if you want to optimize your system. Red Hat should do this by default.

Yes the sane rpm package comes with xscanimage but Xsane takes alot of the pitfalls out of the operation. (but not all) Thus I recommend using Xsane as your scanning application.

  • Start by issuing the command (or create a launch icon): /usr/bin/xsane
  • Choose device /dev/scanner and select «Ok».
  • Select options:
    • «Scan» and «Color». Set the image extension (i.e. jpeg) and output file name.
    • Set brightness (i.e. 50) and change output extension to jpeg (example)
    • Set resolution for HP ScanJet 5p for 100 to get full size on a 17″ 1280×1024 monitor
  • Choose «View» + «show preview» then «Acquire Preview». See pitfall below.
  • Adjust size of preview «elastic» box to fit image.
  • Back on main dialog box select «Start»

Pitfalls: Note that the order of operation is important. You MUST use the preview window and do an «Aquire Preview» first before each scan. If you select the «Start» button to scan immediately, you may get nothing. To set the size in the preview window, adjust the «elastic box» or «marching ants». It is already there. The «elastic» box is already there. (you just can’t see it the first time) Select the corner of the «elastic» box in the corner of the preview window. You can’t see it but it is there. Just left-click at the corner of the preview window and drag. Adjust to the size of your image. Other orders of operation are possible but they may result in no real image.

Also note that if you choose the file number incrementer, that this feature maxes out at 9.

  • The icons at the bottom of the main XSane options panel will reset all the defaults. I take all the defaults and then double «Gamma» to 2.0 (Black gamma slider)
  • Scan resolution defaults to 100. I set it to 72 which matches most monitor resolutions.

Commercial scanning products:

  • ViviData
    • OCR for Linux
    • Vividriver — scanning drivers
    • PShop — Printing
  • Mentalix — Java toolkits and APIs
  • Tummy: XVScan — Scanning software integrated with the XV image viewer/manipulator

Источник

How to Scan/Detect New LUNs on Linux

When you are running RedHat Enterprise Linux 5, 6, and 7 series system with DM-Multipath and the software iSCSI initiator, you can discover new LUNs by rescanning the iSCSI service on the host.

Rescanning the service will display all the newly created LUNs that have been mapped to the host. In this tutorial I will show commands to scan and detect (outputs to check) new luns attached to the Centos/RHEL server.

To scan new FC LUNS and SCSI disks in Linux, you can use the echo script command for a manual scan that doesn’t require a system reboot. But, from Redhat Linux 5.4 onwards, Redhat introduced /usr/bin/rescan-scsi-bus.sh script to scan all the LUNs and update the SCSI layer to reflect new devices.

Check the number of attached disks

You use the below commands to identify existing LUNs and how to add newly mapped LUNs to Linux.

You can use the following command to have better output of all the disks

1) Using /sys class file

You can use the echo command to scan each scsi host device as below. Now to rescan the bus, use the following command

The three dash («- — -«) of the command act as wildcards meaning rescan everything. Remember that the three values normally stand for channel, SCSI target ID, and LUN.

  • h is the HBA number
  • c is the channel on the HBA
  • t is the SCSI target ID
  • l is the LUN.

If you don’t have the host bus number, you must list all the existing host bus number on your system with the command

Then you will scan every iscsi disk found and scan after every scanning if the new disk was detected. It means

It may look like very simple as we perform this operation but the system has much work to do in the background when you execute storage scanning commands.

Method to find Channel Routes

If we know the channel, target ID and LUN address, we can scan using that. Here, we have 4 HBA emulex cards 0, 1, 2 and 3.

Through card 0 and 2,

It has the same WWNN (World Wide Node Name) for all the 4 WWPN (World Wide Port Name).

We can do a depth research by filtering the WWPN (World Wide Port Name) to have more information

This indicates there are four Fibre Channel routes to this target.

So now, you can scan for LUNs as follows and addresss «8» is given by storage team.

The output of SCSI file is illustrated for your reference:

Another Method

If you don’t have the host bus number, you must list all the existing host bus number on your system with the command

On the output, host0 is the relevant field. As we have said earlier, we need to have the host bus number to determine what to scan

Then you will scan every iscsi disk found and scan after every scanning if the new disk was detected. It means

If you have too many hosts (from host0 to host20 for example), you can use the command below

or you can try (this one for Fibre Channel)

# for host in `ls /sys/class/fc_host/`; do
echo «1» >/sys/class/fc_host/$/issue_lip;
done

Can devices be rescanned in Linux OS without reloading the Linux driver?

There is a procedure which forces the driver to rescan the targets and to allow a new device which is to be added. This triggers the driver to initiate a LUN discovery process.

To force a rescan from the command line, type the following command:

# echo «scsi-qlascan» > /proc/scsi//

— = qla2100, qla2200, qla2300 (2.4 kernel drivers) or qla2xxx (2.6 kernel drivers)
— = the instance number of the HBA

After executing this command, force the SCSI mid layer to do its own scan and build the device table entry for the new device by typing the following command:

# echo «scsi add-single-device 0 1 2 3» >/proc/scsi/scsi

— «0 1 2 3» = your «Host Channel ID LUN»

The scanning must be done in the above-mentioned order; first the driver (qla2300/qla2200 driver, etc.) and then the Linux SCSI mid-layer (i.e. OS scan).

2) Scan lun with multipath/powermt

You can check current multipath setup using multipath or powermt command.

If EMC powerpath is installed, check the disk/multipath status as below:

Multipath daemon will automatically add attached devices if it’s configured properly. For powermt, we need to run below command manually.

3) Using Script

You can rescan using the SCSI rescan script which will detect new luns and add it to your server automatically. You can find this script in sg3_utils package.

Conclusion

For storage (Netapp,equallogic) that use iscsi target, command iscsiadm -m session —rescan could be used to rescan when new lun added to the target. I would recommend always to use vendor-specific script or tools to scan Luns.

I hope you have enjoyed reading and let us know if you found any other method to scan storage disk devices.

Источник

Читайте также:  Radeon hd 5145m драйвер windows 10
Оцените статью