Cédric Temple

Administrateur système en logiciels libres

ipv6calc, calcul sur des adresses IPv6

2019-05-21 » notes pour plus tard

Ce contenu est fourni sous licence CC BY-NC-SA 4.0

Notes sur ipv6calc

Introduction

La commande ipv6calc permet de se simplifier la vie lorsque l’on fait des calculs sur des adresses IPv6. Elle permet de calculer automatiquement le préfixe, les adresses non compressées, le reverse, … d’un réseau qu’on lui passe en argument.

Installation

sudo apt-get install ipv6calc

Voir l’adresse réseau d’une adresse IPv6 complète

cedric@portable:~ ipv6calc --out ipv6addr --maskprefix --in ipv6addr 2001:db8:320:b24:1a03:73ff:fe3a:567f/64
2001:db8:320:b24::/64
cedric@portable:~ ipv6calc --out ipv6addr --maskprefix --in ipv6addr 2001:db8:320:b24:1a03:73ff:fe3a:567f/48
2001:db8:320::/48

Choisir la casse de la sortie

cedric@portable:~ ipv6calc --out ipv6addr --maskprefix -u --in ipv6addr 2001:db8:320:b24:1a03:73ff:fe3a:567f/48
2001:DB8:320::/48
cedric@portable:~ ipv6calc --out ipv6addr --maskprefix -l --in ipv6addr 2001:db8:320:b24:1a03:73ff:fe3a:567f/48
2001:db8:320::/48

Voir le préfixe d’une adresse réseau

# par préfixe, on entend "la partie gauche de l'adresse"
cedric@portable:~ ipv6calc --out ipv6addr --printprefix --in ipv6addr 2001:db8:320:b24:1a03:73ff:fe3a:567f/64
2001:db8:320:b24
cedric@portable:~ ipv6calc --out ipv6addr --printprefix --in ipv6addr 2001:db8:320:b24:1a03:73ff:fe3a:567f/32
2001:db8

Voir le suffixe d’une adresse réseau

# par suffixe, on entend "la partie droite de l'adresse"
cedric@portable:~ ipv6calc --out ipv6addr --printsuffix --in ipv6addr 2001:db8:320:b24:1a03:73ff:fe3a:567f/64
1a03:73ff:fe3a:567f
# avec une adresse /48
cedric@portable:~ ipv6calc --out ipv6addr --printsuffix --in ipv6addr 2001:db8:320:b24:1a03:73ff:fe3a:567f/48
b24:1a03:73ff:fe3a:567f

Voir les adresses au format non compressé

# adresse IPv6
cedric@portable:~ ipv6calc --out ipv6addr --in ipv6addr 2001:db8:320:b24::1/64
2001:db8:320:b24::1/64
cedric@portable:~ ipv6calc --out ipv6addr --printuncompressed --in ipv6addr 2001:db8:320:b24::1/64
2001:db8:320:b24:0:0:0:1/64
cedric@portable:~ ipv6calc --out ipv6addr --printfulluncompressed --in ipv6addr 2001:db8:320:b24::1/64
2001:0db8:0320:0b24:0000:0000:0000:0001/64
# préfixe
cedric@portable:~ ipv6calc --out ipv6addr --printprefix --in ipv6addr 2001:db8::1/64
2001:db8:0:0
cedric@portable:~ ipv6calc --out ipv6addr --printprefix --printuncompressed --in ipv6addr 2001:db8::1/64
2001:db8:0:0
cedric@portable:~ ipv6calc --out ipv6addr --printprefix --printfulluncompressed --in ipv6addr 2001:db8::1/64
2001:0db8:0000:0000

Calculer l’EUI-64 modifié depuis une adresse MAC

cedric@portable:~ ipv6calc --in mac --action geneui64 --out eui64 18:03:73:3a:56:7f
1a03:73ff:fe3a:567f

Obtenir le reverse d’une adresse IPv6

On peut obtenir le reverse d’une adresse IPv6, bien pratique pour un outil comme nsupdate !

cedric@portable:~ ipv6calc -I ipv6addr 2001:db8:320:b24::1 -O revnibbles.arpa 
1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.2.b.0.0.2.3.0.8.b.d.0.1.0.0.2.ip6.arpa.

Obtenir le reverse d’une adresse IPv4

ipv6calc permet également d’obtenir le reverse d’une adresse IPv4. Bien pratique pour des outils comme nsupdate !

cedric@portable:~ ipv6calc -I ipv4addr 172.16.17.18 -O revipv4
18.17.16.172.in-addr.arpa.

Ce contenu est fourni sous licence CC BY-NC-SA 4.0