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 6916213
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T09:34:23+00:00 2026-05-27T09:34:23+00:00

I making MAC addr generator and currently I have this problem. mac1=001122334455 mac2=001122334695 mac1

  • 0

I making MAC addr generator and currently I have this problem.

mac1="001122334455"
mac2="001122334695"

mac1 = [mac1[x:x+2] for x in xrange(0,len(mac1),2)]
mac2 = [mac2[x:x+2] for x in xrange(0,len(mac2),2)]
k=0
for item in mac1:
    mac1[k] = "%d" % int(mac1[k], 16)
    mac2[k] = "%d" % int(mac2[k], 16)
    mac1[k]=int(mac1[k])
    mac2[k]=int(mac2[k])
    k=k+1

while mac1 != mac2:
    #print mac1

    print "%X0:%X:%X:%X:%X:%X" % (mac1[0], mac1[1], mac1[2], mac1[3], mac1[4], mac1[5])
    mac1[5] = int(mac1[5]) + 1
    if int(mac1[5]) > 255:
        #mac1[5] = 00
        mac1[4] = int(mac1[4]) +1
        if int(mac1[4]) > 255:
            mac1[3] = int(mac1[3]) + 1
            if int(mac1[3]) > 255:
                mac1[2] = int(mac1[2]) +1
                if int(mac1[2]) > 255:
                    mac1[1] = int(mac1[1]) +1

I need to start generating fifth byte from beginning so I defined mac1[5] = 00, but instead of two 0 I only get one 0?

  • 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-27T09:34:23+00:00Added an answer on May 27, 2026 at 9:34 am

    Much simpler to just treat the entire mac as one number:

    mac1 = 0x1122334455
    mac2 = 0x1122334695
    for i in xrange(mac1, mac2+1):
        s = "%012x" % i
        print ':'.join(s[j:j+2] for j in range(0,12,2)))
    

    See Display number with leading zeros

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm making a new Mac OS X application. (not an iPhone app) This is
Making my first steps in RIA Services (VS2010Beta2) and i encountered this problem: created
I am making this web site http://www.christopherbier.com/gbg/locations.html In safari on mac the content div
I am making an HttpWebRequest at a url similar to this: http://mysite.com/search?query=my+search+string Problem is,
Making my first steps with NHibernate, I'm trying to have it creating my Tables
This code is basically making an HTTP call, when it tries it, it just
I'm making the transition from programming iPhone to native Mac applications. One part that
I´m using Mac OS Lion, with java version 1.6.0_26 I'm making a small app
I'v been making a simple target card reading server on eclipse, on my mac
for some days i have been struggeling with making only certain ips accessing my

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.