Ce contenu est fourni sous licence CC BY-NC-SA 4.0
Notes sur ipcalc
Introduction
La commande ipcalc permet de se simplifier la vie lorsque l’on fait des calculs sur des adresses IPv4. Elle permet de calculer automatiquement le broadcast, le nombre de machines, … d’un réseau qu’on lui passe en argument.
Installation
sudo apt-get install ipcalc
Utilisation basique
cedric@portable:~ ipcalc 172.16.1.0/24
Address: 172.16.1.0 10101100.00010000.00000001. 00000000
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
=>
Network: 172.16.1.0/24 10101100.00010000.00000001. 00000000
HostMin: 172.16.1.1 10101100.00010000.00000001. 00000001
HostMax: 172.16.1.254 10101100.00010000.00000001. 11111110
Broadcast: 172.16.1.255 10101100.00010000.00000001. 11111111
Hosts/Net: 254 Class B, Private Internet
cedric@portable:~/ ipcalc 172.16.1.0/255.255.255.0
Address: 172.16.1.0 10101100.00010000.00000001. 00000000
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
=>
Network: 172.16.1.0/24 10101100.00010000.00000001. 00000000
HostMin: 172.16.1.1 10101100.00010000.00000001. 00000001
HostMax: 172.16.1.254 10101100.00010000.00000001. 11111110
Broadcast: 172.16.1.255 10101100.00010000.00000001. 11111111
Hosts/Net: 254 Class B, Private Internet
Découper un réseau en sous-réseaux
Ici, j’ai un réseau /24 que je veux découper en sous-réseaux /26 :
cedric@portable:~ ipcalc 172.16.1.0/24 26
Address: 172.16.1.0 10101100.00010000.00000001. 00000000
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
=>
Network: 172.16.1.0/24 10101100.00010000.00000001. 00000000
HostMin: 172.16.1.1 10101100.00010000.00000001. 00000001
HostMax: 172.16.1.254 10101100.00010000.00000001. 11111110
Broadcast: 172.16.1.255 10101100.00010000.00000001. 11111111
Hosts/Net: 254 Class B, Private Internet
Subnets after transition from /24 to /26
Netmask: 255.255.255.192 = 26 11111111.11111111.11111111.11 000000
Wildcard: 0.0.0.63 00000000.00000000.00000000.00 111111
1.
Network: 172.16.1.0/26 10101100.00010000.00000001.00 000000
HostMin: 172.16.1.1 10101100.00010000.00000001.00 000001
HostMax: 172.16.1.62 10101100.00010000.00000001.00 111110
Broadcast: 172.16.1.63 10101100.00010000.00000001.00 111111
Hosts/Net: 62 Class B, Private Internet
2.
Network: 172.16.1.64/26 10101100.00010000.00000001.01 000000
HostMin: 172.16.1.65 10101100.00010000.00000001.01 000001
HostMax: 172.16.1.126 10101100.00010000.00000001.01 111110
Broadcast: 172.16.1.127 10101100.00010000.00000001.01 111111
Hosts/Net: 62 Class B, Private Internet
3.
Network: 172.16.1.128/26 10101100.00010000.00000001.10 000000
HostMin: 172.16.1.129 10101100.00010000.00000001.10 000001
HostMax: 172.16.1.190 10101100.00010000.00000001.10 111110
Broadcast: 172.16.1.191 10101100.00010000.00000001.10 111111
Hosts/Net: 62 Class B, Private Internet
4.
Network: 172.16.1.192/26 10101100.00010000.00000001.11 000000
HostMin: 172.16.1.193 10101100.00010000.00000001.11 000001
HostMax: 172.16.1.254 10101100.00010000.00000001.11 111110
Broadcast: 172.16.1.255 10101100.00010000.00000001.11 111111
Hosts/Net: 62 Class B, Private Internet
Subnets: 4
Hosts: 248
Ici, j’ai un réseau /24 que je veux découper en différents 3 sous-réseaux qui contiennent respectivement au moins 100 machines, au moins 20 machines et au moins 20 machines :
cedric@portable:~ ipcalc 172.16.1.0/24 -s 100 20 20
Address: 172.16.1.0 10101100.00010000.00000001. 00000000
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
=>
Network: 172.16.1.0/24 10101100.00010000.00000001. 00000000
HostMin: 172.16.1.1 10101100.00010000.00000001. 00000001
HostMax: 172.16.1.254 10101100.00010000.00000001. 11111110
Broadcast: 172.16.1.255 10101100.00010000.00000001. 11111111
Hosts/Net: 254 Class B, Private Internet
1. Requested size: 100 hosts
Netmask: 255.255.255.128 = 25 11111111.11111111.11111111.1 0000000
Network: 172.16.1.0/25 10101100.00010000.00000001.0 0000000
HostMin: 172.16.1.1 10101100.00010000.00000001.0 0000001
HostMax: 172.16.1.126 10101100.00010000.00000001.0 1111110
Broadcast: 172.16.1.127 10101100.00010000.00000001.0 1111111
Hosts/Net: 126 Class B, Private Internet
2. Requested size: 20 hosts
Netmask: 255.255.255.224 = 27 11111111.11111111.11111111.111 00000
Network: 172.16.1.128/27 10101100.00010000.00000001.100 00000
HostMin: 172.16.1.129 10101100.00010000.00000001.100 00001
HostMax: 172.16.1.158 10101100.00010000.00000001.100 11110
Broadcast: 172.16.1.159 10101100.00010000.00000001.100 11111
Hosts/Net: 30 Class B, Private Internet
3. Requested size: 20 hosts
Netmask: 255.255.255.224 = 27 11111111.11111111.11111111.111 00000
Network: 172.16.1.160/27 10101100.00010000.00000001.101 00000
HostMin: 172.16.1.161 10101100.00010000.00000001.101 00001
HostMax: 172.16.1.190 10101100.00010000.00000001.101 11110
Broadcast: 172.16.1.191 10101100.00010000.00000001.101 11111
Hosts/Net: 30 Class B, Private Internet
Needed size: 192 addresses.
Used network: 172.16.1.0/24
Unused:
172.16.1.192/26
À noter : l’outil optimise la consommation de l’espace d’adressage !
Ce contenu est fourni sous licence CC BY-NC-SA 4.0