Previous Next Table of Contents

4. IP_ADDR_ - Allocating IP Addresses

During Installation, you will give the machine a name, and a position in the networking world. If you have an Internet account, you have an IP_address. If you have an Ethernet card installed, it should have an IP address.

4.1 Allocate your own PRIVATE LAN IP addresses

See also: rfc1918 (previously 1597) Address Allocation for Private Internets.

If you are creating an Ethernet network, you must allocate a unique TCP/IP address for each network and for each machine. How do you do this ? Think of a number? How do you know that your number will not conflict with someone else number? What is the 'right' thing to do? Many documents tell you to 'consult your network administrator', hmm.

Allocate 20 LANS per Site

        Newcastle       192.168.140.0
        Manchester      192.168.160.0
        Reading         192.168.180.0
        Dial-ins        192.168.200.0 # off-site PC's with modems + SLIP | PPP
Actually multiples of 16 or 32 might be easier if you have a real national network, as you could then use bit masks to pick the correct route. However, you will probably only have occasional links between them, such as dial up batch email delivery, so building routing tables won't be a headache, but remembering numbers will be!

4.2 Properly registered addresses

A TCP/IP address is an Internet address. A 'proper' Internet address is one allocated and registered by the Internet authorities, and it is unique in the world. No-one else is allowed to use the same address.

If you have an Internet service provider, they will allocate you one of their numbers, and register your machine name and address in the correct places.

Your Internet provider allocated your modem dial-up IP_ADDR. This address is valid the world over - any caller will be directed to your machine (if you are online). They also allocate and publish your email address, so when you are off-line, their email machine accepts email on your behalf, and batches them until you get connected.

Privately allocated addresses

If your PC is connected to Ethernet you will have a second IP address. If you have an Ethernet card, you have a LAN. Unless it's registered, it's a private LAN.

Your private LAN will have private addresses. Several address ranges have been reserved for this. They allow you to allocate your own IP addresses, without having to ask anyone. Note that they are PRIVATE, you can't use them to communicate with the PUBLIC Internet.

I presume that you have both a SLIP (PPP) account, and a local LAN.

Address conflicts

Other people will also use addresses in the PRIVATE range (conflicting with your use of the same range). Neither your network, nor theirs remote network can communicate with the "The Internet". Only your registered machine(s) is allowed to send packets to and from the Internet. Your private machines can only communicate with other private machine addresses.

As long as all your machines have unique addresses, you will be OK, except that you can only use the Internet from the REGISTERED host.

Yes there are tricks to get around this.

EMAIL gateways

Your REGISTERED machine has TWO addresses. It can talk to hosts on both the public and private networks. When your global EMAIL arrives at the REGISTERED address machine, the post room forwards it to the correct local machine (over the PRIVATE network). Similarly outgoing mail has to be sent via the post room on the gateway, which will send it directly to the destination, or the destinations nominated EMAIL exchanger, or probably your service providers EMAIL exchanger.

PROXY gateways / firewalls

If you want a private host to connect directly to a host on the public Internet, you can't. You can only initiate/receive comms from the REGISTERED address. However, you can build up your network so that your private machines ask the gateway to do this for them. The return address is the gateway, which then relays the results back to the private host (in real time, on a packet-by-packet basis, not SMTP batched EMAIL files).

To do this, you will need a firewall machine or PROXY machine that is properly configured, and lots of client APPS on the PC's that understands that flavour of PROXY. Not all apps are proxy aware, and there will be extra work configuring the security options of the firewall.

IP Masquerading is about getting the gateway/router to substitute addresses in every packet between a private machine and the Internet. It works with TCP, but not (so well) with UDP, and utilites like ping.

4.3 RFC 1918 reserved address ranges

The reserved private ranges are:

        10.0.0.0                - upto -
        10.255.255.255

        172.16.0.0              - upto -
        172.31.255.255

        192.168.0.0             <-- SUGGESTED 
        192.168.255.255         <-- RANGE

