https://github.com/laminko/madmac
madmac: MAC address generator
https://github.com/laminko/madmac
dummy-data-generator macaddr macaddress networking python python3 tool utility
Last synced: 16 days ago
JSON representation
madmac: MAC address generator
- Host: GitHub
- URL: https://github.com/laminko/madmac
- Owner: laminko
- License: mit
- Created: 2019-05-30T09:26:43.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T05:32:43.000Z (over 3 years ago)
- Last Synced: 2026-04-06T14:15:33.244Z (2 months ago)
- Topics: dummy-data-generator, macaddr, macaddress, networking, python, python3, tool, utility
- Language: Python
- Homepage: https://laminko.github.io/madmac/
- Size: 49.8 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MadMAC  [](https://travis-ci.com/laminko/madmac) [](https://codecov.io/gh/laminko/madmac)  [](https://lgtm.com/projects/g/laminko/madmac/alerts/)
MAC address generator library for testers.
## Content
- [Installation](#installation)
- [Usage](#usage)
- [Command](#as-a-command)
- [Module](#as-a-module)
### Installation
Using `pip`:
> `pip install madmac`
Using source:
```bash
$ git clone https://github.com/laminko/madmac.git
$ cd madmac
$ python setup.py install
```
### Usage
#### As a command
Can be used `madmac` as command. The following will generate random MAC address.
```bash
madmac
```
To see help, enter `madmac --help`.
```bash
madmac --help
usage: madmac [-h] [-o OUI] [-r START] [-s STOP] [-t TOTAL] [-d DELIMITER]
[-c CASE]
MAC address generator library for testers.
optional arguments:
-h, --help show this help message and exit
-o OUI, --oui OUI 6-digit organizationally unique identifier
-r START, --start START
NIC specific start address
-s STOP, --stop STOP NIC specific end address
-t TOTAL, --total TOTAL
Number of MACs to generate
-d DELIMITER, --delimiter DELIMITER
Delimiter for MAC address
-c CASE, --case CASE Use lower or upper
```
> **NOTE**: `madmac` is not a binary file. You need to install python 3.5 to execute the command.
#### As a module
Import `MacGenerator` class from `madmac` module. And create an object using `MacGenerator` and call its member `generate()` function. `generate()` function will return python generator object.
The following code will generate single MAC address using default values.
```python
from madmac import MacGenerator
macg = MacGenerator()
macs = macg.generate() # generator object which contains one item
from pprint import pprint
pprint(list(macs))
```
Default values are as follows:
```python
# 'oui': None,
# 'start': None,
# 'stop': None,
# 'total': 1,
# 'delimiter': ':',
# 'case': 'lower'
```
One can provide `oui`:
```python
from madmac import MacGenerator
macg = MacGenerator(oui='F0-9F-C2')
list(macg.generate())
```
Also specify `start` address and `end` address if they are known:
```python
from madmac import MacGenerator
start = '00-B0-A0'
stop = '00-B0-DF'
macg = MacGenerator(start=start, stop=stop)
```
> **NOTE**: Above snippet describes to use random `oui`, but to use certain range from `start` and `stop` values. It will ignore `total` parameter. Delimiter and Case will be default values.
Sometimes, we might want to generate certain amount of MAC addresses:
```python
from madmac import MacGenerator
macg = MacGenerator(total=100)
```