MAC address

Ajay abra9823 at mail.usyd.edu.au
Mon Sep 20 07:23:15 EDT 2004


Quoting Heiko Wundram <heikowu at ceosg.de>:

> Am Montag, 20. September 2004 08:51 schrieb Ajay:
> > is it possible to change your MAC address from a program?
> > Can i do that using Python?
>
> Depends on what OS you're under... Under Linux (and I'd guess that *BSD
> works
> somewhat similar), you can change the hardware address of some network
> device
> using:
>
> ifconfig <device> down
> ifconfig <device> hw <hw-type> <address>
> ifconfig <device> up
>
> So, for example, to change my MAC to some random number (which is
> invalid,
> because it's a broadcast address):
>
> ifconfig eth0 down
> ifconfig eth0 hw ether fffefdfcfbfa
> ifconfig eth0 up
>
> Of course, you need to call all this as root.
>
> From Python, that would be:
>
> import os
>
> def setmac(device,mac):
>  os.system("ifconfig %s down" % device)
>  os.system("ifconfig %s hw ether %s" % (device,mac))
>  os.system("ifconfig %s up" % device)
>
> Under Windows (2000, XP, NT?) there's also the possibility to change the
> MAC
> of a network device, but I don't know if you can access this OS
> functionality
> from somewhere else than the dialog box which offers it (maybe you can
> change
> it somewhere in the registry, don't know).

thanks
its actually windows that i would like to find out about.
what i am trying to do is to anonymize client address by picking a random
MAC address and using that instead

>
> Heiko.
> --
> http://mail.python.org/mailman/listinfo/python-list
>
>


----------------------------------------------------------------
This message was sent using IMP, the Internet Messaging Program.



More information about the Python-list mailing list