Path: csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.069 X-Spam-Evidence: '*H*': 0.86; '*S*': 0.00; 'subject:How': 0.10; 'windows': 0.15; 'from:addr:torriem': 0.16; 'from:name:michael torrie': 0.16; 'subject:port': 0.16; 'wmi': 0.16; 'wrote:': 0.18; 'seems': 0.21; 'import': 0.22; 'this?': 0.23; 'header:User- Agent:1': 0.23; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'am,': 0.29; 'specified': 0.30; "i'm": 0.30; 'getting': 0.31; 'file': 0.32; 'linux': 0.33; 'mac': 0.33; 'could': 0.34; 'there': 0.35; 'subject:?': 0.36; 'two': 0.37; 'message-id:@gmail.com': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'how': 0.40; 'most': 0.60; 'address': 0.63; 'computers': 0.72; 'subject:get': 0.81; 'imagine': 0.93 X-Virus-Scanned: amavisd-new at torriefamily.org Date: Sat, 11 Jan 2014 09:34:35 -0700 From: Michael Torrie User-Agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.12) Gecko/20130105 Thunderbird/10.0.12 MIME-Version: 1.0 To: python-list@python.org Subject: Re: How to get Mac address of ethernet port? References: <6a5ceb3f-021d-4acc-b618-ce53530fa2dd@googlegroups.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 20 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1389458116 news.xs4all.nl 2852 [2001:888:2000:d::a6]:49770 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:63716 On 01/11/2014 07:35 AM, Andriy Kornatskyy wrote: > Sam, > > How about this? > > from uuid import getnode as get_mac > '%012x' % get_mac() This seems to work if you have only one ethernet adapter. Most computers have two (wired and wireless) adapters. Getting a mac address is platform-specific, and the OP has not specified what OS he is using. On Windows I imagine you'd have to access the WMI subsystem in Windows. On Linux you could access the /sys/devices/virtual/net/ file in the sysfs filesystem. I'm sure there are other ways. No idea on OS X.