element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
Personal Blogs
  • Community Hub
  • More
Personal Blogs
Legacy Personal Blogs Raspberry Pi Network Spy - Part 1 - Initial Setup + d/b Schema
  • Blog
  • Documents
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
  • Share
  • More
  • Cancel
Group Actions
  • Group RSS
  • More
  • Cancel
Engagement
  • Author Author: Matt
  • Date Created: 12 Sep 2014 12:21 PM Date Created
  • Views 1790 views
  • Likes 1 like
  • Comments 2 comments
  • rpibeginner
  • raspberrypi
Related
Recommended

Raspberry Pi Network Spy - Part 1 - Initial Setup + d/b Schema

Matt
Matt
12 Sep 2014

Project Outline

 

After thinking up a small project to work on, I bought my first Raspberry Pi.. the B+ modelB+ model with a nice little translucent casetranslucent case. The intention is to run it headless and have it attached to my home network & log what other devices appear/disappear (we'll use arp-scan to spot them). This would give me the ability to see what devices are connected at any particular time, and also log how long certain devices have been on the network for.

 

This has multiple uses (all a bit Big Brother-ish, I admit);

 

  • A report can be run to tell how long a device has been running, on what days and in specific time periods.. useful for keeping track of my son's Minecraft habit image
  • Is anything connecting that you weren't aware of.. you could send email alerts if new devices join that you haven't seen before
  • You could extend this project to add the device's current IP to the activity table.. that would be useful for knowing what IP a device might have been given over DHCP at any time
  • You could do a JSON web service can be called to see what devices are currently connected.. handy for seeing who's in the house; smart phones usually auto-connect to the wifi when they're in range

 

I'm sure there are more uses that I've not thought of.

 

Setting up a fresh Pi

 

I bought the NOOBs 8Gb MicroSDNOOBs 8Gb MicroSD card for ease of installation.. and chose the Raspbian OS (maybe another distro is more suitable, but I'm a beginner at this!). After it set things up and gave me a terminal, I then needed to get Apache/PHP/MySQL set up.. these are the steps I went through;

 

1. Set up proxy (optional step depending on your network)..

 

sudo su
cd /etc/apt/apt.conf.d

 

Create a new file called 10proxy & put in the following...

 

Acquire::http::Proxy "http://yourproxyaddress:proxyport";

 

3. Update packages (are we all up-to-date)

 

sudo su
apt-get update

 

4. Install arp-scan (this will scan the network to see what's online)

 

apt-get install arp-scan

 

5. Install Apache

 

apt-get install apache2

 

(check it's working by accessing the server via it's IP.. find that by running ifconfig)

 

6. Install MySQL

 

apt-get install mysql-server

 

Then secure the installation using..

 

mysql_secure_installation

 

7. Install PHP

 

apt-get install php5 php-pear php5-mysql
service apache2 restart

 

8. Write a PHP test file

 

nano /var/www/info.php

 

<?php
     phpinfo();
?>

 

You should be able to see the PHP info page when you load it in a browser. That confirms everything is set up.


Database Schema

 

We need to record which devices we know about together with a friendly name/alias. Then we need to log when devices connect, and when they leave the network. To do this, we'll have 2 tables in our MySQL d/b;

 

image

 

image

Note; the id field is set to auto-increment.

 

 

In the next part, I go into the PHP code that scans the network and populates those 2 tables.

 

Raspberry Pi Network Spy - Part 2 - D/b Setup + PHP for the scanner

  • Sign in to reply

Top Comments

  • Matt
    Matt over 10 years ago in reply to mcb1 +1
    Good point. I'll do that in part 2
  • Matt
    Matt over 10 years ago in reply to mcb1

    Good point. I'll do that in part 2 image

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • More
    • Cancel
  • mcb1
    mcb1 over 10 years ago

    Nice.

    You may wish to also elaborate on creating the tables and how you go about constructing it for some that are new to databases.

     

    An interesting project.

     

    Mark

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • More
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube