Linux Networking HOWTO - DocBook Rev .02 | ||
---|---|---|
Prev | Chapter 5. Generic Network Configuration Information. | Next |
When you have all of the programs you need and your address and network information you can configure your network interfaces. When we talk about configuring a network interface we are talking about the process of assigning appropriate addresses to a network device and to setting appropriate values for other configurable parameters of a network device. The program most commonly used to do this is the ifconfig (interface configure) command.
Typically you would use a command similar to the following:
root# ifconfig eth0 192.168.0.1 netmask 255.255.255.0 up |
In this case I'm configuring an ethernet interface `eth0' with the IP address `192.168.0.1' and a network mask of `255.255.255.0'. The `up' that trails the command tells the interface that it should become active, but can usually be omitted, as it is the default. To shutdown an interface, you can just call ``ifconfig eth0 down''.
The kernel assumes certain defaults when configuring interfaces. For example, you may specify the network address and broadcast address for an interface, but if you don't, as in my example above, then the kernel will make reasonable guesses as to what they should be based on the netmask you supply and if you don't supply a netmask then on the network class of the IP address configured. In my example the kernel would assume that it is a class-C network being configured on the interface and configure a network address of `192.168.0.0' and a broadcast address of `192.168.0.255' for the interface.
There are many other options to the ifconfig command. The most important of these are:
This option activates an interface (and is the default).
This option deactivates an interface.
This option enables or disables use of the address resolution protocol on this interface
This option enables or disables the reception of all hardware multicast packets. Hardware multicast enables groups of hosts to receive packets addressed to special destinations. This may be of importance if you are using applications like desktop videoconferencing but is normally not used.
This parameter allows you to set the MTU of this device.
This parameter allows you to set the network mask of the network this device belongs to.
This parameter only works on certain types of hardware and allows you to set the IRQ of the hardware of this device.
This parameter allows you to enable and set the accepting of datagrams destined to the broadcast address, or to disable reception of these datagrams.
This parameter allows you to set the address of the machine at the remote end of a point to point link such as for slip or ppp.
This parameter allows you to set the hardware address of certain types of network devices. This is not often useful for ethernet, but is useful for other network types such as AX.25.
With the release of Kernel 2.2 there are a number of options available that are not listed above. Some of the most interesting are tunneling and IPV6 options. The ifconfig paramaters for kernel 2.2 are listed below.
The name of the interface. This is usually a driver name followed by a unit number, for example eth0 for the first Ethernet interface.
This flag causes the interface to be activated. It is implicitly specified if an address is assigned to the interface.
This flag causes the driver for this interface to be shut down.
Enables or disables the use of the ARP protocol on this interface.
Enables or disables the promiscuous mode of the interface. If selected, all packets on the network will be received by the interface.
Enables or disables all-multicast mode. If selected, all multicast packets on the network will be received by the interface.
This parameter sets the interface metric.
This parameter sets the Maximum Transfer Unit (MTU) of an interface.
Sets the remote IP address for a point-to-point link (such as PPP). This keyword is now obsolete; use the pointopoint keyword instead.
Sets the IP network mask for this interface. This value defaults to the usual class A, B or C network mask (as derived from the interface IP address), but it can be set to any value.
Adds an IPv6 address to an interface.
Removes an IPv6 address from an interface.
Creates a new SIT (IPv6-in-IPv4) device, tunnelling to the given destination.
Sets the interrupt line used by this device. Not all devices can dynamically change their IRQ set- ting.
Sets the start address in I/O space for this device.
Set the start address for shared memory used by this device. Only a few devices need this.
Sets the physical port or medium type to be used by the device. Not all devices can change this set- ting, and those that can vary in what values they support. Typical values for type are 10base2 (thin Ethernet), 10baseT (twisted-pair 10Mbps Ethernet), AUI (external transceiver) and so on. The special medium type of auto can be used to tell the driver to auto-sense the media. Again, not all drivers can do this.
If the address argument is given, set the protocol broadcast address for this interface. Otherwise, set (or clear) the IFF_BROADCAST flag for the interface.
This keyword enables the point-to-point mode of an interface, meaning that it is a direct link between two machines with nobody else listening on it. If the address argument is also given, set the pro- tocol address of the other side of the link, just like the obsolete dstaddr keyword does. Otherwise, set or clear the IFF_POINTOPOINT flag for the interface.
Set the hardware address of this interface, if the device driver supports this operation. The keyword must be followed by the name of the hardware class and the printable ASCII equivalent of the hardware address. Hardware classes currently supported include ether (Ethernet), ax25 (AMPR AX.25), ARCnet and netrom (AMPR NET/ROM).
Set the multicast flag on the interface. This should not normally be needed as the drivers set the flag correctly themselves.
The IP address to be assigned to this interface.
Set the length of the transmit queue of the device. It is useful to set this to small values for slower devices with a high latency (modem links, ISDN) to prevent fast bulk transfers from disturbing inter- active traffic like telnet too much.
You may use the ifconfig command on any network interface. Some user programs such as pppd and dip automatically configure the network devices as they create them, so manual use of ifconfig is unnecessary.