[Tutor] Source PC MAC address

Pierre Barbier de Reuille pierre.barbier at cirad.fr
Thu Aug 25 10:42:29 CEST 2005


The problem is: you cannot do that using the socket interface as the OS
IP stack will drop all the ethernet informations. However, you can ask
the network explicitly for the MAC address handling some IP address: the
protocol is called ARP (RFC 826). To do so, the Python package dpkt
(http://www.monkey.org/~dugsong/dpkt/) might be interesting for you
(although I never used it ...) as it includes a module to handle ARP
requests.

Pierre

PS: do not forget to send your answers to Python Tutor also ... BTW,
could it be possible de configure the list so that the "reply-to" field
is set to the Python Tutor list instead of the sender ?

Johan Geldenhuys a écrit :
> Is there a other way of doing this? Getting the MAC. I am on a ethernet
> network.
> 
> Johan 
> 
> 
> 
> 
> 
> ------------------------------------------------------------------------
> 
> Sujet:
> Re: [Tutor] Source PC MAC address
> Expéditeur:
> Pierre Barbier de Reuille <pierre.barbier at cirad.fr>
> Date:
> Wed, 24 Aug 2005 17:00:46 +0200
> Destinataire:
> Python Tutor <tutor at python.org>
> 
> Destinataire:
> Python Tutor <tutor at python.org>
> 
> Return-Path:
> <tutor-bounces at python.org>
> Received:
> from earth.accesstel.co.za ([unix socket]) by earth (Cyrus v2.1.9) with
> LMTP; Wed, 24 Aug 2005 16:59:09 +0200
> X-Sieve:
> CMU Sieve 2.2
> Received:
> by earth.accesstel.co.za (Postfix, from userid 65534) id F00D011DD9;
> Wed, 24 Aug 2005 16:59:08 +0200 (SAST)
> Received:
> from localhost.localdomain (localhost [127.0.0.1]) by
> earth.accesstel.co.za (Postfix) with ESMTP id 11EF911DD9 for
> <johan at accesstel.co.za>; Wed, 24 Aug 2005 16:59:08 +0200 (SAST)
> Received:
> from smtp-vbr1.xs4all.nl (smtp-vbr1.xs4all.nl [194.109.24.21]) by
> gateway.azitech.co.za (8.11.6/8.11.6) with ESMTP id j7OEnmr23311 for
> <johan at accesstel.co.za>; Wed, 24 Aug 2005 16:49:49 +0200
> Received:
> from bag.python.org (bag.python.org [194.109.207.14]) by
> smtp-vbr1.xs4all.nl (8.13.3/8.13.3) with ESMTP id j7OEvApb033830; Wed,
> 24 Aug 2005 16:57:10 +0200 (CEST) (envelope-from tutor-bounces at python.org)
> Received:
> from bag.python.org (bag [127.0.0.1]) by bag.python.org (Postfix) with
> ESMTP id DA7B61E400F; Wed, 24 Aug 2005 16:57:15 +0200 (CEST)
> X-Original-To:
> tutor at python.org
> Received:
> from bag.python.org (bag [127.0.0.1]) by bag.python.org (Postfix) with
> ESMTP id 5382C1E4003 for <tutor at python.org>; Wed, 24 Aug 2005 16:57:13
> +0200 (CEST)
> Received:
> from bag (HELO bag.python.org) (127.0.0.1) by bag.python.org with SMTP;
> 24 Aug 2005 16:57:13 +0200
> Received:
> from auvergne.cirad.fr (auvergne.cirad.fr [195.221.173.145]) by
> bag.python.org (Postfix) with ESMTP for <tutor at python.org>; Wed, 24 Aug
> 2005 16:57:13 +0200 (CEST)
> Received:
> from auvergne.cirad.fr (auvergne.cirad.fr [195.221.173.145]) by
> auvergne.cirad.fr (8.13.2/8.13.2) with ESMTP id j7OEsnoG028104 for
> <tutor at python.org>; Wed, 24 Aug 2005 16:54:49 +0200
> Received:
> from [195.221.175.162] (barbier at pcps-162.cirad.fr [195.221.175.162]) by
> auvergne.cirad.fr (8.13.2/8.13.2) with ESMTP id j7OEsmMS028090 for
> <tutor at python.org>; Wed, 24 Aug 2005 16:54:48 +0200
> ID du Message:
> <430C8B9E.8020505 at cirad.fr>
> Agent utilisateur:
> Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.6) Gecko/20050817
> Thunderbird/1.0.2 Mnenhy/0.7
> X-Accept-Language:
> fr, en
> Version de MIME:
> 1.0
> Références:
> <1124880684.9086.7.camel at KMA.accesstel>
> In-Reply-To:
> <1124880684.9086.7.camel at KMA.accesstel>
> X-Enigmail-Version:
> 0.91.0.0
> X-BeenThere:
> tutor at python.org
> X-Mailman-Version:
> 2.1.6
> Precedence:
> list
> List-Id:
> Discussion for learning programming with Python <tutor.python.org>
> List-Unsubscribe:
> <http://mail.python.org/mailman/listinfo/tutor>,
> <mailto:tutor-request at python.org?subject=unsubscribe>
> List-Archive:
> <http://mail.python.org/pipermail/tutor>
> List-Post:
> <mailto:tutor at python.org>
> List-Help:
> <mailto:tutor-request at python.org?subject=help>
> List-Subscribe:
> <http://mail.python.org/mailman/listinfo/tutor>,
> <mailto:tutor-request at python.org?subject=subscribe>
> Content-Type:
> text/plain; charset="iso-8859-15"
> Expéditeur:
> tutor-bounces at python.org
> Errors-To:
> tutor-bounces at python.org
> X-Virus-Scanned:
> by XS4ALL Virus Scanner
> X-Accesstel-MailScanner-Information:
> Please contact Accesstel for information
> X-Accesstel-MailScanner:
> Found to be clean
> X-MIME-Autoconverted:
> from quoted-printable to 8bit by gateway.azitech.co.za id j7OEnmr23311
> X-Fetched:
> by SuSE Linux Openexchange Server from
> accesstel^johan at mail.accesstel.co.za for johan at accesstel.co.za via pop
> X-Spam-Status:
> No, hits=-7.6 required=4.8
> tests=AWL,BAYES_01,IN_REP_TO,QUOTED_EMAIL_TEXT,REFERENCES,
> REPLY_WITH_QUOTES,SIGNATURE_LONG_SPARSE, USER_AGENT_MOZILLA_UA
> autolearn=ham version=2.55
> X-Spam-Checker-Version:
> SpamAssassin 2.55 (1.174.2.19-2003-05-19-exp)
> Content-Transfer-Encoding:
> 8bit
> 
> 
> Socket is built up on IP, not on Ethernet: you have no way of finding a
> MAC address using sockets simply because it may not exist one ! (if
> you're not on an Ethernet network) You need to access lower levels of
> network and probably access directly the network packet as your network
> card is sending it to your OS !
> 
> Pierre
> 
> Johan Geldenhuys a écrit :
> 
>>Hi List,
>>I am doing some networking programming and would like to limit access to
>>my socket server on the the source devices' MAC address.
>>I know the IP from where the connection is coming, but how could I find
>>out what the MAC of the source device is?
>>Any quick answers / ideas?
>>Is there a build-in function in socket that can do this?
>>
>>Thanks,
>>
>>Johan 
>>
>>
>>
>>
>>
>>------------------------------------------------------------------------
>>
>>_______________________________________________
>>Tutor maillist  -  Tutor at python.org
>>http://mail.python.org/mailman/listinfo/tutor
> 
> 

-- 
Pierre Barbier de Reuille

INRA - UMR Cirad/Inra/Cnrs/Univ.MontpellierII AMAP
Botanique et Bio-informatique de l'Architecture des Plantes
TA40/PSII, Boulevard de la Lironde
34398 MONTPELLIER CEDEX 5, France

tel   : (33) 4 67 61 65 77    fax   : (33) 4 67 61 56 68


More information about the Tutor mailing list