Using IP Addressing

Every computer on a TCP/IP network needs an IP address before it can communicate with others. You or your ISP can assign a permanent address, or IP addresses can be leased from a DHCP server. Your ISP assigns your computer a unique IP address whenever you re connected to the Internet.

To set up IP addresses for your network, you need a network address and a network mask. IP addresses that share the same network address and network mask are on the same LAN. Network addresses fall into one of five different address classes. Network masks define a range of IP addresses that you can assign with a specific network address.

Every network with a connection to other networks needs a gateway IP address for that connection. In Linux, you can limit access to and from your network with the /etc/ hosts .allow and /etc/hosts .deny files, or through appropriate iptables or ipchains firewall commands.

IP Version 4

The IP address standard in use since the 1970s is IP version 4 (IPv4), which is a 32-bit address. With 32 bits, there are over 4 billion possible addresses (2 32 = 4,294,967,296). That was more than enough addresses for the first years of the Internet. However, it isn t enough today. While the Internet is currently in transition to IP version 6 (IPv6), current IP version 4 (IPv4) addresses will still be usable after the transition is complete.

In fact, IPv4 addresses are easier to understand and easier to configure for many private LANs. I believe that IPv4 addresses will remain in common use for many years to come. In the next chapter , you ll learn how this allows you to configure private IP networks quickly and easily.

There are two ways to specify an IPv4 address: in binary notation, or in dotted decimal format. The following is a typical IPv4 private network address in binary notation:

 11000000 10101000 00000001 00100000 

Does this look confusing? Remember, this is the way computers read data. As humans , most of us are more familiar with the decimal system of numbers : 0, 1, 2, 3, 4, 5, 6, 7, 8, and 9. It s easy to convert bits into decimals: the above IPv4 address in dotted-decimal format is 192.168.1.32. But not everyone can make this conversion so easily. It s worth taking a bit of time to understand how to convert bits of an IPv4 address to dotted decimal notation.

The Bits of an IPv4 Address

A bit is a binary digit. The binary system contains two possible numbers: 0 and 1. It s easy to represent a bit in a computer. All you need is a switch, or an electrical impulse or a pulse of light. When the switch is off, it s 0; when the switch is on, it s a 1.

By convention, there are 8 bits in a byte. In ASCII, every letter and number on an English language keyboard is associated with a unique byte. That is why a 32-bit IPv4 address is organized into four groups of 8 bits: there are 4 bytes in this address:

 11000000 10101000 00000001 00100000 

Now let s break down the bits in each byte. The first number in a byte, 00000001 , equals 1 in decimal notation. That s followed by 00000010 = 2, 00000011 = 3 and so on. Several examples of this are shown in Table 20.2.

Table 20.2: Bytes and Regular Numbers

Byte

Regular number

00000000

00000001

1

00000010

2

00000100

4

00001000

8

00010000

16

00100000

32

01000000

64

10000000

128

Now let s take the first byte in the given address, 11000000 . That represents 10000000 = 128 and 01000000 = 64. Since 128 + 64 = 192, that s the first number in this IP address. The next number is 10101000 , which is 128 + 32 + 8 = 168. Similarly, 00000001 = 1 and 00010000 = 32, which leads to an IPv4 address of 192.168.1.32, expressed in dotted-decimal notation.

Taken to its logical extreme, note that 11111111 in binary notation = 255 in our numbers.

Address Classes

IPv4 addresses range from 0.0.0.0 to 255.255.255.255. These addresses are divided into five different address classes, A through E. You can assign IP addresses (when available) from Class A, B, or C. The range of addresses of each of the five different classes is shown in Table 20.3.

Table 20.3: IPv4 Address Classes

Class

Range

Comment

A

1.0.0.0 to 127.255.255.255

Allows networks of up to 16 million computers

B

128.0.0.0 to 191.255.255.255

Allows networks of up to 65,000 computers

C

192.0.0.0 to 223.255.255.255

Allows networks of up to 254 computers

D

224.0.0.0 to 239.255.255.255

Reserved for multicasts

E

240.0.0.0 to 255.255.255.255

Reserved for experiments

Not all of these IP addresses, even in classes A, B, and C, are usable. There are four types of addresses that you can t assign to a computer that is directly connected to the Internet:

  • The first address in any network of IPv4 addresses is reserved as the network address.

  • The last address in any network of IPv4 addresses is reserved as the broadcast address.

  • The address 127.0.0.1 is reserved as the loopback address.

  • There are groups of IPv4 addresses reserved as private addresses, suitable for private LANs that are connected to the Internet only through a firewall.

You ll learn about each of these addresses in detail in the next chapter , which will also cover the concepts of network and broadcast addresses, as well as network or subnet masks. These concepts will be covered in the context of a private IP network connected to the Internet.

IP Version 6

As strange as it sounds, 4 billion IPv4 addresses are not enough. All available IPv4 address groups have already been assigned. While you probably can get your own IPv4 address from your ISP (probably for an extra fee), work is under way to convert the Internet to IPv6.

There are 128 bits in an IPv6 address. That s over 340,000,000,000,000,000,000,000,000,000, 000,000,000 addresses. To ease the transition, a specific IPv6 address has been assigned to every IPv4 address. That leaves over 3.4 10 38 addresses for all other uses. Your IPv4 address will work in an IPv6 world.

The way IPv6 is configured, it s easy to convert an IPv4 address to IPv6. For example, the IPv4 address

 192.168.1.32 

is identical to the following IPv6 address:

 ::192.168.1.32 

However, IPv6 addresses are also shown in hexadecimal notation. This is also known as base 16, where the numbers are 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, a, b, c, d, e, and f. One example of an IPv6 address is

 4aed:0a21:3c53:7dab:0000:0000:0000:0451 

It s easy to convert IPv4 addresses to hexadecimal notation. As an example, convert the previous IPv4 address to binary format:

 11000000 10101000 00000001 00100000 

Next, we know that 2 4 = 16. In other words, there are 4 bits in every hexadecimal number. Therefore, you should regroup the IPv4 address into groups of 4 bits (which is incidentally known as a nibble no kidding):

 1100 0000 1010 1000 0000 0001 0010 0000 

Now, converting these numbers one at a time to decimal format leads to

 12 0 10 8 0 1 2 0 

which equals the following in base 16 or hexadecimal format:

 c0a8:0120 

The corresponding IPv6 address is

 0000:0000:0000:0000:0000:0000:c0a8:0120 
 


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

Similar book on Amazon

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