Para parceiros
O conjunto de documentação deste produto faz o possível para usar uma linguagem imparcial. Para os fins deste conjunto de documentação, a imparcialidade é definida como uma linguagem que não implica em discriminação baseada em idade, deficiência, gênero, identidade racial, identidade étnica, orientação sexual, status socioeconômico e interseccionalidade. Pode haver exceções na documentação devido à linguagem codificada nas interfaces de usuário do software do produto, linguagem usada com base na documentação de RFP ou linguagem usada por um produto de terceiros referenciado. Saiba mais sobre como a Cisco está usando a linguagem inclusiva.
A Cisco traduziu este documento com a ajuda de tecnologias de tradução automática e humana para oferecer conteúdo de suporte aos seus usuários no seu próprio idioma, independentemente da localização. Observe que mesmo a melhor tradução automática não será tão precisa quanto as realizadas por um tradutor profissional. A Cisco Systems, Inc. não se responsabiliza pela precisão destas traduções e recomenda que o documento original em inglês (link fornecido) seja sempre consultado.
Este documento fornece as informações básicas necessárias para configurar seu roteador para rotear IP, como a forma como os endereços são divididos e como a divisão em sub-redes funciona. You learn how to assign each interface on the router an IP address with a unique subnet. Exemplos são incluídos para ajudar a amarrar tudo.
A Cisco recomenda que você tenha uma compreensão básica de números binários e decimais.
Este documento não se restringe a versões de software e hardware específicas.
The information in this document was created from the devices in a specific lab environment. All of the devices used in this document started with a cleared (default) configuration. If your network is live, make sure that you understand the potential impact of any command.
Se as definições tiverem sido úteis, use estes termos de vocabulário para começar:
Endereço - a identificação numérica exclusiva atribuída a um host ou uma interface em uma rede.
Sub-rede - uma parte de uma rede que compartilha um determinado endereço de sub-rede.
Máscara de sub-rede - uma combinação de 32 bits usada para descrever qual parte de um endereço refere-se à sub-rede e qual parte refere-se ao host.
Interface - uma conexão de rede.
If you have already received your legitimate address(es) from the Internet Network Information Center (InterNIC), you are ready to begin. Se você não planeja se conectar à Internet, a Cisco sugere utilizar endereços reservados do RFC 1918 .
Um endereço IP é um endereço usado para identificar de maneira única um dispositivo em uma rede IP. O endereço é composto de 32 bits binários, que podem ser divisíveis em uma porção de rede e de host com a ajuda de uma máscara de sub-rede. The 32 binary bits are broken into four octets (1 octet = 8 bits). Each octet is converted to decimal and separated by a period (dot). For this reason, an IP address is said to be expressed in dotted decimal format (for example, 172.16.81.100). The value in each octet ranges from 0 to 255 decimal, or 00000000 - 11111111 binary.
Here is how binary octets convert to decimal: O bit mais a direita, ou o bit menos significativo, de um octeto, tem um valor de 20. O bit à esquerda dele guarda um valor de 21. Isso continua até o bit mais à esquerda, ou o bit mais significativo, que guarda um valor de 27. So if all binary bits are a one, the decimal equivalent would be 255 as shown here:
1 1 1 1 1 1 1 1 128 64 32 16 8 4 2 1 (128+64+32+16+8+4+2+1=255)
Here is a sample octet conversion when not all of the bits are set to 1.
0 1 0 0 0 0 0 1 0 64 0 0 0 0 0 1 (0+64+0+0+0+0+0+1=65)
E essa amostra mostra um endereço IP representado em número binário e decimal.
10. 1. 23. 19 (decimal) 00001010.00000001.00010111.00010011 (binary)
These octets are broken down to provide an addressing scheme that can accommodate large and small networks. There are five different classes of networks, A to E. Este documento trata das classes A a C, pois as classes D e E são reservadas e discuti-las vai além do propósito deste documento.
Note: Observe também que os termos "Classe A e Classe B" etc. são usados neste documento para ajudar a facilitar a compreensão do endereço IP e da sub-rede. These terms are rarely used in the industry anymore because of the introduction of classless interdomain routing (CIDR).
A classe de um endereço IP específico pode ser determinada pelos três bits de ordem primordial (os três bits mais à esquerda no primeiro octeto). Figure 1 shows the significance in the three high order bits and the range of addresses that fall into each class. For informational purposes, Class D and Class E addresses are also shown.
Figure 1
Em um endereço de classe A, o primeiro octeto é a porção de rede, então o exemplo de classe A na figura 1 tem um endereço de rede principal de 1.0.0.0 - 127.255.255.255. Os octetos 2, 3 e 4 (os próximos 24 bits) são para o gerente de rede dividir em sub-redes e hosts como parece adequado. Class A addresses are used for networks that have more than 65,536 hosts (actually, up to 16777214 hosts!).
Em um endereço de classe B, os dois primeiros octetos são a porção de rede, então o exemplo de classe B na Figura 1 tem um endereço de rede principal de 128.0.0.0 - 191.255.255.255. Os octetos 3 e 4 (16 bits) são para sub-redes e hosts locais. Class B addresses are used for networks that have between 256 and 65534 hosts.
In a Class C address, the first three octets are the network portion. O exemplo de Classe C na Figura 1 tem um endereço de rede principal de 192.0.0.0 - 223.255.255.255. O octeto 4 (8 bits) é para sub-redes e hosts locais - perfeito para redes com menos de 254 hosts.
A network mask helps you know which portion of the address identifies the network and which portion of the address identifies the node. Class A, B, and C networks have default masks, also known as natural masks, as shown here:
Class A: 255.0.0.0 Class B: 255.255.0.0 Class C: 255.255.255.0
An IP address on a Class A network that has not been subnetted would have an address/mask pair similar to: 8.20.15.1 255.0.0.0. Para ver como a máscara ajuda a identificar as peças da rede e do nó do endereço, converta o endereço e a máscara em números binários.
8.20.15.1 = 00001000.00010100.00001111.00000001 255.0.0.0 = 11111111.00000000.00000000.00000000
Quando você tiver o endereço e a máscara representados em binário, a identificação da rede e da ID do host será mais fácil. Any address bits which have corresponding mask bits set to 1 represent the network ID. Any address bits that have corresponding mask bits set to 0 represent the node ID.
8.20.15.1 = 00001000.00010100.00001111.00000001 255.0.0.0 = 11111111.00000000.00000000.00000000 ----------------------------------- net id | host id netid = 00001000 = 8 hostid = 00010100.00001111.00000001 = 20.15.1
Subnetting allows you to create multiple logical networks that exist within a single Class A, B, or C network. If you do not subnet, you are only able to use one network from your Class A, B, or C network, which is unrealistic.
Each data link on a network must have a unique network ID, with every node on that link being a member of the same network. If you break a major network (Class A, B, or C) into smaller subnetworks, it allows you to create a network of interconnecting subnetworks. Each data link on this network would then have a unique network/subnetwork ID. Qualquer dispositivo, ou gateway, que se conecta em redes/sub-redes tem n endereços IP distintos, um para cada rede/sub-rede que interconecta.
Para dividir uma rede em sub-redes, estenda a máscara natural com alguns dos bits da parte do ID do host do endereço para criar um ID de sub-rede. Por exemplo, dada uma rede de classe C 204.17.5.0 que tem uma máscara natural de 255.255.255.0, você pode criar sub-redes desta maneira:
204.17.5.0 - 11001100.00010001.00000101.00000000 255.255.255.224 - 11111111.11111111.11111111.11100000 --------------------------|sub|----
By extending the mask to be 255.255.255.224, you have taken three bits (indicated by "sub") from the original host portion of the address and used them to make subnets. With these three bits, it is possible to create eight subnets. With the remaining five host ID bits, each subnet can have up to 32 host addresses, 30 of which can actually be assigned to a device since host ids of all zeros or all ones are not allowed (it is very important to remember this). So, with this in mind, these subnets have been created.
204.17.5.0 255.255.255.224 host address range 1 to 30 204.17.5.32 255.255.255.224 host address range 33 to 62 204.17.5.64 255.255.255.224 host address range 65 to 94 204.17.5.96 255.255.255.224 host address range 97 to 126 204.17.5.128 255.255.255.224 host address range 129 to 158 204.17.5.160 255.255.255.224 host address range 161 to 190 204.17.5.192 255.255.255.224 host address range 193 to 222 204.17.5.224 255.255.255.224 host address range 225 to 254
Note: There are two ways to denote these masks. Em primeiro lugar, como você usa três bit a mais do que a máscara "natural" de classe C, você pode denotar estes endereços como se tivesse uma máscara de sub-rede de 3 bits. Or, secondly, the mask of 255.255.255.224 can also be denoted as /27 as there are 27 bits that are set in the mask. This second method is used with CIDR. Com este método, uma dessas redes pode ser descrita com o prefixo/comprimento da notação. For example, 204.17.5.32/27 denotes the network 204.17.5.32 255.255.255.224. Quando apropriado, o prefixo/notação de comprimento é usado para denotar a máscara por todo o resto deste documento.
The network subnetting scheme in this section allows for eight subnets, and the network might appear as:
Figure 2
Notice that each of the routers in Figure 2 is attached to four subnetworks, one subnetwork is common to both routers. Also, each router has an IP address for each subnetwork to which it is attached. Each subnetwork could potentially support up to 30 host addresses.
This brings up an interesting point. The more host bits you use for a subnet mask, the more subnets you have available. However, the more subnets available, the less host addresses available per subnet. For example, a Class C network of 204.17.5.0 and a mask of 255.255.255.224 (/27) allows you to have eight subnets, each with 32 host addresses (30 of which could be assigned to devices). Se você usar uma máscara de 255.255.255.240 (/28), o detalhamento será:
204.17.5.0 - 11001100.00010001.00000101.00000000 255.255.255.240 - 11111111.11111111.11111111.11110000 --------------------------|sub |---
Since you now have four bits to make subnets with, you only have four bits left for host addresses. So in this case you can have up to 16 subnets, each of which can have up to 16 host addresses (14 of which can be assigned to devices).
Take a look at how a Class B network might be subnetted. Se você tiver a rede 172.16.0.0, então você sabe que sua máscara natural é 255.255.0.0 ou 172.16.0.0/16. Extending the mask to anything beyond 255.255.0.0 means you are subnetting. You can quickly see that you have the ability to create a lot more subnets than with the Class C network. If you use a mask of 255.255.248.0 (/21), how many subnets and hosts per subnet does this allow for?
172.16.0.0 - 10101100.00010000.00000000.00000000 255.255.248.0 - 11111111.11111111.11111000.00000000 -----------------| sub |-----------
Você usa cinco bit dos bit originais do host para sub-redes. Isso permite que você tenha 32 sub-redes (25). After using the five bits for subnetting, you are left with 11 bits for host addresses. Isso permite que cada sub-rede tenha 2048 endereços de host (211), 2046 dos quais poderiam ser atribuídos a dispositivos.
Note: In the past, there were limitations to the use of a subnet 0 (all subnet bits are set to zero) and all ones subnet (all subnet bits set to one). Some devices would not allow the use of these subnets. Os dispositivos Cisco Systems permitem o uso dessas sub-redes quando o ip subnet zero
está configurado.
Now that you have an understanding of subnetting, put this knowledge to use. In this example, you are given two address / mask combinations, written with the prefix/length notation, which have been assigned to two devices. Your task is to determine if these devices are on the same subnet or different subnets. Você pode usar o endereço e a máscara de cada dispositivo para determinar a que sub-rede cada endereço pertence.
DeviceA: 172.16.17.30/20 DeviceB: 172.16.28.15/20
Determine a sub-rede para o Dispositivo A:
172.16.17.30 - 10101100.00010000.00010001.00011110 255.255.240.0 - 11111111.11111111.11110000.00000000 -----------------| sub|------------ subnet = 10101100.00010000.00010000.00000000 = 172.16.16.0
Looking at the address bits that have a corresponding mask bit set to one, and setting all the other address bits to zero (this is equivalent to performing a logical "AND" between the mask and address), shows you to which subnet this address belongs. In this case, DeviceA belongs to subnet 172.16.16.0.
Determine a sub-rede para o Dispositivo B
172.16.28.15 - 10101100.00010000.00011100.00001111 255.255.240.0 - 11111111.11111111.11110000.00000000 -----------------| sub|------------ subnet = 10101100.00010000.00010000.00000000 = 172.16.16.0
From these determinations, DeviceA and DeviceB have addresses that are part of the same subnet.
Given the Class C network of 204.15.5.0/24, subnet the network in order to create the network in Figure 3 with the host requirements shown.
Figure 3
Looking at the network shown in Figure 3, you can see that you are required to create five subnets. The largest subnet must support 28 host addresses. Is this possible with a Class C network? And if so, then how?
You can start by looking at the subnet requirement. In order to create the five needed subnets you would need to use three bits from the Class C host bits. Dois bits permitiria somente quatro sub-redes (22).
Since you need three subnet bits, that leaves you with five bits for the host portion of the address. How many hosts does this support? 25 = 32 (30 utilizáveis). This meets the requirement.
Therefore you have determined that it is possible to create this network with a Class C network. An example of how you might assign the subnetworks is:
netA: 204.15.5.0/27 host address range 1 to 30 netB: 204.15.5.32/27 host address range 33 to 62 netC: 204.15.5.64/27 host address range 65 to 94 netD: 204.15.5.96/27 host address range 97 to 126 netE: 204.15.5.128/27 host address range 129 to 158
In all of the previous examples of subnetting, notice that the same subnet mask was applied for all the subnets. This means that each subnet has the same number of available host addresses. You can need this in some cases, but, in most cases, having the same subnet mask for all subnets ends up wasting address space. For example, in the Sample Exercise 2 section, a class C network was split into eight equal-size subnets; however, each subnet did not utilize all available host addresses, which results in wasted address space. Figure 4 illustrates this wasted address space.
Figure 4
Figure 4 illustrates that of the subnets that are being used, NetA, NetC, and NetD have a lot of unused host address space. É possível que este foi um design deliberado projeto deliberado com vistas ao crescimento futuro, mas em muitos casos é apenas espaço de endereços desperdiçado devido ao fato de que a mesma máscara de sub-rede é usada para todas as sub-redes.
Variable Length Subnet Masks (VLSM) allows you to use different masks for each subnet, thereby using address space efficiently.
Given the same network and requirements as in Sample Exercise 2 develop a subnetting scheme with the use of VLSM, given:
netA: must support 14 hosts netB: must support 28 hosts netC: must support 2 hosts netD: must support 7 hosts netE: must support 28 host
Determine what mask allows the required number of hosts.
netA: requires a /28 (255.255.255.240) mask to support 14 hosts netB: requires a /27 (255.255.255.224) mask to support 28 hosts netC: requires a /30 (255.255.255.252) mask to support 2 hosts netD*: requires a /28 (255.255.255.240) mask to support 7 hosts netE: requires a /27 (255.255.255.224) mask to support 28 hosts * a /29 (255.255.255.248) would only allow 6 usable host addresses therefore netD requires a /28 mask.
The easiest way to assign the subnets is to assign the largest first. For example, you can assign in this manner:
netB: 204.15.5.0/27 host address range 1 to 30 netE: 204.15.5.32/27 host address range 33 to 62 netA: 204.15.5.64/28 host address range 65 to 78 netD: 204.15.5.80/28 host address range 81 to 94 netC: 204.15.5.96/30 host address range 97 to 98
This can be graphically represented as shown in Figure 5:
Figure 5
Figure 5 illustrates how using VLSM helped save more than half of the address space.
O Classless Interdomain Routing (CIDR) foi introduzido para melhorar a utilização do espaço de endereços e a escalabilidade do roteamento na Internet. It was needed because of the rapid growth of the Internet and growth of the IP routing tables held in the Internet routers.
O CIDR se afasta das classes IP tradicionais (classe A, classe B, classe C, etc.). In CIDR , an IP network is represented by a prefix, which is an IP address and some indication of the length of the mask. Length means the number of left-most contiguous mask bits that are set to one. So network 172.16.0.0 255.255.0.0 can be represented as 172.16.0.0/16. CIDR also depicts a more hierarchical Internet architecture, where each domain takes its IP addresses from a higher level. This allows for the summarization of the domains to be done at the higher level. For example, if an ISP owns network 172.16.0.0/16, then the ISP can offer 172.16.1.0/24, 172.16.2.0/24, and so on to customers. Yet, when advertising to other providers, the ISP only needs to advertise 172.16.0.0/16.
Para obter mais informações sobre CIDR, consulte o RFC 1518 e o RFC 1519 .
Uma máscara de sub-rede de 30 bits permite quatro endereços IPv4: dois endereços de host, uma rede com zeros e um endereço de broadcast com apenas um. Um link ponto-a-ponto pode ter apenas dois endereços de host. Não há necessidade real de ter os endereços de broadcast e todos os zeros com links ponto-a-ponto. Uma máscara de sub-rede de 31 bits permitirá exatamente dois endereços de host e eliminará os endereços de broadcast e todos os zeros, conservando assim o uso de endereços IP ao mínimo para links ponto-a-ponto.
Consulte RFC 3021 - Usando prefixos de 31 bits em links ponto-a-ponto IPv4.
A máscara é 255.255.255.254 ou /31.
A sub-rede /31 pode ser usada em links ponto-a-ponto verdadeiros, como interfaces seriais ou POS. No entanto, eles também podem ser usados em tipos de interface de broadcast como interfaces ethernet. Se for esse o caso, verifique se há apenas dois endereços IPv4 necessários nesse segmento ethernet.
Exemplo
192.168.1.0 e 192.168.1.1 estão na sub-rede 192.168.1.0/31.
R1(config)#int gigabitEthernet 0/1
R1(config-if)#ip address 192.168.1.0 255.255.255.254
% Warning: use /31 mask on non point-to-point interface cautiously
O aviso é impresso porque gigabitEthernet é um segmento de broadcast.
Uma máscara de sub-rede de 255.255.255.255 (uma sub-rede /32) descreve uma sub-rede com apenas um endereço de host IPv4. Essas sub-redes não podem ser usadas para atribuir endereços a links de rede, pois sempre precisam de mais de um endereço por link. O uso de /32 é estritamente reservado para uso em links que podem ter apenas um endereço. O exemplo para os roteadores Cisco é a interface de loopback. Essas interfaces são interfaces internas e não se conectam a outros dispositivos. Como tal, eles podem ter uma sub-rede /32.
Exemplo
interface Loopback0
ip address 192.168.2.1 255.255.255.255
Routers A and B are connected via serial interface.
hostname routera ! ip routing ! int e 0 ip address 172.16.50.1 255.255.255.0 !(subnet 50) int e 1 ip address 172.16.55.1 255.255.255.0 !(subnet 55) int s 0 ip address 172.16.60.1 255.255.255.0 !(subnet 60) int s 0 ip address 172.16.65.1 255.255.255.0 (subnet 65) !S 0 connects to router B router rip network 172.16.0.0
hostname routerb ! ip routing ! int e 0 ip address 192.1.10.200 255.255.255.240 !(subnet 192) int e 1 ip address 192.1.10.66 255.255.255.240 !(subnet 64) int s 0 ip address 172.16.65.2 (same subnet as router A's s 0) !Int s 0 connects to router A router rip network 192.1.10.0 network 172.16.0.0
Class B Effective Effective # bits Mask Subnets Hosts ------- --------------- --------- --------- 1 255.255.128.0 2 32766 2 255.255.192.0 4 16382 3 255.255.224.0 8 8190 4 255.255.240.0 16 4094 5 255.255.248.0 32 2046 6 255.255.252.0 64 1022 7 255.255.254.0 128 510 8 255.255.255.0 256 254 9 255.255.255.128 512 126 10 255.255.255.192 1024 62 11 255.255.255.224 2048 30 12 255.255.255.240 4096 14 13 255.255.255.248 8192 6 14 255.255.255.252 16384 2 Class C Effective Effective # bits Mask Subnets Hosts ------- --------------- --------- --------- 1 255.255.255.128 2 126 2 255.255.255.192 4 62 3 255.255.255.224 8 30 4 255.255.255.240 16 14 5 255.255.255.248 32 6 6 255.255.255.252 64 2 *Subnet all zeroes and all ones included. These might not be supported on some legacy systems. *Host all zeroes and all ones excluded.