ip linkNetwork Device Configuration

   

ip link ” Network Device Configuration

A link refers to a network device. The ip link object and the corresponding command set allow you to view and manipulate the state of network devices. There are just two commands for the link object: set and show .

The full help syntax which you may want to refer back to for ip link is as follows :

 
 Usage: ip link set DEVICE {  up  down  arp {  on  off }                                dynamic {  on  off }                                multicast {  on  off }   txqueuelen PACKETS                               name NEWNAME                               address LLADDR  broadcast LLADDR                               mtu MTU }        ip link show [ DEVICE ] 
 

ip link set ” Change Device Attributes

This command allows you to change device attributes.

Abbreviations: set, s

Warning

You can request multiple parameter changes with ip link . If you request multiple parameter changes and any ONE change fails, ip aborts immediately after the failure. Thus, the parameter changes prior to the failure have completed and are not backed out on abort. This is the only case where using the ip command can leave your system in an unpredictable state. The solution is to avoid changing multiple parameters with one ip link set call. Use as many individual ip link set commands as necessary to perform the actions you want.


Arguments
  • dev NAME (default) ” NAME specifies the network device to operate on, for example: eth0 .

  • up/down ” Change the state of the device to up or down .

  • arp on/arp off ” Change NOARP flag status on the device.

    Note that this operation is not allowed if the device is already in the up state. Since neither the ip utility nor the kernel checks for this condition, you can get very unpredictable results changing the flag while the device is running. It is better to set the device down , then issue this command.

  • multicast on/multicast off ” Change the MULTICAST flag on the device.

  • dynamic on/dynamic off ” Change the DYNAMIC flag on the device.

  • name NAME ”Change the name of the device.

    Note that this operation is not recommended if the device is running or has some addresses already configured. You can break your system's security and inadvertently modify other networking daemons and programs by changing the device name while the device is running or has addressing assigned.

  • txqueuelen NUMBER /txqlen NUMBER ” Change the transmit queue length of the device.

  • mtu NUMBER ”Change the MTU (maximum transfer unit) of the device.

  • address LLADDRESS ”Change the station address of the interface.

  • broadcast LLADDRESS , brd LLADDRESS , or peer LLADDRESS ”Change the link layer broadcast address (or peer address in the case of a POINTOPOINT interface).

    Note that, for most physical network devices (ethernet, token ring, and so on), changing the link layer broadcast address will break networking. Do not use this argument if you do not understand what this operation really does.

The ip command does not allow changing the PROMISC and ALLMULTI flags, which are considered obsolete and should not be changed administratively.

Examples

To change the station address of the interface dummy :

 
 ip link set dummy address 000000000001 
 

To start the interface dummy:

 
 ip link set dummy up 

ip link show ” Look at Device Attributes

This command allows you to look at the device attributes.

Abbreviations: show, list, lst, sh, ls, l

Arguments

This command only has two arguments:

  • dev NAME (default) ” NAME specifies the network device to show. If this argument is omitted, the command lists all the devices.

  • up ” Display only running interfaces.

Example
 
 kuznet@alisa~:$  ip link ls dummy  2: dummy: <BROADCAST,NOARP> mtu 1500 qdisc noop     link/ether 00:00:00:00:00:00 brd ff:ff:ff:ff:ff:ff 
 

The number followed by a colon is the interface index or ifindex. This number uniquely identifies the interface. If you look at the output from cat /proc/net/dev , you will see that the network devices are listed in the same order as the numbering you see here. After the ifindex is the interface name ( eth0, sit0 , and so on). The interface name is also unique at any given moment; however, interfaces may disappear from the list, such as when the corresponding driver module is unloaded, and another interface with the same name will be created later. Additionally, with the ip link set DEVICE name NEWNAME command, the system administrator may change the device's name.

The interface name may also have another name or the keyword NONE appended after an @ symbol. This signifies that this device is bound to another device in a master/slave device relationship. Thus, packets sent through this device are encapsulated and forwarded via the master device. If the name is NONE , the master device is unknown.

After the interface name you see the flags associated with the device. Then comes the interface mtu , which determines the maximum size of a data packet that can be sent as a single packet over this interface.

qdisc (queuing discipline) shows which queuing algorithm is used on the interface. In particular, the keyword noqueue means that this interface does not queue anything. The keyword noop indicates that the interface is in blackhole mode, in which all of the packets sent to it are immediately discarded. The queueing disciplines refer to the QoS setup for the device.

The qlen indicates the default transmit queue length of the device, measured in packets.

