Configuring Private and Public Networks

In Chapter 20 , you learned some of the basics of IPv4 addresses. Now you ll see how to make IPv4 addressing work in configuring a LAN that is connected to the Internet.

When you configure a network that s connected to the Internet, you can t select just any IP address. There are a number of private IP addresses that you can freely use on your internal network. However, for your connection to the Internet, you need at least one public IP address. Each of the computers on your network can access the Internet simultaneously using your public IP address.

Unfortunately, most public IP addresses are taken. Those that are still available are generally assigned by ISPs.

Note  

Public IP addresses are used for communication between computers and networks on the Internet. On the other hand, the same private IP addresses can be used on independent private networks. To avoid confusion, private IP addresses are not valid for communication through the Internet.

You can configure your LAN with private IP addresses, with one public IP address on a gateway computer for connecting your LAN to the Internet. To get a public IP address on the Internet, talk to your ISP. You ll get either a static IP address with a subnet or network mask, or instructions to get your address from a DHCP server.

start sidebar
Network Definitions

Several basic definitions are used to define IP addresses on a LAN.

Network address Every IP address includes two parts : the network address and the numbers associated with a particular host. A network address such as 192.168.22.0 uniquely identifies a specific network. Assuming it is a Class C address, it identifies a network with a range of IP addresses between 192.168.22.1 and 192.168.22.254.

Network mask This special IP address (also known as a subnetwork mask or a subnet mask ) lets you define a range of available IP addresses on a LAN. The three standard network masks are 255.0.0.0, 255.255.0.0, and 255.255.255.0.

Broadcast address This is a special IP address used to communicate with all computers on that network. It is the last available IP address on a network. For example, if you have a network address of 192.168.22.0 and a network mask of 255.255.255.0, the broadcast address is 192.168.22.255.

Private IP address This is an IP address that is dedicated for private LANs. You can use a private IP address on a LAN that is connected to the Internet through a computer with a public IP address. The same private IP addresses are often used on different LANs. However, you aren t allowed to use a private IP address to connect directly to the Internet.

Public IP address This is an IP address that is used to communicate directly to the Internet.

Classless Inter-Domain Routing (CIDR) CIDR is a method of specifying nonstandard network masks. This allows you to subdivide or combine standard IP address ranges.

end sidebar
 

Private IP Networks

To set up the computers inside your network with private IP addresses, you need a network address and a network mask. These two parameters define a range of IP addresses. As described in Chapter 20 , three standard ranges of private IP addresses are available, as shown in Table 21.3.

Table 21.3: Private IP Address Ranges

Range

Class

Description

10.0.0.1 “10.255.255.254

A

Can accommodate about 16 million computers in one domain

172.168.0.1 “172.168.255.254

B

Can accommodate about 65,000 computers in one domain

192.168.0.1 “192.168.255.254

C

Can accommodate up to 254 computers in one domain

When you choose a network address and network mask, you typically choose a subset of one of the IP address groups shown in Table 21.3. For example, if you have a network address of 10.0.0.0 and a network mask of 255.255.255.0, the range of possible addresses is 10.0.0.0 through 10.0.0.255, which consists of 256 different addresses. These addresses compose a subnetwork, also known as a subnet .

But as you may remember from Chapter 20 , the first address in this subnet, 10.0.0.0, is reserved as the network address. And the last address in this subnet, 10.0.0.255, is reserved as the broadcast address. You can t assign either address to a specific computer. That leaves 254 addresses on this subnet that you can assign to actual computers.

Network Mask

A network mask allows you to determine if a specific IP address is on the same LAN. It also enables you to differentiate network addresses from host addresses. When you put the network address together with the network mask, you can define the range of host addresses that you can assign to your computers.

Table 21.4 shows several examples of network addresses, host addresses, and network masks. The Available Host Addresses column defines the IP addresses that you can assign on your internal network.

Table 21.4: Sample Network Addresses and Network Masks

Network Address

Network Mask

Available Host Addresses

Number of Assignable IP Addresses

10.0.0.0

255.0.0.0

10.0.0.1 “10.255.255.254

16,777,214

10.21.92.0

255.255.255.0

10.21.92.1 “10.21.92.254

254

10.182.0.0

255.255.0.0

10.182.0.1 “10.182.255.254

65,534

172.168.78.0

255.255.255.0

172.168.78.1 “172.168.78.254

254

172.168.0.0

255.255.0.0

172.168.0.1 “172.168.255.254

65,534

192.168.3.0

255.255.255.0

192.168.3.1 “192.168.3.254

254

From this information, you can derive the following rules for IP addressing:

  • A network IP address is never used as a host address for a specific computer. This address comes just before the range of available host addresses.

  • The 255s in a network mask normally correspond to the network address. For example, if your IP address is 10.162.4.23 and your network mask is 255.255.255.0, the network address is 10.162.4.0. The host part of the IP address is 23. See the section Classless Inter-Domain Routing (CIDR) for exceptions to this rule.

  • The last address in an IP address range is reserved as the broadcast address. For example, for the last example in Table 21.4, the broadcast address is 192.168.3.255.

  • Standard network masks are 255.0.0.0, 255.255.0.0, and 255.255.255.0. Other network masks are described in the section Classless Inter-Domain Routing (CIDR).

Configuring a Network

Before you set up TCP/IP on a LAN, you need to select a set of addresses. Based on the information in the previous sections, select a private network address and network mask. When you put the two addresses together, you get a range of IP addresses that you can assign to each computer on your LAN.