So for example, you decide to number your machines:

        192.168.67.1
        192.168.67.2    
        192.168.67...

4.4 What is IP and what are IP addresses?

IP (Internet protocol) is a system for transporting packets - networking. Each packet has a destination address - a 32 bit IP address.

Routers retransmit packets that they receive to other routers that know how to reach the remote network. Routers talk to other routers, and can redirect traffic - hopefully via the best route.

TCP is a system (protocol) that uses IP packets to implement reliable connections (with retransmission, timeouts etc). Hence TCP/IP (over).

The 32 bit IP address is split into two parts. The split can be at any bit boundary, but a typical split is used in 'C' class addresses 24:8

        |<------ NETWORK --------->|<-HOST->|
        +--------+--------+--------+--------+
        | BYTE   | BYTE   | BYTE   | BYTE   |
        +--------+--------+--------+--------+

        +--------+--------+--------+--------+
        | 192    | 168    |  67    |   3    |  HOST 3 on LAN 67
        +--------+--------+--------+--------+
special | 192    | 168    |  67    |   0    |  Address of LAN itself
        +--------+--------+--------+--------+
special | 192    | 168    |  67    |  255   |  Broadcast to LAN
        +--------+--------+--------+--------+
        | 192    | 168    | 100    |   2    |  Different LAN  
        +--------+--------+--------+--------+

All the hosts in a physical LAN share the same NETWORK address. Two host addresses are reserved: zero and all 1's. The NETMASK-SPLIT for our sample network is 24:8, so the Host part of the address is simple.

192.168.67.255 is reserved for broadcasting to ALL hosts on LAN 67. 192.168.67.0 is reserved to describe the LAN itself. 192.168.67.1 is your first host (upto 254 in a C mask LAN).

running two networks on the same LAN - no benefit

If you have two network addresses in operation on the same LAN wire, both will run concurrently. You may get communication between them, especially if there is a gateway on the LAN, which listens to both broadcasts.

This is not a good idea, unless two independent departments share the same LAN wire, or you are testing something.

sub-netting - don't do it

If you have more than 254 hosts, you should not run them all on the same wire. Split your network into chunks so that each LAN uses a C-class address. You may wish to have fewer (eg 14) hosts on a LAN, with 16 such mini-lans inside one C-class address range. However most people with small office networks will have more address space than time, and would use several ordinary C-class network addresses, with default bitmasks.

Redefining the position of the split is "sub-netting". Its biggest benefit is to allow several LANS connected by gateways OR bridges, to share in broadcast traffic, and act as one 'logical' LAN.

Sub-netting's biggest use is in re-defining a huge block of B-addresses as blocks of C range, and configure them as such.

The problems are mostly in configuring in the correct mask values in the correct places. It is easiest to leave the hosts (ie not gateways) on LANS with upto 254 addresses, and the standard broadcasts.

NETMASKS

