Sponsored Content
Top Forums UNIX for Beginners Questions & Answers ARP and Bonjour to build list of user devices Post 302993621 by Zooma on Sunday 12th of March 2017 10:00:21 AM
Old 03-12-2017
ARP and Bonjour to build list of user devices

Hi,
I want to build a list of the devices that are connected to my network and refresh that list every 10th minute (using an RPi with Raspbian). The host names are obtained by using Bonjour which is easily installed by:
Code:
sudo apt-get install libnss-mdns

To build the list manually, I do like this:

1. Find the broadcast address (I sometimes change subnet, so the address could change and the ARP table has to be refreshed at every run):
Code:
ip address show | grep eth0 | grep brd | awk '{print $4}'

2. Ping the broadcast address to build ARP table:
Code:
ping <broadcast address>

3. Print the desired fields of the ARP table:
Code:
arp -a | awk '{print $4 " " $1}'

This produces the desired output which would look something like this:
Code:
00:11:22:33:AA:BB iPhone1
00:11:22:33:AA:BC my Laptop
00:11:22:33:AA:BD ?
...

I want to make this process automated so that I get an updated list every 10th minute. Does someone know a good way of doing this? Have tried to script it but it seems I can't ping a stored IP address.

Cheers!
Sam
 

6 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

passthrough devices vs. named devices

I am having trouble understanding the difference between a passthrough device and a named device and when you would use one or the other to access equipment. As an example, we have a tape library and giving the command "camcontrol devlist" gives the following output: akx# camcontrol... (1 Reply)
Discussion started by: thumper
1 Replies

2. HP-UX

list of devices

Hi, I need to rediracte all the names of the devices (only disks) to a file. Thanks:confused: (3 Replies)
Discussion started by: yoavbe
3 Replies

3. Shell Programming and Scripting

Run SQL command for a list of devices

Hi Please help me to resolve. Question: I can run this command to change the mode of a device with id=500 as below dbc "select device mode=3 where id=500;" How can i run the same query with a file contaning n number of ids ? file1.txt 12 234 34 500 34 45 Thanks in... (3 Replies)
Discussion started by: sureshcisco
3 Replies

4. Shell Programming and Scripting

Perl - run sub routine for list of devices

Hi, Can anyone please correct the script such that it run on all the devices in the devicelist.txt file. The problem is when the script runs it only reads the first device in the list, configures the device and exists. Script: The devicelist.txt: device.crs... (1 Reply)
Discussion started by: sureshcisco
1 Replies

5. UNIX for Dummies Questions & Answers

Adding SDK Build on Kernel Source Build

Hi, So I downloaded this kernel source and was able to build it successfully. But I want to add this SDK source code inside, can anyone help me how to do this? Note that the SDK source can be built by itself. I added the SDK in the main Makefile: init-y := init/ #added SDK... (0 Replies)
Discussion started by: h0ujun
0 Replies

6. UNIX for Advanced & Expert Users

How to handle build user access/permissions?

All, I am looking for some guidance on how to handle permissions/access for an application build/deployment. We need to allow for software deployments via Visual Studio Team Services and a build server running on Windows, deploying to RHEL 7 servers. We would like to use a service account,... (3 Replies)
Discussion started by: hburnswell
3 Replies
Net::Bonjour::Entry(3pm)				User Contributed Perl Documentation				  Net::Bonjour::Entry(3pm)

NAME
Net::Bonjour::Entry - Support module for mDNS service discovery (Apple's Bonjour) SYNOPSIS
use Net::Bonjour; my $res = Net::Bonjour->new(<service>[, <protocol>]); $res->discover; foreach my $entry ( $res->entries ) { print $entry->name, " "; } DESCRIPTION
Net::Bonjour::Entry is a module used to manage entries returned by a mDNS service discovery (Apple's Bonjour). See Net::Bonjour for more information. METHODS
new([<fqdn>]) Creates a new Net::Bonjour::Entry object. The optional argument defines the fully qualifed domain name (FQDN) of the entry. Normal usage of the Net::Bonjour module will not require the construction of Net::Bonjour::Entry objects, as they are automatically created during the discovery process. address Returns the IP address of the entry. all_attrs Returns all the current attributes in the form of hashed array. attribute(<attribute>) Returns the specified attribute from the TXT record of the entry. TXT records are used to specify additional information, e.g. path for http. dnsrr([<record type>]) Returns an DNS answer packet of the entry. The output will be in the format of a Net::DNS::Packet object. The record type designates the resource record to answer with, i.e. PTR, SRV, or TXT. The default is PTR. fetch Reloads the information for the entry via mDNS. fqdn Returns the fully qualifed domain name (FQDN) of entry. An example FQDN is server._afpovertcp._tcp.local hostname Returns the hostname of the server, e.g. 'server.local'. name Returns the name of the entry. In the case of the fqdn example, the name would be 'server'. This name may not be the hostname of the server. For example, names for presence/tcp will be the name of the user and http/tcp will be title of the web resource. port Returns the TCP or UDP port of the entry. sockaddr Returns the binary socket address for the resource and can be used directly to bind() sockets. EXAMPLES
Print out a list of local websites print "<HTML><TITLE>Local Websites</TITLE>"; use Net::Bonjour; my $res = Net::Bonjour->new('http'); $res->discover; foreach my $entry ( $res->entries) { printf "<A HREF='http://%s%s'>%s</A><BR>", $entry->address, $entry->attribute('path'), $entry->name; } print "</HTML>"; Find a service and connect to it use Net::Bonjour; my $res = Net::Bonjour->new('custom'); $res->discover; my $entry = $res->shift_entry; socket SOCK, PF_INET, SOCK_STREAM, scalar(getprotobyname('tcp')); connect SOCK, $entry->sockaddr; print SOCK "Send a message to the service"; while ($line = <SOCK>) { print $line; } close SOCK; SEE ALSO
Net::Bonjour COPYRIGHT
This library is free software and can be distributed or modified under the same terms as Perl itself. Bonjour (in this context) is a trademark of Apple Computer, Inc. AUTHORS
The Net::Bonjour::Entry module was created by George Chlipala <george@walnutcs.com> perl v5.10.0 2007-03-18 Net::Bonjour::Entry(3pm)
All times are GMT -4. The time now is 03:08 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy