-->
Previous Table of Contents Next


Table 24.2 lists the command-line arguments for ifconfig.

Table 24.2 Command-Line Arguments for ifconfig

Argument Description

interface The name of the network interface, usually the name of the device driver followed by an identification number. This argument is required.
aftype The address family that should be used for decoding and displaying all protocol addresses. Now, the inet (TCP/IP), ddp (Appletalk Phase 2), ipx (Novell), and AX.25 and netrom (both amateur packet radio) address families are supported. The inet family is the default.
up Activates the specified interface.
down Deactivates the specified interface.
[-]arp Turns on or off the use of the ARP protocol on the specified interface. The minus sign is used to turn off the flag.
[-]trailers Turns on or off trailers on Ethernet frames. This isn’t currently implemented in the Linux networking system.
[-]allmulti Turns on or off the promiscuous mode of the interface. Turning this mode on tells the interface to send all traffic on the network to the kernel, not just traffic addressed to your machine.
metric N Sets the interface metric to the integer value N. The metric value represents the “cost” of sending a packet on this route. Route costing isn’t currently used by the Linux kernel but is to be implemented at a future date.
mtu N Sets the maximum number of bytes the interface can handle in one transfer to the integer value N. The current networking code in the kernel doesn’t handle IP fragmentation, so make sure that the MTU (Maximum Transmission Unit) value is set large enough.
dstaddr addr Sets the IP address of the other end of a point-to-point link. It has been made obsolete by the pointopoint keyword.
netmask addr Sets the IP network mask for the specified interface.
irq addr Sets the interrupt line used by this device. Remember that many devices don’t support dynamic IRQ setting.
[-]broadcast[addr] Sets the broadcast address for the interface when an address is included. If no address is given, the IFF_BROADCAST flag for the specified interface is turned on. A leading minus sign turns off the flag.
[-]pointopoint[addr] Turns on point-to-point mode on the specified interface. This tells the kernel that this interface is a direct link to another machine. The address, when included, is assigned to the machine on the other end of the list. If no address is given, the IFF_POINTOPOINT flag for the interface is turned on. A leading minus sign turns off the flag.
hw Sets the hardware address for the specified interface. The name of the hardware class and the ASCII equivalent of the hardware address must follow this keyword. Ethernet (ether ), AMPR AX.25 (ax25 ), and PPP (ppp ) are now supported.
address The host name or IP address to be assigned to the specified interface. Host names used here are resolved to their IP address equivalents. This parameter is required.

You normally don’t need to use all the options. ifconfig can set everything needed from just the interface name, netmask, and IP address assigned. You only need to explicitly set most parameters when ifconfig misses or you have a complex network.


CAUTION:  
If your Linux machine is on a network, the ifconfig program must be kept secure from unauthorized use. Setting a network interface to promiscuous mode allows a person to snoop in your network and get sensitive data such as passwords. This is a serious breach of security.


See “Handling Physical Security,”p. 236

Using ifconfig to Inspect a Network Interface

Running ifconfig with no arguments causes it to output the status of all network interfaces the kernel knows about. Running ifconfig with just an interface name on the command line prints the status of the interface:


$ ifconfig lo

lo        Link encap Local Loopback

          inet addr 127.0.0.1 Bcast 127.255.255.255 Mask 255.0.0.0

          UP LOOPBACK RUNNING MTU 2000 Metric 1

          RX packets 0 errors 0 dropped 0 overruns 0

          TX packets 1658 errors 10 dropped 0 overruns 0

This example uses lo, the software loopback interface. You can see the assigned IP address (inet addr ), broadcast address (Bcast ), and netmask (Mask ). The interface is UP with an MTU of 2000 and a Metric of 1. The last two lines give statistics on the number of packets received (RX ) and transmitted (TX ), along with packet error, dropped, and overrun counts.

Configuring the Software Loopback Interface

All Linux machines with the networking layer installed in the kernel have a software loopback interface. This interface is used to test networking applications and to provide a network for local TCP/IP services when the machine isn’t connected to a real network.

The network interface name for the loopback system is lo. Enter the following to run ifconfig :


ifconfig lo 127.0.0.1

This activates the loopback interface and assigns the address 127.0.0.1 to it. This is the address traditionally used for the loopback because the class A network, 127.0.0.0, will never be assigned to anyone by InterNIC.

To make the loopback system fully operational, you need to add a route for it with the route command, which is discussed later in the section “Understanding TCP/IP Routing.”

Configuring a Network Interface

Configuring an Ethernet network interface takes a little bit more work, especially if you’re using subnetworks. The basic call to ifconfig looks like this for linux1.burwell.com:


ifconfig eth0 linux1


Previous Table of Contents Next