Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 455485
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T22:22:32+00:00 2026-05-12T22:22:32+00:00

I’m looking for a way (with python) to obtain the layer II address from

  • 0

I’m looking for a way (with python) to obtain the layer II address from a device on my local network. Layer III addresses are known.

The goal is to build a script that will poll a databases of IP addresses on regular intervals ensuring that the mac addresses have not changed and if they have, email alerts to myself.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T22:22:33+00:00Added an answer on May 12, 2026 at 10:22 pm

    To answer the question with Python depends on your platform. I don’t have Windows handy, so the following solution works on the Linux box I wrote it on. A small change to the regular expression will make it work in OS X.

    First, you must ping the target. That will place the target — as long as it’s within your netmask, which it sounds like in this situation it will be — in your system’s ARP cache. Observe:

    13:40 jsmith@undertow% ping 97.107.138.15
    PING 97.107.138.15 (97.107.138.15) 56(84) bytes of data.
    64 bytes from 97.107.138.15: icmp_seq=1 ttl=64 time=1.25 ms
    ^C
    
    13:40 jsmith@undertow% arp -n 97.107.138.15
    Address                  HWtype  HWaddress           Flags Mask            Iface
    97.107.138.15            ether   fe:fd:61:6b:8a:0f   C                     eth0
    

    Knowing that, you do a little subprocess magic — otherwise you’re writing ARP cache checking code yourself, and you don’t want to do that:

    >>> from subprocess import Popen, PIPE
    >>> import re
    >>> IP = "1.2.3.4"
    
    >>> # do_ping(IP)
    >>> # The time between ping and arp check must be small, as ARP may not cache long
    
    >>> pid = Popen(["arp", "-n", IP], stdout=PIPE)
    >>> s = pid.communicate()[0]
    >>> mac = re.search(r"(([a-f\d]{1,2}\:){5}[a-f\d]{1,2})", s).groups()[0]
    >>> mac
    "fe:fd:61:6b:8a:0f"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 222k
  • Answers 222k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer If you are willing to wait a bit, Adobe is… May 13, 2026 at 12:23 am
  • Editorial Team
    Editorial Team added an answer Wouldn't it be easier to use XPath Tests? I imagine… May 13, 2026 at 12:23 am
  • Editorial Team
    Editorial Team added an answer iPhone's zoom is a graphical thing - it does not… May 13, 2026 at 12:23 am

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I want use html5's new tag to play a wav file (currently only supported
I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
In order to apply a triggered animation to all ToolTip s in my app,
I have a French site that I want to parse, but am running into

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.