como posso gerar um endereço MAC incremental como 00: 00: 00: 00: 01 00: 00: 00: 00: 02

0

como eu posso gerar um endereço MAC incremental como

00:00:00:00:01
00:00:00:00:02
    
por moshe 24.02.2014 / 07:43

1 resposta

2

Você apenas incrementa um contador e usa if para isso

printf %0.16x "$counter" | sed -e 's/../&:/g' -e 's/:$//'

ou (maiúsculas)

printf %0.16X "$counter" | sed -e 's/../&:/g' -e 's/:$//'

Por exemplo:

$ counter=0;
$ while [ "$counter" -lt 11 ] ; do 
    let counter++;
    printf "%0.16x\n" "$counter" | sed -e 's/../&:/g' -e 's/:$//'; 
 done
00:00:00:00:00:00:00:01
00:00:00:00:00:00:00:02
00:00:00:00:00:00:00:03
00:00:00:00:00:00:00:04
00:00:00:00:00:00:00:05
00:00:00:00:00:00:00:06
00:00:00:00:00:00:00:07
00:00:00:00:00:00:00:08
00:00:00:00:00:00:00:09
00:00:00:00:00:00:00:0a
00:00:00:00:00:00:00:0b
    
por 24.02.2014 / 07:53

Tags