C.1 Using ifconfig to Manage Network Devices

   


C.1 Using ifconfig to Manage Network Devices

The command ifconfig is available in Linux to configure a network device. It serves mainly to activate, deactivate, and configure a network device and its physical adapters. This tool lets you modify both protocol-specific parameters (address, subnet mask, etc.) and interface-specific parameters (I/O port, interrupts, etc.). ifconfig can also be used to modify the flags of a registered network device (ARP, PROMISC, etc.).

To be able to use it, a network device has to first be activated in ifconfig. To this end, the adapter has to be known to the kernel and be present in the list of network devices. (See Chapter 5.)

Syntax

ifconfig          [-a] [-i] [-v] interface [[family] address]                   [add address[/prefixlen]] [del address[/prefixlen]]                   [tunnel aa.bb.cc.dd] [[-]broadcast [aa.bb.cc.dd]]                   [[-]pointopoint [aa.bb.cc.dd]]                   [netmask aa.bb.cc.dd] [dstaddr aa.bb.cc.dd]                   [hw class address][metric NN] [mtu NN]                   [[-]trailers] [[-]arp] [[-]allmulti] [[-]promisc]                   [multicast] [mem_start NN] [io_addr NN] [irq NN]                   [media type] [up] [down]

  • interface denotes the network device to be configured (e.g., eth0, ppp1).

  • family denotes the protocol family of the network-layer protocol used. Depending on the address family, the addresses specified here have different address formats (e.g., inet (TCP/IPv4 protocols), inet6 (TCP/IPv6 protocols), ax25 (Packet Radio), ddp (Apple), ipx (Novell)). inet is the default choice, so it does not have to be selected.

  • address is the address of the network device in the address format of the address family. IP addresses are written in the usual dotted decimal notation, a.b.c.d.

If ifconfig is started with the name of a network device, then only the configuration of this interface is output on the console. If you start it without parameters, it lists all currently configured interfaces. The option -a can be used to additionally display network devices known to the kernel, but not yet activated.

Example

root@tux # ifconfig eth0   Link encap:Ethernet HWaddr 00:90:27:44:D9:89        inet addr:129.13.25.10 Bcast:129.13.25.255 Mask:255.255.255.0        UP BROADCAST RUNNING MTU:1500 Metric:1        RX packets:879876 errors:1 dropped:0 overruns:0 frame:11        TX packets:706287 errors:0 dropped:0 overruns:0 carrier:0        collisions:45793 txqueuelen:100        Interrupt:11 Base address:0xe800 lo     Link encap:Local Loopback        inet addr:127.0.0.1 Mask:255.0.0.0        UP LOOPBACK RUNNING MTU:3924 Metric:1        RX packets:130 errors:0 dropped:0 overruns:0 frame:0        TX packets:130 errors:0 dropped:0 overruns:0 carrier:0        collisions:0 txqueuelen:0

  • The fields MTU and Metric show the current values for Maximum Transfer Unit (MTU) and the metrics of the interface. The metrics can be used by routing protocols to make a choice when several routes having the same cost lead over two different network devices.

  • The flags displayed by ifconfig correspond more or less to the names of command parameters and will later be explained further.

  • The RX (Receive) and TX (Transmit) information shows how many packets have been received or sent over the network device.

  • errors gives the number of errors that occurred.

  • overruns shows the number of faulty packets. Among other reasons, errors can occur that are due to an overrun of the receive queue. An overrun occurs in a computer when more packets arrive than the kernel can process. The input queues reach their maximum (max_backlog), and all packets arriving additionally will be dropped. (See Chapter 6.)

The following list describes the parameters of the ifconfig command (with the names of the relevant flags in brackets). Some of these parameters enable certain modes of the network device (e.g., the ARP capability). These modes can be disabled by a leading minus (? sign.

  • up activates a network device. When you use this command to state an address, then up is taken as the default option. If up is called without additional parameters, ifconfig initializes the network adapter to the default values (e.g., the IP address to 0.0.0.0, which won't make much sense). The up option sets the flags UP and RUNNING.

  • down deactivates a network device. However, this device remains in the list of registered network devices, so that it can be reactivated later. At the same time, all routes in which this network device participated are removed from the routing table.

  • netmask mask assigns a subnet mask to the network device.

  • pointopoint address is used for a point-to-point connection that directly connects two computers. Examples include SLIP and PLIP network connections. This parameter is used to set the IP address of the peer system. ifconfig shows the presence of a point-to-point peer by the flag POINTOPOINT.

  • broadcast address sets the broadcast address of the network device. It normally is built from the network address and the appropriate address class. All bits of the host part are set to one. However, the broadcast address can also be set explicitly. The presence of a broadcast address is shown by the flag BROADCAST.

  • mtu bytes sets the Maximum Transfer Unit (MTU) (i.e., the maximum size of a MAC frame) to the specified size. The default value is 1500 bytes for Ethernet adapters, 296 bytes for SLIP connections.

  • arp enables the Address Resolution Protocol for network devices that use broadcast technologies (Ethernet, token ring, etc.) to allocate logical layer-3 addresses to physical MAC addresses. This option is set by default for broadcast networks. ifconfig shows the flag NOARP if ARP was deactivated.

  • -arp disables the use of the Address Resolution Protocol and sets the NOARP flag.

  • promisc moves the network adapter into the promiscuous mode. For broadcast-capable networks, this mode causes all packets to be received by the network interface and to be forwarded to the higher layers, regardless of whether they are addressed to this computer. This allows us to monitor the network traffic in a local area network. Of course, this mode should be used for analysis purposes only, which is often extremely useful. The tcpdump tool uses the promiscuous mode to analyze the traffic in a local area network. The promiscuous mode is shown by the flag PROMISC.

  • -promisc disables the promiscuous mode.

  • multicast enables the receipt of multicast packets addressed to groups at which the computer is registered as a member.

  • -multicast disables the receipt of multicast packets.

  • allmulti enables the receipt of all multicast packets, including multicast packets from groups of which the computer is not a member. This mode is used by multicast routers, among others.

  • -allmulti disables the allmulti mode.

  • irq, io_addr, and mem_start set the number of the interrupt, the I/O address, and the memory address of a network adapter.


       


    Linux Network Architecture
    Linux Network Architecture
    ISBN: 131777203
    EAN: N/A
    Year: 2004
    Pages: 187

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net