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

  • SEARCH
  • Home
  • 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 6968925
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T16:30:55+00:00 2026-05-27T16:30:55+00:00

I want to get the MAC address for my network interface on Linux. I

  • 0

I want to get the MAC address for my network interface on Linux. I am using Python with PyQt4 modules. When I run this code:

form PyQt4.QtNetwork import *
def getinfo():
  all_info = QNetworkInterface().allInterfaces()
  for interface in all_info:
        print interface.hardwareAddress()," ",interface.humanReadableName()

I get this outout:

00:00:00:00:00:00   lo
00:26:2D:8C:8F:B3   eth3
F0:7B:CB:3B:82:2B   wlan3
  ppp0

It works fine with eth3 and wlan3, but with ppp0 which runs on my mobile broadband modem, the MAC address doesn’t appear.

  • 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-27T16:30:56+00:00Added an answer on May 27, 2026 at 4:30 pm

    ppp doesn’t use a MAC (hardware) address:

    ppp0      Link encap:Point-to-Point Protocol
              inet addr:172.27.42.1  P-t-P:172.27.42.17  Mask:255.255.255.255
              UP POINTOPOINT RUNNING NOARP MULTICAST  MTU:1500  Metric:1
              RX packets:416 errors:0 dropped:0 overruns:0 frame:0
              TX packets:397 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:3
              RX bytes:253765 (247.8 Kb)  TX bytes:62621 (61.1 Kb)
    

    In general, if you’re looking for network interface management in Python, look no further than netifaces. It is designed to be cross-platform on Mac OS X, Linux, and Windows.

    >>> import netifaces as ni
    >>> ni.interfaces()
    ['lo', 'eth0', 'eth1', 'vboxnet0', 'dummy1']
    >>> ni.ifaddresses('eth0')
    {17: [{'broadcast': 'ff:ff:ff:ff:ff:ff', 'addr': '00:02:55:7b:b2:f6'}], 2: [{'broadcast': '24.19.161.7', 'netmask': '255.255.255.248', 'addr': '24.19.161.6'}], 10: [{'netmask': 'ffff:ffff:ffff:ffff::', 'addr': 'fe80::202:55ff:fe7b:b2f6%eth0'}]}
    >>> 
    >>> ni.ifaddresses.__doc__
    'Obtain information about the specified network interface.\n\nReturns a dict whose keys are equal to the address family constants,\ne.g. netifaces.AF_INET, and whose values are a list of addresses in\nthat family that are attached to the network interface.'
    >>> # for the IPv4 address of eth0
    >>> ni.ifaddresses('eth0')[2][0]['addr']
    '24.19.161.6'
    

    The numbers used to index protocols are from /usr/include/linux/socket.h (in Linux)…

    #define AF_INET         2       /* Internet IP Protocol         */
    #define AF_INET6        10      /* IP version 6                 */
    #define AF_PACKET       17      /* Packet family                */
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have found this code to get a MAC address, but it returns a
I'm running Mac OS 10.6. I want to run top to get memory usage,
I'm trying to get the MAC address for the network adapter of the user's
how to get mac address of external IP in C# ? E.g I want
I want to get the mac address of the bluetooth device on the pc
I want to accesss the mac address of the computer using c#. I have
I just want to know how to get the mac address of a remote
Possible Duplicate: Reliable method to get machine's MAC address in C# I want to
I want to get other process' argv like ps. I'm using Mac OS X
i want to get client MAC address (in jsp,java) it's possible? how to do?

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.