An IP address is really a 32 bit number (that's binary), it's just usually printed in dotted quad decimal for readability. This address is split into two sides: network and host. The split can happen any where (if you use sub-netting), but there are three 'default' recommended splits, depending on how may hosts you want to have on a network.

These are class A, B and C. The 192 range is within the class-C range where the split is defined as

24 bit network part (left = high) 8 bit host part (right=low)

So your network address is 192.168.67.__, and the host part is __.__.__.3, which combined gives 192.168.67.3

Although the default interpretation of 192.__.__.__ addresses is class-C, and that has a split of net.net.net.host it is possible to redefine the boundary line. If you did that, you would have to tell all the hosts about the special splitting boundary line. This is done using the NET-MASK and BROADCAST address. That is called sub-netting,.

Note that any routers, outside the LAN, can be told a slightly different story. If all of Manchester fits under one bitmask, (and noone else does), you can route traffic towards Manchester by telling the routers about the bigger bitmask (sub-net), but still telling every host within Manchester to use the standard C-class sub-net mask.

In binary logic, a MASK is used to AND or OR, to select bits of data or to mask them off (de-select them). With the default split line, most of the networking software can guess correctly at the default. You may need to calculate the following numbers in-order to configure the TCP/IP interface devices (eth0 sl0), and routing software. ifconfig(1) route(1)

Converting binary to decimal, 11111111 is 255

        netmask  = 255.255.255.  0      11111111.11111111.11111111.00000000
        hostmask =   0.  0.  0.255      00000000.00000000.00000000.11111111
        netaddr  = 192.168. 67.  0        -192- .  -168- .01000011.00000000
        broadcast= 192.168. 67.255        -192- .  -168- .01000011.11111111
        hostaddr = 192.168. 67.  3        -192- .  -168- .01000011.00000011

NEVER have a host at address 0 or at address 255. Host address 0 is reserved for the network itself and 255 is reserved for broadcasting to every host on the network. (If you have a different net mask, re-read as host part all '0' or host part all '1', and avoid 255 and 0 anyway).

So now you should see that the 192.168 range gives you 254 networks of 254 hosts If you only have one Ethernet LAN, simply PICK-A-NUMBER (eg 100) for the LAN address. If you have four LAN's pick 100, 101, 102, 103 for them. Actually you can have 256 networks, no problem, but why allow confuse in the door?

The only real problem you may have is when your company merges with another company, or you decide to link networks together. If you both have picked the same network addresses, one of you will have to move. So pick a magic number (67) at random (not 1,2,3 ...).

point-to-point networks

Each network must have a unique network address, if you experiment with SLIP or PLIP (SLIP over a parallel cable), you should really create a new network address for the cable itself, and two numbers for the hosts.

This is not absolutely necessary, as the two ends are 'point-to-point' when you can re-use the Ethernet address. Doing so works because the two networks are otherwise disconnected, and every packet has an unique destination and origin.

4.5 MULTI-ADDRESS machines

Now your machine has TWO IP addresses! One for the SLIP connection via the modem, one for the LAN connection via the Ethernet card. One is globally registered, the other is privately registered and publicly ignored.

This is only confusing if you let it be. Every network has a network address, every interface card has a host address, and most machines only have one interface card.

A host with several (physical) connections to several networks, has several addresses.

There is also the special 'loopback' address 127.0.0.1, which is used to allow hosts to talk to themselves.

/etc/hosts

IP addresses exist whether or not they are listed in /etc/hosts. This is just a mechanism of finding the address from the NAME. Of course it makes sense to keep a central host up-to-date with all the hosts on the network, and document which addresses have already been allocated by editing this file.

The job of /etc/hosts (finding IP address of hostname) can be configured to be done over the network. That's how you can call ftp.Microsoft.com without it being in your /etc/hosts file.

After the IP address, the first name in /etc/hosts is the "proper name" of the host, followed by abbreviations, and aliases. Multi-address machine will have multiple lines for the same name.

If you use /etc/hosts in preference to NIS+BIND, it makes it harder for hackers to feed you lies about your own network addresses (it also provides a list for them to try out).

/etc/networks

This file is a list of network addresses (without NETMASKS - confusingly). It is only really used by the ifconfig and route commands. It is limited by it's lack of NETMASK.

4.6 Ethernet MAC addresses (-aka- DTE address).

Every Ethernet card in the world has a unique MAC address, on a plug in PROM. This is put there by the manufacturer (though most cards can be programmed to pretend to have a different address!).

This address is used within the LAN segment, to uniquely identify the card (and host). You don't need to know the address, it all happens automatically. You might have to program the address into any 'secure' bridges.

When running IP over ethernet, it is the MAC address that gets used in the ethernet packet headers. ARP and RARP is all about converting MAC addresses to IP addresses (and reverse). Inside the ethernet packet is an IP packet with the IP address, and the ethernet packets have their own checksums, and often retransmission protcols.


Previous Next Table of Contents