12.7. Troubleshooting Network Addresses
A number of common problems are caused by incorrect routing of Internet addresses or by the incorrect assignment of addresses. This section helps you determine your addresses.
Using the netmask, it is possible to determine which addresses can be reached directly (i.e., which are on the local network) and which addresses require forwarding packets through a router. If the netmask is wrong, the systems will make one of two mistakes. One is to route local packets via a router, which is an expensive waste of timeit might work reasonably fast, it might run slowly, or it might fail utterly. The second mistake is to fail to send packets from a remote system to the router, which will prevent them from being forwarded to the remote system.
The netmask is a number like an IP address, with one bits for the network part of an address and zero bits for the host portion. It is used as a bitmask to mask off parts of the address inside the TCP/IP code. If the mask is 255.255.0.0, the first two bytes are the network part and the last two are the host part; this is sometimes known (somewhat anachronistically) as the netmask for a class B network. More common is the class C netmask 255.255.255.0, in which the first three bytes are the network part and the last one is the host part.
For example, let's say your IP address is 192.168.1.10 and the Samba server is 192.168.236.86. If your netmask happens to be 255.255.255.0, the network part of the address is the first 3 bytes, and the host part is the last byte. In this case, the network parts are different, and the systems are on different networks:
If your netmask happens to be 255.255.0.0, the network part is just the first 2 bytes. In this case, the network parts match, and so the two systems are on the same network:
Make sure that the netmask in use on each system matches the structure of your network. On every subnet, the netmask should be identical on each system.
12.7.2. Broadcast Addresses
The broadcast address is a normal address, with the hosts part all one bits. It means "all hosts on your network." You can compute it easily from your netmask and address: take the address and put one-bits in it for all the bits that are zero at the end of the netmask (the host part). The following table illustrates this:
In this example, the broadcast address on the 192.168.236 network is 192.168.236.255. There is also an old "universal" broadcast address, 255.255.255.255. Routers are prohibited from forwarding these, but most systems on your local network will respond to broadcasts to this address.
12.7.3. Network Address Ranges
A number of address ranges have been reserved for testing and for nonconnected networks; we use these for the examples in this book. If you don't have an address yet, feel free to use one of these to start. They include one class A network, 10.*.*.*, a range of class B network addresses, 172.16.*.* through 172.31.*.*, and 254 class C networks, 192.168.1.* through 192.168.254.*. The domain example.com is also reserved for unconnected networks, explanatory examples, and books.
If you're actually connecting to the Internet, you'll need to get an appropriate IP address and a domain name, probably through the same company that provides your connection.
12.7.4. Finding Your Network Address
If you haven't recorded your IP address, you can learn it through the ifconfig command on Unix or the ipconfig.exe command on Windows. Check your manual pages for any options required by your brand of Unix. For example, ifconfig -a works on both Linux and Solaris. You should see output similar to the following:
$ ifconfig -a eth0 Link encap:Ethernet HWaddr 00:14:A4:82:36:E0 inet addr:192.168.236.86 Bcast:192.168.236.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:54509 errors:2199 dropped:0 overruns:0 frame:2199 TX packets:45497 errors:1 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:200 RX bytes:19202254 (18.3 Mb) TX bytes:5060379 (4.8 Mb) Interrupt:11 Memory:f92e0000-f92f0000 lo Link encap:Local Loopback inet addr:127.0.0.1 Mask:255.0.0.0 UP LOOPBACK RUNNING MTU:16436 Metric:1 RX packets:291088 errors:0 dropped:0 overruns:0 frame:0 TX packets:291088 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:75847323 (72.3 Mb) TX bytes:75847323 (72.3 Mb)
One of the interfaces will be loopback (in our examples, lo), and the other will be the regular IP interface. The flags should show that the interface is running, and Ethernet interfaces will also say they support broadcasts (PPP interfaces don't).