Perhaps the most common network mask is 255.255.255.0. As discussed earlier, this network mask allows you to choose from 254 IP addresses. In other words, if your network address is 10.168.0.0, this network mask allows you to assign 10.168.0.1, 10.168.0.2, 10.168.0.3, and so on through 10.168.0.254 to different computers on your network.

Remember, the first address in the network range, in this case 10.168.0.0, is reserved as the network address. The last address in this range, 10.168.0.255, is reserved as the broadcast address.

You have two choices with the assignable IP addresses. You can assign them to individual computers yourself, with commands such as ifconfig as described earlier. This means you also need to manually add the IP addresses for the DNS server and the default gateway. Alternatively, you can set up the range of available IP addresses on a DHCP server. As discussed in Chapter 24 , DHCP servers can be configured to "lease" IP addresses to each computer on your network. That server can also pass along information related to the DNS server and gateway address for your network.

The Gateway Computer

On a network, the gateway computer is connected to your LAN and another network, such as the Internet. On a typical LAN, only one computer is directly connected to another network. That computer has two or more network cards: one is connected to the LAN, and the other is connected to the other network. One IP address is assigned to each network card. The gateway address is the IP address of the network card on the LAN.

To illustrate this configuration, look at Figure 21.2, which shows a LAN of five computers. The computer that is shown between the hub and the Internet is the gateway computer. The gateway address for all the other computers on this LAN is 10.190.18.3, which is the address that the gateway computer uses on the LAN.

click to expand
Figure 21.2: Assigning IP addresses

The other network card on the gateway computer gets the public IP address on the Internet, in this case, 62.33.23.122.

Classless Inter-Domain Routing (CIDR)

Classless Inter-Domain Routing (CIDR) is not the easiest topic for speed-readers. However, if you take these explanations step by step, you ll be a CIDR master in no time at all.

In most cases, the only network masks that you need on an IPv4 network are 255.0.0.0, 255.255.0.0, and 255.255.255.0. These network masks are most closely associated with Class A, B, and C addresses, respectively.

Those three network masks make it easy to differentiate network addresses from the host address. For example, if one of the computers on a distant network has an IP address of 192.168.38.48, with a network mask of 255.255.255.0, you know the network address is 192.168.38.0. The other computers on that LAN can have IP addresses between 192.168.38.1 and 192.168.38.254.

start sidebar
Bits and Bytes

To understand CIDR, you need to understand the bits and bytes in an IPv4 address. There are 32 bits in an IPv4 address. They are organized into 4 different numbers between 0 and 255, which correspond to 4 bytes. There are 8 bits in a byte. Each bit represents a different number. The top row represents the bits in a byte; the bottom row represents their decimal equivalent.

1

1

1

1

1

1

1

1

128

64

32

16

8

4

2

1

For example, if you have a byte of 10000000 , the corresponding number is 128. If you have a byte of 00010000 , the corresponding number is 16. If your byte is 11111111 , the corresponding number is 128 + 64 + 32 + 16 + 8 + 4 + 2 + 1 = 255.

end sidebar
 

As an example, assume that you re setting up a Class C network, using the 192.168.38.0 network address. You may not even need 254 different IP addresses for your LAN; however, CIDR is useful if you re responsible for two LANs in separate buildings . In this case, you can use CIDR to subdivide IP addresses in a different way.

To understand how this works, let s take a step back and return to the bits. The following two IP addresses represent 192.168.38.48 and 255.255.255.0 in binary notation:

 11000000 10101000 00100110 00110000 11111111 11111111 11111111 00000000 

As discussed earlier, the 255s in a network mask correspond to the network IP address, in this case, 192.168.38.0. When expressed in bits, the 1s in a network mask correspond to the network address as shown:

 11000000 10101000 00100110 00000000 
Note  

Note how 255.255.255.0 corresponds to 24 bits of an IPv4 address. In CIDR notation, this network address and mask can be shown as 192.168.38.0/24.

The last 8 bits are not covered, which gives us a range of 2 8 = 256 host addresses, starting with 0. The 0 is assigned as the end of the host network address; 255 is assigned as the host broadcast address. Neither of these addresses can be assigned to a specific computer; therefore, you have 254 addresses available on this LAN. Look at what happens when you add one more bit to the network mask:

 11000000 10101000 00100110 00110000 11111111 11111111 11111111 10000000 

The area covered by the 1s in the network mask represents the network address of 192.168.38.0. However, only the last 7 bits are not covered, which gives us a theoretical range of 2 7 = 128 host addresses, starting with 0 and ending with 127. Therefore, this particular network has an address of 192.168.38.0 and a broadcast address of 192.168.38.127. The network mask is 255.255.255.128.

Note  

See how 255.255.255.128 corresponds to 25 bits of an IPv4 address. In CIDR notation, this network, with this network mask, can be represented by 192.168.38.0/25.

Alternatively, look at the same network mask for an IP address of 192.168.38.166:

 11000000 10101000 00100110 10110000 11111111 11111111 11111111 10000000 

Using the same rationale, this particular network has an address of 192.168.38.128, and a broadcast address of 192.168.38.255. Remember, neither of these addresses can be used on a specific computer. Thus, there are only 126 available host addresses.

With a standard Class C network mask of 255.255.255.0, you can configure 254 computers on the 192.168.38.0 network. With a slightly different network mask (255.255.255.128), you can configure two different LANs with 126 available host addresses.

 


Mastering Red Hat Linux 9
Building Tablet PC Applications (Pro-Developer)
ISBN: 078214179X
EAN: 2147483647
Year: 2005
Pages: 220

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net