Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

IP of routers at school

router ip school python

This topic has been archived. This means that you cannot reply to this topic.
13 replies to this topic

#1 Bob2580

Bob2580

    CC Lurker

  • New Member
  • Pip
  • 9 posts

Posted 06 October 2014 - 12:55 PM

Hi guys,

 

We are working on a project for school. We want to make a programm that tells us with which router the Raspberry Pi is connected. We tried to work with IP addresses and stuff like that, but it just gives us the same address at every place in the school. See the code below:

import urllib
import re
url = "http://checkip.dyndns.org"
print url
request = urllib.urlopen(url).read()
theIP = re.findall(r"\d{1,3}\.\d{1,3}\.\d{1,3}.\d{1,3}", request)
print theIP

So now we are trying to use MAC-addresses. Is this possible you guys think ? And can you give us some advice on how to get started with it or give us an tutorial or something like that ?

 

Thank you so much !

Bob

 



#2 Alexander

Alexander

    YOL9

  • Moderator
  • 3963 posts

Posted 07 October 2014 - 01:10 AM

The purpose of the router is to route external packets, are there multiple routers or switches in your school? If so, why?

 

MAC addresses are per-device, and are not normally brought out to a public interface.

 

What are you trying to ultimately do?


All new problems require investigation, and so if errors are problems, try to learn as much as you can and report back.


#3 Bob2580

Bob2580

    CC Lurker

  • New Member
  • Pip
  • 9 posts

Posted 07 October 2014 - 09:16 AM

Hi Alexander,

 

Thanks for your reply. We have multiple routers in our school. There is a router in each classroom, I think it is for a better connection. Our goal: The raspberry pi connects to the router with WiFi, then tells us something about the router so we know which one it is and in which classroom it is.

 

So is there something we can do to know which router it is connected with ? So we need something characteristic of the router. We already found an app on our phone. You can see it in the picture below. In the red circle you can see an address that belongs to the router in the classroom. We kept our phone very close to the router and then saw which address was the closest. Can't we use something of this maybe ?

 

The app is in dutch, so if you don't know some words and need to know them, just ask !

 

Attached Thumbnails

  • Screenshot app wifi.png


#4 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts

Posted 07 October 2014 - 09:56 AM

One thing to be aware of: you might not be connecting to wireless routers, but wireless access points. So there might be only a single router that has dozens of wireless access points feeding into it. Of course, each WAP will still have a unique MAC address, but it may be basically invisible from a network perspective, much like a switch.


Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#5 JonElias

JonElias

    CC Addict

  • Advanced Member
  • PipPipPipPipPip
  • 201 posts

Posted 07 October 2014 - 10:33 AM

what is the purpose behind knowing the ip-address?

just curious


"computers are useless they only give you answers" Pablo Picasso
And yes he was alive when the first programmable computer was made

#6 Bob2580

Bob2580

    CC Lurker

  • New Member
  • Pip
  • 9 posts

Posted 07 October 2014 - 10:47 AM

So WingedPanther, it is never possible to get those MAC-addresses in that case or is it possible but in another way ?

#7 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts

Posted 07 October 2014 - 11:28 AM

It's probably possible to get the MAC addresses of whatever you're connecting to, but it may be harder than you were hoping for. A quick search found some information you can return from arp and ifconfig on a *nix type system, for example, but my immediate tests seemed less than helpful.

 

In a school environment, I would expect you to have a single router for the entire school, with multiple wireless access points. So the first question is: do you want the MAC of the router, or the WAP? It's a critical question. If you want a WAP MAC address, then you're going to have to dig around into the details of your actual connection.

 

These articles MAY be relevant:

http://yourbusiness....oint-19756.html

http://yourbusiness....inux-19373.html


Edited by WingedPanther, 07 October 2014 - 11:29 AM.

Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#8 Bob2580

Bob2580

    CC Lurker

  • New Member
  • Pip
  • 9 posts

Posted 07 October 2014 - 12:01 PM

Thank you very much WingedPanther ! We will try this tomorrow at school and will tell you what happened.



#9 Bob2580

Bob2580

    CC Lurker

  • New Member
  • Pip
  • 9 posts

Posted 08 October 2014 - 11:12 AM

Thank you so much WingedPanther it worked !! Thanks so much again, you're great !



#10 Bob2580

Bob2580

    CC Lurker

  • New Member
  • Pip
  • 9 posts

Posted 08 October 2014 - 11:34 AM

But now we have another problem  :(. Is it possible to use cmd in python ? I figured this out:

 

import subprocess
import re


myProcess = subprocess.Popen(
    [ipconfig],
    stdout = subprocess.PIPE,
    stderr = subprocess.PIPE)


out, error = myProcess.communicate()


print out

But then i only can use 1 word and not something like ipconfig /all or something like that. Do you know another tactic to use cmd in python ?

Thanks !

B.t.w. it also has to be automatic, so I do not have to type in the command, cause I only use one command and it is always the same and in our case it has to go automatic, so we do not have to fill in anything, it just runs automatically.



#11 WingedPanther73

WingedPanther73

    A spammer's worst nightmare

  • Moderator
  • 17757 posts

Posted 08 October 2014 - 12:06 PM

Now's where we have to hope the Python programmers will step in :) I've never touched the language :D


Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

My MineCraft server site: http://banishedwings.enjin.com/


#12 BlackRabbit

BlackRabbit

    CodeCall Legend

  • Expert Member
  • PipPipPipPipPipPipPipPip
  • 3871 posts

Posted 08 October 2014 - 06:27 PM

You can use call. like this:

[code]
from subprocess import call
call(["ipconfig", "/all"])

[/code]






Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download