Ask Ubuntu is a question and answer site for Ubuntu users and developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a question concerning Ubuntu 12.04 LTS Desktop - notifications (same notification as Rhythmbox application when playing music back and forth), technically if I'm not mistaken it should be called "freedesktop.Notifications.service". I just want to add notifications when one of my devices such as; laptop, phone, tablet connect to my local network. My configuration is as follows:

I have a wireless router. My router is connected directly to my desktop computer with a wire, I'm using LAN, the other devices connect through WI-FI.

By way of example, let's say :

My router's ip address : & MAC address XX:XX:XX:XX:XX:XX

Me - as server - & MAC address YY:YY:YY:YY:YY:YY

Smartphone - & MAC address ZZ:ZZ:ZZ:ZZ:ZZ:ZZ

Laptop - & MAC address KK:KK:KK:KK:KK:KK

  • What I want to do is simple; add those IP addresses along with their MAC addresses in the ARP and finally modify the notification file, whenever those devices connect to my local network I get notified. That's it.

P.S : I said "ARP". However, I'm not sure if it is suitable, I'm just supposing it has something to do with ARP config file, and notification file. Any suggestion using terminal or other application will be acceptable.

I will be much appreciated if someone can help me.

share|improve this question
Hello i'm a newbie can you please help me to get all the ip adress that has changed not only the first one. Thank you! – user268846 Apr 14 '14 at 15:28
up vote 0 down vote accepted

You can send notifications by use of notify-send yourmessage but what you want to do is a bit strange.

Your router is the one handling the connections, a connection to your network will not be logged or noticed by your computer unless the device actually connects / interacts to your computer. Of course you could be making a monitor by regularly scanning the network like:

nmap -sn 192.168.1.*

and then read you data from here (or arp, because now you can find them there). But basically the device for monitoring connections is your router, not your pc.

If your router supports it, you could parse the logging of the router to the syslog of your pc. Now you get an message in the syslog when a connection is made, which you can then send to your desktop environment if you want.

But to answer the question, add a script to your cron which will do a nmap -sn, pipe this to temp file and compare this with the previous situation by use of diff. Diff out means offline, diff in means online.

A rough example (only handles first ip change per run):

#Script to monitor the network and put changes to notification
#Save previous scan
cp scan.txt previousscan.txt
#get numeric list of online hosts
nmap -n -sn 192.168.178.* > scan.txt
#collect the difference, only the lines with ip-numbers
message=$(diff previousscan.txt scan.txt | grep 192)
#get first char which indicates if the host came up or went away
#get first ip-number from the list

#show ip-number in notify if host came up
if [ "$iostring" = \> ]; then
        notify-send "$computer online"
#show ip-number in notify if host went away
if [ "$iostring" = \< ]; then
        notify-send "$computer offline"
share|improve this answer
Works like magic, Thank you very much Requist. By the way I was working on something similar, I was going to post my own response, because I just figured out that all the problem could be solved using "nmap, notify-send, bash". I just didn't know how to mix things in order to get a solution. But Thank you so much, very helpful with more details. – ggalaxy Jan 1 '14 at 22:04
you're welcome :) – Requist Jan 1 '14 at 23:02

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.