Configuring an Interface with ifconfig

To configure an address for an interface with ifconfig, you need to specify the interface in question, the IP address, and traditionally the state of the interface (up or down). Consider the following example, which assigns an IP address to an interface with ifconfig:

bible:~ # ifconfig eth0 up

This configures the device eth0 with an IP address of and sets the interface into an active configuration. When you are setting an IP address, the network and broadcast addresses are automatically set based on the IP address given (in a class-based configuration). If you want to specify a network mask for this interface, add the netmask option to the ifconfig command.

i- : i , The ifconfig command is very familiar to most Linux users and still very widely used in practice. But it should be considered deprecated in favor of the ip command from the iproute2 package that is discussed later in this chapter.

If you want to set up a classless IP address to split the IP address into subnets, you could set up the interface with ifconfig eth0 netmask up. This sets the network mask for the interface, which is used by the kernel to make routing decisions. Subnetting is discussed in more detail in Chapter 6.

Was this article helpful?

0 0

Post a comment