The flags that are shown within the angle brackets show the actual kernel associated status of the device. The most applicable flags are as follows:

  • UP ”This device is turned on, ready to accept packets for transmission onto the network. It also may receive packets from other nodes on the network.

  • LOOPBACK ”The interface does not communicate to other hosts . All the packets that are sent through it will be returned to the sender, and only bounced-back packets can be received.

  • BROADCAST ”This device is able to send packets to all other hosts sharing the same physical link, for example, Ethernet.

  • POINTOPOINT ”The network has only two ends with two nodes attached. All the packets sent to the link will reach the peer link, and all packets received are originated by the peer.

  • If neither LOOPBACK nor BROADCAST nor POINTOPOINT is set, the interface is assumed to be a NBMA (Non-Broadcast Multi-Access) link. NBMA is the most generic (and also the most complicated) type of device type, because a host attached to a NBMA link cannot send information to any other host without additional manually provided configuration information.

  • MULTICAST ”An advisory flag noting that the interface is aware of multicasting. Broadcasting is a particular case of multicasting in which the multicast group contains all of the nodes on the link as members . Note that software must NOT interpret the absence of this flag as the incapability of the interface to multicast. Any POINTOPOINT or BROADCAST link is multicasting by definition, because you have direct access to all the link neighbors and thus to any particular group of them. The use of high-bandwidth multicast transfers is not recommended on broadcast-only networks because of the high expense associated with the transmission, but such use is not strictly prohibited .

  • PROMISC ” The device listens and feeds to the kernel all of the traffic on the link. This includes every packet on the network that passes the transceiver. Usually this mode exists only on broadcast links and is used by bridges and network monitoring devices.

  • ALLMULTI ” The device receives all multicast packets wandering on the link. This mode is used by multicast routers.

  • NOARP ”This flag is different from the other flags. It has no invariant value, and its interpretation depends on network protocols involved. As a rule, it indicates that the device does not need any address resolution and that the software or hardware knows how to deliver packets without any help from the protocol stacks.

  • DYNAMIC ”This is an advisory flag marking this interface as dynamically created and destroyed .

  • SLAVE ”This interface is bound to other interfaces in order to share link capacities .

Other flags do exist and can be seen within the angle brackets, but they are either obsolete ( NOTRAILERS ), not implemented ( DEBUG ), or specific to certain devices ( MASTER, AUTOMEDIA , and PORTSEL ). They do not need to be discussed here. Additionally, the values of the PROMISC and ALLMULTI flags as shown by the ifconfig utility and by the ip utility are different. The ip link list command provides the current true device state, whereas ifconfig shows the flag state that was set through ifconfig itself.

The second line of the output from the example contains information about the link layer addresses associated with the device. The first word ( ether, sit ) defines the interface hardware type, which then determines the format and semantics of the addresses and thus logically is part of the address itself. The default format of station and broadcast addresses (or peer addresses for POINTOPOINT links) is a sequence of hexadecimal bytes separated by colons. However, some link types may instead have their own natural address formats that are used in the presentation. For example, the addresses of IP tunnels are printed as dotted -quad IP addresses. While NBMA links have no well-defined broadcast or peer address, this field may contain useful information such as the address of a broadcast relay or the address of an ARP server. Multicast addresses are not shown by this command.

When given the option -statistics, ip will print the interface statistics as additional information in the listing. Note that you can give this option multiple times, with each repetition increasing the verbosity of output.

 
 kuznet@alisa~ $  ip -s link ls eth0  3: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc cbq qlen 100     link/ether 00:a0:cc:66:18:78 brd ff:ff:ff:ff:ff:ff     RX bytes  packets  errors  dropped overrun mcast     2449949362 2786187  0       0       0       0     TX bytes  packets  errors  dropped carrier collsns     178558497  1783945  332     0       332     35172 
 

The RX and TX lines summarize receiver and transmitter statistics. The information output breaks down into the following:

  • bytes ” The total number of bytes received or transmitted on the interface.

  • This number wraps when the maximum length of the natural data type on the architecture is exceeded. In order to provide correct long term data from this output, these statistics should be continuously monitored . Continuous monitoring of this data requires a user -level daemon to sample the output periodically.

  • packets ” The total number of packets received or transmitted on the interface.

  • errors ” The total number of receiver or transmitter errors.

  • dropped ” The total number of packets dropped because of lack of resources.

  • overrun ” The total number of receiver overruns resulting in packet drops . As a rule, if the interface is overrun, either you have a serious problem within the kernel or your machine is too slow to handle the speed of this interface.

  • mcast ” The total number of received multicast packets. This option is supported only on certain devices.

  • carrier ” The total number of link media failures, such as those due to lost carrier.

  • collsns ” The total number of collision events on ethernet-like media. This number has different interpretations on other link types.

  • compressed ” The total number of compressed packets. It is available only for links using VJ header compression.

When you issue the -statistics option more than once, you get additional output, depending on the statistics supported by the device itself, as in the following example with ethernet:

 
 kuznet@alisa~ $  ip -s -s link ls eth0  3: eth0: <BROADCAST,MULTICAST,UP> mtu 1500 qdisc cbq qlen 100     link/ether 00:a0:cc:66:18:78 brd ff:ff:ff:ff:ff:ff     RX bytes  packets  errors  dropped overrun mcast     2449949362 2786187  0       0       0       0     RX errors length   crc     frame   fifo    missed                0        0       0       0       0     TX bytes  packets  errors  dropped carrier collsns     178558497  1783945  332     0       332     35172     TX errors aborted  fifo    window  heartbeat                0        0       0       332 
 

In this case the error names are pure ethernetisms. Other devices may have non-zero fields in these positions , but the headers are generated independently of the device responses. It is up to the device driver to send more appropriate error messages to the system logging facility, such as is done by the token ring driver.


   
Top


Policy Routing Using Linux
Policy Routing Using Linux
ISBN: B000C4SRVI
EAN: N/A
Year: 2000
Pages: 105

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