UNIX System Administration Handbook - Evi Nemeth [183]
A better way to avoid problems with broadcast pings is to prevent your border routers from forwarding them and to tell individual hosts not to respond to them. See the vendor-specific sections starting on page 306 for instructions on how to implement these constraints on each of our example systems.
In the ifconfig example at the beginning of this section, the broadcast address is 128.138.240.255 because the network is a /24, as specified by the netmask value of 255.255.255.0.
Executing ifconfig en0 shows the following output:
en0: flags=63 netmask ffffff00 broadcast 128.138.240.255 Let’s look at some complete examples. # ifconfig lo0 127.0.0.1 up This command configures the loopback interface, which doesn’t usually require any options to be set. You should never need to change your system’s default configuration for this interface. The implied netmask of 255.0.0.0 is correct and does not need to be manually overridden. # ifconfig en0 128.138.243.151 netmask 255.255.255.192 broadcast 128.138.243.191 up This is a typical example for an Ethernet interface. The IP and broadcast addresses are set to 128.138.243.151 and 128.138.243.191, respectively. The network is class B (you can tell from the first byte of the address), but it has been subnetted by an additional ten bits into a /26 network. 192 in the netmask is 11000000 in binary and so adds 2 extra bits to the 24 contained in the three 255 octets. The 191 in the broadcast address is 10111111 in binary, which sets all 6 host bits to 1s and indicates that this interface is part of the 3rd network (10) in the group of 4 carved out of the 4th octet. Now that you know how to configure a network interface by hand, you need to figure out how the parameters to ifconfig are set when the machine boots, and you need to make sure that the new values are entered correctly. You normally do this by editing one or more configuration files; see the vendor-specific sections starting on page 306 for more information. route: configure static routes When you add a new machine to a local area network, you usually only need to specify a default route; see the next section for details. Be sure to read your system’s man page for route as well. Syntax, flags, and arguments vary enormously among vendors. This book’s discussion of routing is split between this section and Chapter 14, Routing. Although most of the basic information about routing and the route command is here, you might find it helpful to read the first few sections of Chapter 14 if you need more information. Routing is performed at the IP layer. When a packet bound for some other host arrives, the packet’s destination IP address is compared with the routes in the kernel’s routing table. If it matches or partially matches a route in the table, the packet is forwarded to the “next gateway” IP address associated with that route. There are two special cases: First, a packet may be destined for some host on a directly connected network. In this case, the “next gateway” address in the routing table will be one of the local host’s own interfaces, and the packet is sent directly to its destination.
The route command defines static routes, explicit routing table entries that never change (you hope), even if you run a routing daemon.18